resa-padel/tests/integration_tests/test_booking.py

59 lines
1.2 KiB
Python

import asyncio
import os
from unittest.mock import patch
from resa_padel import booking
@patch.dict(
os.environ,
{"CLUB_ID": "tpc"},
clear=True,
)
def test_booking(club, user, booking_filter):
booked_court, user_that_booked = asyncio.run(
booking.book_court(club, [user], booking_filter)
)
assert booked_court is not None
assert user_that_booked == user
@patch.dict(
os.environ,
{"CLUB_ID": "tpc"},
clear=True,
)
def test_cancellation(club, user, booking_filter):
asyncio.run(booking.cancel_booking(club, user, booking_filter))
@patch.dict(
os.environ,
{
"CLUB_ID": "tpc",
"ACTION": "book",
"SPORT_NAME": "Padel",
"DATE_TIME": "2024-03-21T13:30:00+01:00",
},
clear=True,
)
def test_main_booking():
court, player = booking.main()
assert court is not None
assert player.login == "padel.testing@jouf.fr"
@patch.dict(
os.environ,
{
"CLUB_ID": "tpc",
"ACTION": "cancel",
"SPORT_NAME": "Padel",
"DATE_TIME": "2024-03-21T13:30:00+01:00",
"LOGIN": "padel.testing@jouf.fr",
"PASSWORD": "ridicule",
},
clear=True,
)
def test_main_cancellation():
booking.main()