Exemplo n.º 1
0
    def test_check_update_free_text(self, member):
        valid_update = Update(1,
                              message=Message(1, None, None, None,
                                              text='text'))
        invalid_update = Update(1, poll_answer=PollAnswer(123, None, [1]))

        for attr in [
                a for a in Question.SUPPORTED_ATTRIBUTES if a != Question.PHOTO
        ]:
            q = Question(member, attr, multiple_choice=False)
            assert q.check_update(valid_update)
            assert not q.check_update(invalid_update)

        q = Question(member, Question.ADDRESS, multiple_choice=False)

        valid_update = Update(1,
                              message=Message(1,
                                              None,
                                              None,
                                              None,
                                              location=Location(longitude=1,
                                                                latitude=1)))
        invalid_update = Update(1, poll_answer=PollAnswer(123, None, [1]))
        assert q.check_update(valid_update)
        assert not q.check_update(invalid_update)
Exemplo n.º 2
0
    def test_check_update_multiple_choice(self, member):
        valid_update = Update(1, poll_answer=PollAnswer(123, None, [1]))
        invalid_update = Update(1, message=True)

        for attr in Question.SUPPORTED_ATTRIBUTES:
            q = Question(member, attr, poll=self.poll)
            assert q.check_update(valid_update)
            assert not q.check_update(invalid_update)