Skip to content

Commit

Permalink
format-python
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyanghosh30 committed Jun 12, 2024
1 parent 905af6c commit 09f3bca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
20 changes: 15 additions & 5 deletions webapp/shop/api/ua_contracts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ def _request(
error_rules=None,
headers={},
):
headers["Authorization"] = f"{self.token_type} {self.authentication_token}"
headers[
"Authorization"
] = f"{self.token_type} {self.authentication_token}"

if self.remote_addr:
headers["X-Forwarded-For"] = self.remote_addr
logger = logging.getLogger("talisker.requests")
logger.info("remote address", extra={"remote_addr": self.remote_addr})
logger.info(
"remote address", extra={"remote_addr": self.remote_addr}
)

response = self.session.request(
method=method,
Expand Down Expand Up @@ -163,7 +167,9 @@ def put_customer_info(
error_rules=["default"],
).json()

def put_anonymous_customer_info(self, account_id, name, address, tax_id) -> dict:
def put_anonymous_customer_info(
self, account_id, name, address, tax_id
) -> dict:
return self._request(
method="put",
path=f"v1/accounts/{account_id}/customer-info/stripe",
Expand Down Expand Up @@ -206,7 +212,9 @@ def accept_renewal(self, renewal_id) -> dict:

return {}

def get_product_listings(self, marketplace: str, filters: str = "") -> dict:
def get_product_listings(
self, marketplace: str, filters: str = ""
) -> dict:
return self._request(
method="get",
path=f"v1/marketplace/{marketplace}/product-listings{filters}",
Expand All @@ -226,7 +234,9 @@ def get_account_subscriptions(
error_rules=["default", "auth"],
).json()

def get_account_purchases(self, account_id: str, filters: str = "") -> dict:
def get_account_purchases(
self, account_id: str, filters: str = ""
) -> dict:
return self._request(
method="get",
path=f"v1/accounts/{account_id}/purchases{filters}",
Expand Down
5 changes: 2 additions & 3 deletions webapp/shop/cred/mock_logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ def get_mock_cue_annotated_contract_items(email):
if email == "[email protected]":
res._content = b'{"code": "unauthorized","message": "unauthorized","traceId": "4f741380-317d-409d-a2e2-ed3e89565f56"}'
res.status_code = 401

else:

else:
mock_exams = [
{
"accountContext": {
Expand Down Expand Up @@ -62,6 +61,6 @@ def get_mock_cue_annotated_contract_items(email):
]
res._content = json.dumps(mock_exams).encode("utf-8")
res.status_code = 200

res.raise_for_status()
return res.json()
5 changes: 1 addition & 4 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,7 @@ def cred_your_exams(ua_contracts_api, trueability_api, **kwargs):
# exam_contracts = ua_contracts_api.get_annotated_contract_items(
# email=email, product_tags=["cue"]
# )
exam_contracts = get_mock_cue_annotated_contract_items(
email=email
)
exam_contracts = get_mock_cue_annotated_contract_items(email=email)
except Exception as error:
print(error)
flask.current_app.extensions["sentry"].captureException(
Expand All @@ -422,7 +420,6 @@ def cred_your_exams(ua_contracts_api, trueability_api, **kwargs):
else:
exam_contracts = []


exams_in_progress = []
exams_scheduled = []
exams_not_taken = []
Expand Down

0 comments on commit 09f3bca

Please sign in to comment.