From 51b7117c6dac5fd9f8f9cbe9e9b699008a2a32f2 Mon Sep 17 00:00:00 2001 From: kilian Date: Sun, 19 Oct 2025 23:29:02 +0200 Subject: [PATCH] better demonstrator --- backend/src/payments/test.py | 10 ++++++---- backend/src/tests/test_payment.py | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/backend/src/payments/test.py b/backend/src/payments/test.py index e2ca9cc..d3f6bcf 100644 --- a/backend/src/payments/test.py +++ b/backend/src/payments/test.py @@ -30,7 +30,8 @@ validation_response = requests.post( ) # todo check status code + try except. Status code 201 ? -print(validation_response.text) +print(f'Reponse status code: {validation_response.status_code}') +print(f'Access token: {json.loads(validation_response.text)["access_token"]}') access_token = json.loads(validation_response.text)["access_token"] @@ -87,8 +88,9 @@ order_response = requests.post( for link_obj in order_response.json()['links']: if link_obj['rel'] == 'approve': forward_to_user_link = link_obj['href'] +print(f'Reponse status code: {order_response.status_code}') print(f'Follow this link to proceed to payment: {forward_to_user_link}') -# order_id = json.loads(order_response.text)["id"] +order_id = json.loads(order_response.text)["id"] #%% @@ -104,6 +106,6 @@ capture_response = requests.post( ) # todo check status code + try except -print(capture_response.json()) +print(f'Reponse status code: {capture_response.status_code}') +print(capture_response.text) # order_id = json.loads(response.text)["id"] - diff --git a/backend/src/tests/test_payment.py b/backend/src/tests/test_payment.py index 7a141fd..7fc7225 100644 --- a/backend/src/tests/test_payment.py +++ b/backend/src/tests/test_payment.py @@ -29,18 +29,25 @@ def test_nearby(client): # pylint: disable=redefined-outer-name response = client.post( url=f"/orders/new/", json={ - 'user_id': supabase.SUPABASE_TEST_USER_ID + 'user_id': supabase.SUPABASE_TEST_USER_ID, 'basket': { - - } - 'currency': - 'return_url_success': - 'return_url_failure': + { + 'id': '1873672819', + 'quantity': 1982 + }, + { + 'id': '9876789', + 'quantity': 1982 + } + }, + 'currency': 'CHF', + 'return_url_success': 'https://anydev.info', + 'return_url_failure': 'https://anydev.info' } ) suggestions = response.json() # checks : - assert response.status_code == status_code # check for successful planning + assert response.status_code == 200 # check for successful planning assert isinstance(suggestions, list) # check that the return type is a list assert len(suggestions) > 0