Пример #1
0
    def test_trivia_command_callback(self):
        query = BotQuery()
        query.has_callback_query = True
        query.callback_query = BotQuery()
        query.callback_query.callback_data = "payload here/trivia"

        result = CommandParser.parse_command(query)
        self.assertIsInstance(result, TriviaCommand)
        self.assertIs(query, result.query)
Пример #2
0
    def test_trivia_callback_query(self):
        query = BotQuery()
        query.has_callback_query = True

        trivia_command = TriviaCommand(query)
        trivia_command.handle_callback_query = Mock()

        trivia_command.execute()
        trivia_command.handle_callback_query.assert_called_once()
Пример #3
0
    def test_trivia_callback_query_correct(self):
        query = BotQuery()
        query.has_callback_query = True
        query.callback_query = BotQuery()
        query.callback_query.callback_data = "CC/trivia"
        trivia_command = TriviaCommand(query)

        with patch("commands.trivia_command.requests.post") as mock_post:
            trivia_command.execute()
            response_text = mock_post.call_args[1]["json"]["text"]
            self.assertTrue(response_text.endswith("*C* is correct!"))