def test_check_answer_multiple_choice(self, member): correct_update = Update(1, poll_answer=PollAnswer(123, None, [1])) false_update = Update(1, poll_answer=PollAnswer(123, None, [0])) for attr in Question.SUPPORTED_ATTRIBUTES: q = Question(member, attr, poll=self.poll) assert q.check_answer(correct_update) assert not q.check_answer(false_update) assert q.correct_answer == 'Opt2'
def test_check_answer_free_text_location_coords(self, answer, result, member): q = Question(member, Question.ADDRESS, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, location=Location(*reversed(answer)))) assert q.check_answer(update) is result assert q.correct_answer == member.address
def test_check_answer_free_text_functions(self, answer, result, member): q = Question(member, Question.FUNCTIONS, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, text=answer)) assert q.check_answer(update) is result assert q.correct_answer == member.functions_str
def test_check_answer_free_text_instrument(self, answer, result, member): q = Question(member, Question.INSTRUMENT, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, text=answer)) assert q.check_answer(update) is result assert q.correct_answer == member.instruments_str
def test_check_answer_free_text_joined(self, answer, result, member): q = Question(member, Question.JOINED, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, text=answer)) assert q.check_answer(update) is result assert q.correct_answer == str(member.joined)
def test_check_answer_free_text_birthday(self, answer, result, member): q = Question(member, Question.BIRTHDAY, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, text=answer)) assert q.check_answer(update) is result assert q.correct_answer == str(member.birthday)
def test_check_answer_free_text_full_name(self, answer, result, member): member.nickname = 'nick' q = Question(member, Question.FULL_NAME, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, text=answer)) assert q.check_answer(update) is result assert q.correct_answer == member.full_name
def test_check_answer_free_text_last_name(self, answer, result, member): q = Question(member, Question.LAST_NAME, multiple_choice=False) update = Update(1, message=Message(1, None, None, None, text=answer)) assert q.check_answer(update) is result assert q.correct_answer == member.last_name