From e30f25dec0dcab709c4ee799e3029ba8d6d661c7 Mon Sep 17 00:00:00 2001 From: Alexander Loechel Date: Thu, 28 Sep 2023 00:40:09 +0200 Subject: [PATCH] fix linting problems --- src/edutap/wallet_google/models/tickets_and_transit.py | 4 +++- src/edutap/wallet_google/session.py | 1 - tests/conftest.py | 10 +++++++--- tests/test_api_create.py | 6 ++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/edutap/wallet_google/models/tickets_and_transit.py b/src/edutap/wallet_google/models/tickets_and_transit.py index ebd0867..e280ff1 100644 --- a/src/edutap/wallet_google/models/tickets_and_transit.py +++ b/src/edutap/wallet_google/models/tickets_and_transit.py @@ -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 diff --git a/src/edutap/wallet_google/session.py b/src/edutap/wallet_google/session.py index 1f90808..c4cc603 100644 --- a/src/edutap/wallet_google/session.py +++ b/src/edutap/wallet_google/session.py @@ -19,7 +19,6 @@ class HTTPRecorder(HTTPAdapter): - def send(self, request, *args, **kwargs): req_record = { "method": request.method, diff --git a/tests/conftest.py b/tests/conftest.py index f30c1af..34740dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,8 +4,8 @@ import json import pytest -DATA_PATH = Path(__file__).parent / "data" +DATA_PATH = Path(__file__).parent / "data" @pytest.fixture @@ -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 diff --git a/tests/test_api_create.py b/tests/test_api_create.py index c081ac1..4685b44 100644 --- a/tests/test_api_create.py +++ b/tests/test_api_create.py @@ -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")