Skip to content

Commit bd5be8e

Browse files
authored
Fix methods not raising InvalidAuth when unauthorized (#1)
* Fix get_status not raising InvalidAuth when unauthorized * Fix login not raising InvalidAuth * update version
1 parent 5e914c1 commit bd5be8e

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.0.1
2+
3+
* Fix login and get_status not raising InvalidAuth when unauthorized
4+
15
# 1.0.0
26

37
* Initial commit

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = PyLoadAPI
3-
version = 1.0.0
3+
version = 1.0.1
44
author = Manfred Dennerlein Rodelo
55
author_email = [email protected]
66
description = "Simple wrapper for pyLoad's API."
@@ -22,4 +22,4 @@ install_requires =
2222
aiohttp~=3.9
2323

2424
[options.packages.find]
25-
where=src
25+
where=src

src/pyloadapi/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def login(self) -> LoginResponse:
4444
r.raise_for_status()
4545
try:
4646
data = await r.json()
47-
if not r:
47+
if not data:
4848
raise InvalidAuth
4949
return LoginResponse.from_dict(data)
5050
except JSONDecodeError as e:
@@ -67,9 +67,10 @@ async def get_status(self) -> StatusServerResponse:
6767
_LOGGER.debug(
6868
"Response from %s [%s]: %s", url, r.status, (await r.text())
6969
)
70-
r.raise_for_status()
70+
7171
if r.status == HTTPStatus.UNAUTHORIZED:
7272
raise InvalidAuth
73+
r.raise_for_status()
7374
try:
7475
data = await r.json()
7576
return StatusServerResponse.from_dict(data)

0 commit comments

Comments
 (0)