pyircbot/tests/modules/test_urban.py
2017-12-03 23:18:33 -08:00

24 lines
700 B
Python

import pytest
from unittest.mock import MagicMock
from tests.lib import * # NOQA - fixtures
import requests
@pytest.fixture
def urbanbot(fakebot):
"""
Provide a bot loaded with the Seen module
"""
fakebot.loadmodule("Urban")
return fakebot
def test_seen(urbanbot, monkeypatch):
def fakeget(url, params=None):
r = MagicMock()
r.json = lambda: {"list": [{"definition": "A process for testing things", "defid": 708924}]}
return r
monkeypatch.setattr(requests, 'get', fakeget)
urbanbot.feed_line(".u test")
urbanbot.act_PRIVMSG.assert_called_once_with('#test', "Urban definition: A process for testing things - http://urbanup.com/708924")