Esempio n. 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)
Esempio n. 2
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!"))