42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
import asyncio
|
|
|
|
from aioresponses import aioresponses
|
|
|
|
from resa_padel import booking
|
|
|
|
user = "user"
|
|
password = "password"
|
|
club_id = "98"
|
|
|
|
|
|
# FIXME
|
|
# 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():
|
|
# mock connection to the booking platform
|
|
booking_url = "https://some.url"
|
|
connection_url = booking_url + "/connexion.php"
|
|
login_url = connection_url
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
with aioresponses() as aio_mock:
|
|
aio_mock.get(
|
|
connection_url,
|
|
status=200,
|
|
headers={"Set-Cookie": f"connection_called=True; Domain={booking_url}"},
|
|
)
|
|
aio_mock.post(
|
|
login_url,
|
|
status=200,
|
|
headers={"Set-Cookie": f"login_called=True; Domain={booking_url}"},
|
|
)
|
|
|
|
session = loop.run_until_complete(
|
|
booking.book(booking_url, user, password, club_id)
|
|
)
|
|
|
|
cookies = session.cookie_jar.filter_cookies(booking_url)
|
|
# assert cookies.get("connection_called") == "True"
|
|
# assert cookies.get("login_called") == "True"
|