def test_request_error(self, mocker) -> None: mocker.patch( "requests.Session.get", side_effect=requests.exceptions.RequestException() ) with pytest.raises(TemporaryCheckError): KodiIdleTime("foo", url="url", timeout=10, idle_time=42).check()
def test_result_no_entry(self, mocker) -> None: mock_reply = mocker.MagicMock() mock_reply.json.return_value = {"id": 1, "jsonrpc": "2.0", "result": {}} mocker.patch("requests.Session.get", return_value=mock_reply) with pytest.raises(TemporaryCheckError): KodiIdleTime("foo", url="url", timeout=10, idle_time=42).check()
def test_no_result(self, mocker): mock_reply = mocker.MagicMock() mock_reply.json.return_value = {"id": 1, "jsonrpc": "2.0"} mocker.patch('requests.Session.get', return_value=mock_reply) with pytest.raises(TemporaryCheckError): KodiIdleTime('foo', url='url', timeout=10, idle_time=42).check()
def test_inactive(self, mocker): mock_reply = mocker.MagicMock() mock_reply.json.return_value = {"id": 1, "jsonrpc": "2.0", "result": { "System.IdleTime(42)": True}} mocker.patch('requests.Session.get', return_value=mock_reply) assert KodiIdleTime('foo', url='url', timeout=10, idle_time=42).check() is None
def test_active(self, mocker) -> None: mock_reply = mocker.MagicMock() mock_reply.json.return_value = { "id": 1, "jsonrpc": "2.0", "result": {"System.IdleTime(42)": False}, } mocker.patch("requests.Session.get", return_value=mock_reply) assert ( KodiIdleTime("foo", url="url", timeout=10, idle_time=42).check() is not None )
def create_instance(self, name): return KodiIdleTime(name, url="url", timeout=10, idle_time=10)
def test_request_error(self, mocker): mocker.patch('requests.Session.get', side_effect=requests.exceptions.RequestException()) with pytest.raises(TemporaryCheckError): KodiIdleTime('foo', url='url', timeout=10, idle_time=42).check()