Skip to content

Commit

Permalink
fix all tox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed May 1, 2024
1 parent a2c80dc commit 1942abf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/edutap/wallet_google/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def create(
elif response.status_code != 200:
raise Exception(f"Error at {url}: {response.status_code} - {response.text}")

logger.debug(f"RAW-Response: {response.content}")
logger.debug(f"RAW-Response: {response.content!r}")
return model.model_validate_json(response.content)


Expand All @@ -126,7 +126,7 @@ def read(

if response.status_code == 200:
model = lookup_model(name)
logger.debug(f"RAW-Response: {response.content}")
logger.debug(f"RAW-Response: {response.content!r}")
# print(f"RAW-Response: {response.content}")
return model.model_validate_json(response.content)

Expand Down Expand Up @@ -185,7 +185,6 @@ def update(
data=verified_json.encode("utf-8"),
)
logger.debug(verified_json.encode("utf-8"))
# print(verified_json.encode("utf-8"))
if response.status_code == 404:
raise LookupError(
f"Error 404, {name} {getattr(data, 'id', 'No ID')} not found: - {response.text}"
Expand All @@ -194,7 +193,7 @@ def update(
if response.status_code != 200:
raise Exception(f"Error: {response.status_code} - {response.text}")

logger.debug(f"RAW-Response: {response.content}")
logger.debug(f"RAW-Response: {response.content!r}")
return model.model_validate_json(response.content)


Expand Down Expand Up @@ -259,7 +258,7 @@ def message(

if response.status_code != 200:
raise Exception(f"Error: {response.status_code} - {response.text}")
logger.debug(f"RAW-Response: {response.content}")
logger.debug(f"RAW-Response: {response.content!r}")
response_data = json.loads(response.content)
return model.model_validate(response_data.get("resource"))

Expand Down Expand Up @@ -426,9 +425,10 @@ def save_link(
}
signer = crypt.RSASigner.from_service_account_file(session_manager.credentials_file)
jwt_string = jwt.encode(signer, claims).decode("utf-8")
logger.warning(
"JWT-Length: %d, is larger than recommended 1800 bytes: %s",
len(jwt_string),
len(jwt_string) >= 1800,
)
if len(jwt_string) >= 1800:
logger.debug(
"JWT-Length: %d, is larger than recommended 1800 bytes: %s",
len(jwt_string),
len(jwt_string) >= 1800,
)
return f"{session_manager.save_url}/{jwt_string}"
4 changes: 2 additions & 2 deletions src/edutap/wallet_google/modelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pydantic import Field


class GoogleWalletClassModel(GoogleWalletWithIdModel):
class GoogleWalletClassModel(GoogleWalletModel, GoogleWalletWithIdModel):
"""
BaseModel for all Google Wallet Class Models.
"""
Expand Down Expand Up @@ -72,7 +72,7 @@ class GoogleWalletClassModel(GoogleWalletWithIdModel):
)


class GoogleWalletObjectModel(GoogleWalletWithIdModel):
class GoogleWalletObjectModel(GoogleWalletModel, GoogleWalletWithIdModel):
"""
Base model for all Google Wallet Object models.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/edutap/wallet_google/models/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
can_list=False,
can_message=False,
)
class SmartTap(GoogleWalletWithIdModel):
class SmartTap(GoogleWalletModel, GoogleWalletWithIdModel):
"""
see: https://developers.google.com/wallet/generic/rest/v1/smarttap#resource:-smarttap
"""
Expand Down
7 changes: 6 additions & 1 deletion src/edutap/wallet_google/registry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .modelbase import GoogleWalletClassModel
from .modelbase import GoogleWalletObjectModel
from .modelcore import GoogleWalletModel
from typing import TypedDict

Expand Down Expand Up @@ -72,7 +74,10 @@ def __init__(
"can_message": can_message,
}

def __call__(self, cls: type[GoogleWalletModel]) -> type[GoogleWalletModel]:
def __call__(
self,
cls: type[GoogleWalletModel | GoogleWalletClassModel | GoogleWalletObjectModel],
) -> type[GoogleWalletModel | GoogleWalletClassModel | GoogleWalletObjectModel]:
"""
Registers the given class in the registry.
"""
Expand Down

0 comments on commit 1942abf

Please sign in to comment.