From a622ee69de7a866cadcbca547e433476167ebc8d Mon Sep 17 00:00:00 2001 From: stanislas Date: Sat, 23 Mar 2024 11:58:07 +0100 Subject: [PATCH] Added a service that can get all current tournaments list --- tests/data/configuration/platforms.yaml | 7 ++++- tests/integration_tests/test_booking.py | 15 +++++++++ .../test_gestion_sport_connector.py | 4 +-- tests/unit_tests/responses.py | 31 +++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/tests/data/configuration/platforms.yaml b/tests/data/configuration/platforms.yaml index f3cdc8e..4d82911 100644 --- a/tests/data/configuration/platforms.yaml +++ b/tests/data/configuration/platforms.yaml @@ -16,4 +16,9 @@ platforms: payloadTemplate: gestion-sports/user-bookings-payload.txt - name: cancellation path: /cancel.html - payloadTemplate: gestion-sports/booking-cancellation-payload.txt + payloadTemplate: sports/booking-cancellation-payload.txt + - name: tournament-sessions + path: /membre/index.php + payloadTemplate: sports/tournament-sessions-payload.txt + - name: tournament-list + path: /membre/events/event.html?event= diff --git a/tests/integration_tests/test_booking.py b/tests/integration_tests/test_booking.py index 22e9613..db6c6e1 100644 --- a/tests/integration_tests/test_booking.py +++ b/tests/integration_tests/test_booking.py @@ -57,3 +57,18 @@ def test_main_booking(): ) def test_main_cancellation(): booking.main() + + +@patch.dict( + os.environ, + { + "CLUB_ID": "tpc", + "ACTION": "tournaments", + "LOGIN": "padel.testing@jouf.fr", + "PASSWORD": "ridicule", + }, + clear=True, +) +def test_main_tournaments(): + tournaments = booking.main() + assert len(tournaments) != 0 diff --git a/tests/integration_tests/test_gestion_sport_connector.py b/tests/integration_tests/test_gestion_sport_connector.py index 0489110..4e5bb44 100644 --- a/tests/integration_tests/test_gestion_sport_connector.py +++ b/tests/integration_tests/test_gestion_sport_connector.py @@ -191,10 +191,8 @@ async def test_cancel_booking_id(connector, user): async with ClientSession() as session: await connector.land(session) await connector.login(session, user) - ongoing_bookings = await connector.get_ongoing_bookings(session) - booking_id = ongoing_bookings[0].id - response = await connector.cancel_booking_id(session, 666) + await connector.cancel_booking_id(session, 666) assert len(await connector.get_ongoing_bookings(session)) == 0 diff --git a/tests/unit_tests/responses.py b/tests/unit_tests/responses.py index 35982f9..8ee5c7e 100644 --- a/tests/unit_tests/responses.py +++ b/tests/unit_tests/responses.py @@ -1,3 +1,6 @@ +from gestion_sport_connector import GestionSportsConnector + + def make_landing_request_success(aioresponses, connector, landing_response): aioresponses.get( connector.landing_url, @@ -54,6 +57,26 @@ def set_bookings_response(aioresponses, connector, user_bookings_post_response): ) +def set_tournaments_sessions_response( + aioresponses, connector: GestionSportsConnector, tournaments_sessions_response +): + aioresponses.post( + connector.tournaments_sessions_url, + status=200, + body=tournaments_sessions_response, + ) + + +def set_tournaments_list_response( + aioresponses, + connector: GestionSportsConnector, + tournament_id, + tournaments_list_response, +): + url = f"{connector.tournaments_list_url}{tournament_id}" + aioresponses.get(url, status=200, body=tournaments_list_response) + + def set_full_user_bookings_responses(aioresponses, connector, responses): make_landing_request_success(aioresponses, connector, responses[0]) make_login_request_success(aioresponses, connector, responses[1]) @@ -81,3 +104,11 @@ def set_full_cancellation_responses(aioresponses, connector, responses): set_bookings_response(aioresponses, connector, responses[3]) set_cancellation_response(aioresponses, connector, responses[4]) + + +def set_full_tournaments_requests(aioresponses, connector, responses, tournament_id): + make_landing_request_success(aioresponses, connector, responses[0]) + make_login_request_success(aioresponses, connector, responses[1]) + + set_tournaments_sessions_response(aioresponses, connector, responses[2]) + set_tournaments_list_response(aioresponses, connector, tournament_id, responses[3])