Choose a user with booking availability among many
This commit is contained in:
parent
a8322d6be0
commit
559c3b6d69
18 changed files with 1810 additions and 147 deletions
|
@ -13,7 +13,25 @@ from tests.fixtures import (
|
|||
)
|
||||
|
||||
tpc_url = "https://toulousepadelclub.gestion-sports.com"
|
||||
o = "https://toulousepadelclub.gestion-sports.fr"
|
||||
TPC_COURTS = [
|
||||
None,
|
||||
596,
|
||||
597,
|
||||
598,
|
||||
599,
|
||||
600,
|
||||
601,
|
||||
602,
|
||||
603,
|
||||
604,
|
||||
605,
|
||||
606,
|
||||
607,
|
||||
608,
|
||||
609,
|
||||
610,
|
||||
611,
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -82,27 +100,7 @@ async def test_booking_url_should_be_reachable(
|
|||
|
||||
court_booked = await gs_connector.book(a_booking_filter, a_club)
|
||||
# At 18:00 no chance to get a booking, any day of the week
|
||||
assert court_booked in [
|
||||
None,
|
||||
597,
|
||||
598,
|
||||
599,
|
||||
600,
|
||||
601,
|
||||
602,
|
||||
603,
|
||||
604,
|
||||
605,
|
||||
606,
|
||||
607,
|
||||
608,
|
||||
609,
|
||||
610,
|
||||
611,
|
||||
612,
|
||||
613,
|
||||
614,
|
||||
]
|
||||
assert court_booked in TPC_COURTS
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -147,7 +145,9 @@ def test_response_status_should_be_ok(a_booking_success_response: str) -> None:
|
|||
|
||||
:param a_booking_success_response: the success response mock
|
||||
"""
|
||||
is_booked = GestionSportsConnector.is_response_status_ok(a_booking_success_response)
|
||||
is_booked = GestionSportsConnector.is_booking_response_status_ok(
|
||||
a_booking_success_response
|
||||
)
|
||||
assert is_booked
|
||||
|
||||
|
||||
|
@ -158,5 +158,26 @@ def test_response_status_should_be_not_ok(a_booking_failure_response: str) -> No
|
|||
|
||||
:param a_booking_failure_response: the failure response mock
|
||||
"""
|
||||
is_booked = GestionSportsConnector.is_response_status_ok(a_booking_failure_response)
|
||||
is_booked = GestionSportsConnector.is_booking_response_status_ok(
|
||||
a_booking_failure_response
|
||||
)
|
||||
assert not is_booked
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_user_ongoing_bookings(a_user: User, a_club: Club) -> None:
|
||||
"""
|
||||
Test that the user has 2 ongoing bookings
|
||||
|
||||
:param a_user:
|
||||
:param a_club:
|
||||
:return:
|
||||
"""
|
||||
async with ClientSession() as session:
|
||||
gs_connector = GestionSportsConnector(session, tpc_url)
|
||||
await gs_connector.land()
|
||||
await gs_connector.login(a_user, a_club)
|
||||
|
||||
bookings = await gs_connector.get_ongoing_bookings()
|
||||
|
||||
assert len(bookings) == 0
|
||||
|
|
8
tests/gestion_sports/test_gestion_sports_html_parser.py
Normal file
8
tests/gestion_sports/test_gestion_sports_html_parser.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from gestion_sports import gestion_sports_html_parser as parser
|
||||
|
||||
from tests.fixtures import mes_resas_html
|
||||
|
||||
|
||||
def test_html_parser(mes_resas_html):
|
||||
hash_value = parser.get_hash_input(mes_resas_html)
|
||||
assert hash_value == "ef4403f4c44fa91060a92476aae011a2184323ec"
|
|
@ -1,6 +1,7 @@
|
|||
from resa_padel.gestion_sports.payload_builders import (
|
||||
GestionSportsBookingPayloadBuilder,
|
||||
GestionSportsLoginPayloadBuilder,
|
||||
GestionSportsUsersBookingsPayloadBuilder,
|
||||
)
|
||||
from tests.fixtures import a_booking_filter, a_club, a_user
|
||||
|
||||
|
@ -48,3 +49,13 @@ def test_booking_payload_should_be_built(a_booking_filter):
|
|||
)
|
||||
|
||||
assert booking_payload == expected_payload
|
||||
|
||||
|
||||
def test_users_bookings_payload_should_be_built():
|
||||
builder = GestionSportsUsersBookingsPayloadBuilder()
|
||||
builder.hash("super_hash")
|
||||
expected_payload = "ajax=loadResa&hash=super_hash"
|
||||
|
||||
actual_payload = builder.build()
|
||||
|
||||
assert actual_payload == expected_payload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue