Big refactoring.

- clubs, booking platforms and user are now defined in customization files -> there are less environment variables
- the responsibility of the session moved
- booking cancellation is available
This commit is contained in:
Stanislas Jouffroy 2024-03-17 23:57:50 +01:00 committed by stanislas
parent dbda5a158e
commit 0938fb98b7
27 changed files with 3050 additions and 696 deletions

View file

@ -2,40 +2,20 @@ import os
from unittest.mock import patch
import config
from pendulum import DateTime, Time, Timezone
from pendulum import DateTime, Timezone
@patch.dict(
os.environ,
{
"CLUB_URL": "club.url",
"COURT_IDS": "7,8,10",
"CLUB_ID": "666",
"BOOKING_OPEN_DAYS_BEFORE": "5",
"BOOKING_OPENING_TIME": "18:37",
},
clear=True,
)
def test_get_club():
club = config.get_club()
assert club.url == "club.url"
assert club.courts_ids == [7, 8, 10]
assert club.id == "666"
assert club.booking_open_days_before == 5
assert club.booking_opening_time == Time(hour=18, minute=37)
@patch.dict(
os.environ,
{
"SPORT_ID": "666",
"SPORT_NAME": "Padel",
"DATE_TIME": "2024-02-03T22:38:45Z",
},
clear=True,
)
def test_get_booking_filter():
booking_filter = config.get_booking_filter()
assert booking_filter.sport_id == 666
assert booking_filter.sport_id == "padel"
assert booking_filter.date == DateTime(
year=2024,
month=2,
@ -61,14 +41,11 @@ def test_get_available_user():
assert user.password == "gloups"
@patch.dict(
os.environ,
{"AVAILABLE_USERS_CREDENTIALS": "login@user.tld:gloups,other@user.tld:patatras"},
clear=True,
)
def test_user():
users = config.get_available_users()
assert users[0].login == "login@user.tld"
assert users[0].password == "gloups"
assert users[1].login == "other@user.tld"
assert users[1].password == "patatras"
def test_read_clubs():
clubs = config.get_clubs()
assert len(clubs) == 2
def test_get_users():
users = config.get_users("tpc")
assert len(users) == 2