Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
PTST committed Nov 3, 2024
1 parent e69bed6 commit c0db833
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
4 changes: 3 additions & 1 deletion custom_components/danish_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ async def authenticate(self):
token_text = token_response.text

self.user_token = re.search(r"\"user\",\s*\"(.*?)\"", token_text).group(1)
self.library_token = re.search(r"\"library\",\s*\"(.*?)\"", token_text).group(1)
self.library_token = re.search(
r"\"library\",\s*\"(.*?)\"", token_text
).group(1)
except httpx.HTTPStatusError as e:
if e.response.status_code >= 500:
LOGGER.debug(e, exc_info=True)
Expand Down
39 changes: 26 additions & 13 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,69 @@
import pytest

from custom_components.danish_libraries.api import Library
from custom_components.danish_libraries.models import EreolenLoan, EreolenReservation, LibraryConfig, Loan, ProfileInfo, Reservation
from custom_components.danish_libraries.models import (
EreolenLoan,
EreolenReservation,
LibraryConfig,
Loan,
ProfileInfo,
Reservation,
)

dotenv.load_dotenv()


async def test_auth():
user = os.getenv('LIBRARY_USER_ID')
pin = os.getenv('LIBRARY_PIN')
user = os.getenv("LIBRARY_USER_ID")
pin = os.getenv("LIBRARY_PIN")
lib = Library("Aalborg", user, pin)
await lib.authenticate()
assert lib.user_bearer_token != None


async def test_loans():
user = os.getenv('LIBRARY_USER_ID')
pin = os.getenv('LIBRARY_PIN')
user = os.getenv("LIBRARY_USER_ID")
pin = os.getenv("LIBRARY_PIN")
lib = Library("Aalborg", user, pin)
loans = await lib.get_loans()
assert loans != None
assert len(loans) > 0
assert isinstance(loans[0], Loan)


async def test_reservations():
user = os.getenv('LIBRARY_USER_ID')
pin = os.getenv('LIBRARY_PIN')
user = os.getenv("LIBRARY_USER_ID")
pin = os.getenv("LIBRARY_PIN")
lib = Library("Aalborg", user, pin)
reservations = await lib.get_reservations()
assert reservations != None
assert len(reservations) > 0
assert isinstance(reservations[0], Reservation)


async def test_profile():
user = os.getenv('LIBRARY_USER_ID')
pin = os.getenv('LIBRARY_PIN')
user = os.getenv("LIBRARY_USER_ID")
pin = os.getenv("LIBRARY_PIN")
lib = Library("Aalborg", user, pin)
profile = await lib.get_profile_info()
assert profile != None
assert isinstance(profile, ProfileInfo)
assert "gmail.com" in profile.email_address


async def test_ereolen_loans():
user = os.getenv('LIBRARY_USER_ID')
pin = os.getenv('LIBRARY_PIN')
user = os.getenv("LIBRARY_USER_ID")
pin = os.getenv("LIBRARY_PIN")
lib = Library("Aalborg", user, pin)
loans = await lib.get_ereolen_loans()
assert loans != None
assert len(loans) > 0
assert isinstance(loans[0], EreolenLoan)


async def test_ereolen_reservations():
user = os.getenv('LIBRARY_USER_ID')
pin = os.getenv('LIBRARY_PIN')
user = os.getenv("LIBRARY_USER_ID")
pin = os.getenv("LIBRARY_PIN")
lib = Library("Aalborg", user, pin)
reservations = await lib.get_ereolen_reservations()
assert reservations != None
Expand Down

0 comments on commit c0db833

Please sign in to comment.