70 lines
1.5 KiB
Python
70 lines
1.5 KiB
Python
import asyncio
|
|
import os
|
|
from unittest.mock import patch
|
|
|
|
import config
|
|
import pendulum
|
|
from models import BookingFilter, User
|
|
|
|
from resa_padel import booking
|
|
|
|
|
|
@patch.dict(
|
|
os.environ,
|
|
{"CLUB_ID": "tpc"},
|
|
clear=True,
|
|
)
|
|
def test_booking():
|
|
club = config.get_club()
|
|
user = User(login="padel.testing@jouf.fr", password="ridicule")
|
|
booking_filter = BookingFilter(
|
|
sport_name="Padel", date=pendulum.parse("2024-03-21T13:30:00+01:00")
|
|
)
|
|
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 = config.get_club()
|
|
user = User(login="padel.testing@jouf.fr", password="ridicule")
|
|
asyncio.run(booking.cancel_booking_id(club, user, 3605033))
|
|
|
|
|
|
@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, user = booking.main()
|
|
assert court is not None
|
|
assert user.username == "padel.testing@jouf"
|
|
|
|
|
|
@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()
|