Added a lot of unit tests
This commit is contained in:
parent
0938fb98b7
commit
16d4a0724c
32 changed files with 4268 additions and 497 deletions
70
tests/integration_tests/test_booking.py
Normal file
70
tests/integration_tests/test_booking.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
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()
|
Loading…
Add table
Add a link
Reference in a new issue