How to use the pmxbot.karma.karma function in pmxbot

To help you get started, we’ve selected a few pmxbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_set_and_check(self):
        """
        Take a new entity, give it some karma, check that it has more
        """
        id = str(uuid.uuid4())
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match("^%s has 0 karmas$" % id, res)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s--" % id)
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match(r"^%s has 2 karmas$" % id, res)
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_check_self_blank(self):
        """
        Determine your own, blank, karma.
        """
        id = str(uuid.uuid4())[:15]
        res = karma.karma(nick=id, rest="")
        assert re.match(r"^%s has 0 karmas$" % id, res)
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_check_other_blank(self):
        """
        Determine some else's blank/new karma.
        """
        id = str(uuid.uuid4())
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match("^%s has 0 karmas$" % id, res)
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_set_and_check_with_space(self):
        """
        Take a new entity that has a space in it's name, give it some karma,
        check that it has more
        """
        id = str(uuid.uuid4()).replace("-", " ")
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match("^%s has 0 karmas$" % id, res)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s--" % id)
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match(r"^%s has 2 karmas$" % id, res)
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_randomchange(self):
        """
        Take a new entity that has a space in it's name, give it some karma,
        check that it has more
        """
        id = str(uuid.uuid4())
        flags = {}
        i = 0
        karmafetch = re.compile(r"^%s has (\-?\d+) karmas$" % id)
        while len(flags) < 3 and i <= 30:
            res = karma.karma(nick="testrunner", rest=id)
            prekarma = int(karmafetch.findall(res)[0])
            change = karma.karma(nick="testrunner", rest="%s~~" % id)
            assert change in [
                "%s karma++" % id,
                "%s karma--" % id,
                "%s karma shall remain the same" % id,
            ]
            if change.endswith('karma++'):
                flags['++'] = True
                res = karma.karma(nick="testrunner", rest=id)
                postkarma = int(karmafetch.findall(res)[0])
                assert postkarma == prekarma + 1
            elif change.endswith('karma--'):
                flags['--'] = True
                res = karma.karma(nick="testrunner", rest=id)
                postkarma = int(karmafetch.findall(res)[0])
                assert postkarma == prekarma - 1
            elif change.endswith('karma shall remain the same'):
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
"%s karma--" % id,
                "%s karma shall remain the same" % id,
            ]
            if change.endswith('karma++'):
                flags['++'] = True
                res = karma.karma(nick="testrunner", rest=id)
                postkarma = int(karmafetch.findall(res)[0])
                assert postkarma == prekarma + 1
            elif change.endswith('karma--'):
                flags['--'] = True
                res = karma.karma(nick="testrunner", rest=id)
                postkarma = int(karmafetch.findall(res)[0])
                assert postkarma == prekarma - 1
            elif change.endswith('karma shall remain the same'):
                flags['same'] = True
                res = karma.karma(nick="testrunner", rest=id)
                postkarma = int(karmafetch.findall(res)[0])
                assert postkarma == prekarma
            i += 1
        assert len(flags) == 3
        assert i < 30
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_set_and_check(self):
        """
        Take a new entity, give it some karma, check that it has more
        """
        id = str(uuid.uuid4())
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match("^%s has 0 karmas$" % id, res)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s--" % id)
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match(r"^%s has 2 karmas$" % id, res)
github yougov / pmxbot / tests / unit / test_commands.py View on Github external
def test_karma_set_and_check_with_space(self):
        """
        Take a new entity that has a space in it's name, give it some karma,
        check that it has more
        """
        id = str(uuid.uuid4()).replace("-", " ")
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match("^%s has 0 karmas$" % id, res)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s++" % id)
        res = karma.karma(nick="testrunner", rest="%s--" % id)
        res = karma.karma(nick="testrunner", rest=id)
        assert re.match(r"^%s has 2 karmas$" % id, res)