This repository was archived by the owner on Jun 26, 2022. It is now read-only.
File tree 4 files changed +24
-4
lines changed
4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 3
3
SonarrAccessRestricted ,
4
4
SonarrConnectionError ,
5
5
SonarrError ,
6
+ SonarrResourceNotFound ,
6
7
)
7
8
from .sonarr import Client , Sonarr # noqa
Original file line number Diff line number Diff line change 9
9
from yarl import URL
10
10
11
11
from .__version__ import __version__
12
- from .exceptions import SonarrAccessRestricted , SonarrConnectionError , SonarrError
12
+ from .exceptions import (
13
+ SonarrAccessRestricted ,
14
+ SonarrConnectionError ,
15
+ SonarrError ,
16
+ SonarrResourceNotFound ,
17
+ )
13
18
14
19
15
20
class Client :
@@ -94,6 +99,9 @@ async def _request(
94
99
"Access restricted. Please ensure valid API Key is provided" , {}
95
100
)
96
101
102
+ if response .status == 404 :
103
+ raise SonarrResourceNotFound ("Resource not found" )
104
+
97
105
content_type = response .headers .get ("Content-Type" , "" )
98
106
99
107
if (response .status // 100 ) in [4 , 5 ]:
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ class SonarrConnectionError(SonarrError):
14
14
15
15
16
16
class SonarrAccessRestricted (SonarrError ):
17
- """Sonarr access restricted."""
17
+ """Sonarr access restricted exception."""
18
+
19
+ pass
20
+
21
+
22
+ class SonarrResourceNotFound (SonarrError ):
23
+ """Sonarr resource not found exception."""
18
24
19
25
pass
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
from aiohttp import ClientSession
6
6
from sonarr import Client
7
- from sonarr .exceptions import SonarrAccessRestricted , SonarrConnectionError , SonarrError
7
+ from sonarr .exceptions import (
8
+ SonarrAccessRestricted ,
9
+ SonarrConnectionError ,
10
+ SonarrError ,
11
+ SonarrResourceNotFound ,
12
+ )
8
13
9
14
API_KEY = "MOCK_API_KEY"
10
15
HOST = "192.168.1.89"
@@ -169,7 +174,7 @@ async def test_http_error404(aresponses):
169
174
170
175
async with ClientSession () as session :
171
176
client = Client (HOST , API_KEY , session = session )
172
- with pytest .raises (SonarrError ):
177
+ with pytest .raises (SonarrResourceNotFound ):
173
178
assert await client ._request ("system/status" )
174
179
175
180
You can’t perform that action at this time.
0 commit comments