Beispiel #1
0
    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()
Beispiel #2
0
    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()
Beispiel #3
0
    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()