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'): 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
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)
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)
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)
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)