def test_count_failed(self): """ tests bancount with a failed API response """ responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_failed) assert bancount(test_user, DummyBot) == reply_failed
def test_count(self): """ tests bancount with a successful API response having multiple bans """ responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api) assert bancount(test_user, DummyBot) == count_reply
def test_count_error(self): """ tests bancount with a HTTP error """ responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', status=404) assert bancount(test_user, DummyBot).startswith(reply_error)
def test_count_failed(monkeypatch): def fake_http(url): assert url == "http://api.fishbans.com/stats/notch/" return json.loads(test_api_failed) monkeypatch.setattr(http, "get_json", fake_http) assert bancount(test_user) == count_reply_failed