def test_assertion_no_result(self, mocker): mock_reply = mocker.MagicMock() mock_reply.json.return_value = {"id": 1, "jsonrpc": "2.0"} mocker.patch('requests.get', return_value=mock_reply) with pytest.raises(autosuspend.TemporaryCheckError): autosuspend.Kodi('foo', 'url', 10).check()
def test_not_playing(self, mocker): mock_reply = mocker.MagicMock() mock_reply.json.return_value = { "id": 1, "jsonrpc": "2.0", "result": [] } mocker.patch('requests.get', return_value=mock_reply) assert autosuspend.Kodi('foo', 'url', 10).check() is None mock_reply.json.assert_called_once_with()
def test_request_error(self, mocker): mocker.patch('requests.get', side_effect=requests.exceptions.RequestException()) with pytest.raises(autosuspend.TemporaryCheckError): autosuspend.Kodi('foo', 'url', 10).check()