ABle to send the booking request to several courts at the same time
This commit is contained in:
parent
fcc08f03f1
commit
51af600d28
11 changed files with 288 additions and 99 deletions
|
@ -1,10 +1,14 @@
|
|||
import asyncio
|
||||
|
||||
import pendulum
|
||||
from aioresponses import aioresponses
|
||||
|
||||
from resa_padel import booking
|
||||
from resa_padel.models import BookingFilter, User
|
||||
from tests.fixtures import (a_booking_failure_response,
|
||||
a_booking_success_response)
|
||||
|
||||
user = "user"
|
||||
login = "user"
|
||||
password = "password"
|
||||
club_id = "98"
|
||||
court_id = "11"
|
||||
|
@ -14,11 +18,14 @@ court_id = "11"
|
|||
# check that called are passed to the given urls
|
||||
# check made with cookies, but at the current time, cookies from the response are
|
||||
# not set in the session. Why ? I don't know....
|
||||
def test_booking_does_the_rights_calls():
|
||||
def test_booking_does_the_rights_calls(
|
||||
a_booking_success_response, a_booking_failure_response
|
||||
):
|
||||
# mock connection to the booking platform
|
||||
booking_url = "https://some.url"
|
||||
connection_url = booking_url + "/connexion.php"
|
||||
platform_url = "https://some.url"
|
||||
connection_url = platform_url + "/connexion.php"
|
||||
login_url = connection_url
|
||||
booking_url = platform_url + "/membre/reservation.html"
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
|
@ -26,19 +33,34 @@ def test_booking_does_the_rights_calls():
|
|||
aio_mock.get(
|
||||
connection_url,
|
||||
status=200,
|
||||
headers={"Set-Cookie": f"connection_called=True; Domain={booking_url}"},
|
||||
headers={"Set-Cookie": f"connection_called=True; Domain={platform_url}"},
|
||||
)
|
||||
aio_mock.post(
|
||||
login_url,
|
||||
status=200,
|
||||
headers={"Set-Cookie": f"login_called=True; Domain={booking_url}"},
|
||||
headers={"Set-Cookie": f"login_called=True; Domain={platform_url}"},
|
||||
)
|
||||
aio_mock.post(
|
||||
booking_url,
|
||||
status=200,
|
||||
headers={"Set-Cookie": f"booking_called=True; Domain={platform_url}"},
|
||||
body=a_booking_failure_response,
|
||||
)
|
||||
aio_mock.post(
|
||||
booking_url,
|
||||
status=200,
|
||||
headers={"Set-Cookie": f"booking_called=True; Domain={platform_url}"},
|
||||
body=a_booking_success_response,
|
||||
)
|
||||
|
||||
session = loop.run_until_complete(
|
||||
booking.book(booking_url, user, password, club_id, court_id)
|
||||
user = User(login=login, password=password, club_id=club_id)
|
||||
booking_filter = BookingFilter(
|
||||
court_ids=[607, 606], sport_id=444, date=pendulum.now().add(days=6)
|
||||
)
|
||||
|
||||
cookies = session.cookie_jar.filter_cookies(booking_url)
|
||||
loop.run_until_complete(booking.book(platform_url, user, booking_filter))
|
||||
|
||||
# cookies = session.cookie_jar.filter_cookies(platform_url)
|
||||
# assert cookies.get("connection_called") == "True"
|
||||
# assert cookies.get("login_called") == "True"
|
||||
# assert cookies.get("booking_called") == "True"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue