You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
595 B
19 lines
595 B
import logging
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from api_client import TweedeKamerAPI
|
|
|
|
|
|
class TestTweedeKamerAPILogging:
|
|
def test_get_motions_error_logged(self, caplog):
|
|
api = TweedeKamerAPI()
|
|
caplog.set_level(logging.ERROR, logger="api_client")
|
|
|
|
with patch.object(api, "_get_voting_records", side_effect=Exception("network down")):
|
|
result = api.get_motions()
|
|
|
|
assert result == []
|
|
assert any("network down" in rec.message for rec in caplog.records)
|
|
assert any(rec.levelno == logging.ERROR for rec in caplog.records)
|
|
|