Пример #1
0
    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'
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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
Пример #8
0
 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