Ejemplo n.º 1
0
    def test_http_error(self, fake_message, mocker):
        fake_message.text = '/quote'
        mocker.patch('tululbot.commands.quote_engine.retrieve_random', side_effect=HTTPError,
                     autospec=True)
        mock_reply_to = mocker.patch('tululbot.commands.bot.reply_to', autospec=True)

        quote(fake_message)

        mock_reply_to.assert_called_once_with(fake_message, 'Aduh ada error nich')
Ejemplo n.º 2
0
    def test_conn_error(self, fake_message, mocker):
        fake_message.text = '/quote'
        mocker.patch('tululbot.commands.quote_engine.retrieve_random',
                     side_effect=ConnectionError, autospec=True)
        mock_reply_to = mocker.patch('tululbot.commands.bot.reply_to', autospec=True)

        quote(fake_message)

        mock_reply_to.assert_called_once_with(fake_message, "Koneksi lagi bapuk nih :'(")
Ejemplo n.º 3
0
    def test_quote(self, fake_message, mocker):
        fake_message.text = '/quote'
        mock_engine = mocker.patch('tululbot.commands.quote_engine', autospec=True)
        mock_reply_to = mocker.patch('tululbot.commands.bot.reply_to', autospec=True)
        mock_engine.retrieve_random.return_value = 'some random quote'

        quote(fake_message)

        mock_reply_to.assert_called_once_with(fake_message, 'some random quote')