Skip to content

Commit

Permalink
fix linting problems
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Sep 27, 2023
1 parent 8414bd1 commit e30f25d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/edutap/wallet_google/models/tickets_and_transit.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ class EventReservationInfo(BaseModel):
confirmationCode: str | None = None


@register_model("EventTicketObject", url_part="eventTicketObject", plural="eventTicketObjects")
@register_model(
"EventTicketObject", url_part="eventTicketObject", plural="eventTicketObjects"
)
class EventTicketObject(GoogleWalletObjectModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketobject
Expand Down
1 change: 0 additions & 1 deletion src/edutap/wallet_google/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class HTTPRecorder(HTTPAdapter):

def send(self, request, *args, **kwargs):
req_record = {
"method": request.method,
Expand Down
10 changes: 7 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import json
import pytest

DATA_PATH = Path(__file__).parent / "data"

DATA_PATH = Path(__file__).parent / "data"


@pytest.fixture
Expand Down Expand Up @@ -39,17 +39,21 @@ def mock_session(self):

_THREADLOCAL.session = None


@pytest.fixture
def mock_request_response(mock_session):
"""Fixture to load a mock request response from a json file.
Prepares a mock response and status code for a given url and method.
"""

def _load_mock_request_response(name: str, url: str, method: str, code=200):
data = {}
for postfix in {"REQUEST", "RESPONSE"}:
with open(DATA_PATH / f"{name}.REQUEST.json", "r") as f:
with open(DATA_PATH / f"{name}.REQUEST.json") as f:
data[postfix.lower()] = json.load(f)
mock_session.register_uri(method, url, json=data["response"]["body"], status_code=code)
mock_session.register_uri(
method, url, json=data["response"]["body"], status_code=code
)
return data["request"]

yield _load_mock_request_response
6 changes: 4 additions & 2 deletions tests/test_api_create.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
def test_api_create(mock_request_response):
from edutap.wallet_google.api import create
from edutap.wallet_google.models.primitives.enums import State
from edutap.wallet_google.registry import lookup_model
from edutap.wallet_google.session import session_manager
from edutap.wallet_google.models.primitives.enums import State

request_data = mock_request_response("CreateGenericObject", session_manager.url("GenericObject"), "POST")
request_data = mock_request_response(
"CreateGenericObject", session_manager.url("GenericObject"), "POST"
)
result = create("GenericObject", request_data["body"])

GenericObject = lookup_model("GenericObject")
Expand Down

0 comments on commit e30f25d

Please sign in to comment.