Added a lot of unit tests
This commit is contained in:
parent
16d4a0724c
commit
bcd8dc0733
5 changed files with 182 additions and 121 deletions
|
@ -20,99 +20,167 @@ TEST_FOLDER = Path(__file__).parent.parent
|
|||
DATA_FOLDER = TEST_FOLDER / "data"
|
||||
RESPONSES_FOLDER = DATA_FOLDER / "responses"
|
||||
|
||||
court11 = Court(id="1", name="Court 1", number=1, isIndoor=True)
|
||||
court12 = Court(id="2", name="Court 2", number=2, isIndoor=False)
|
||||
court13 = Court(id="3", name="Court 3", number=3, isIndoor=True)
|
||||
court14 = Court(id="4", name="Court 4", number=4, isIndoor=True)
|
||||
|
||||
sport1 = Sport(
|
||||
name="Sport1",
|
||||
id=8,
|
||||
duration=99,
|
||||
price=54,
|
||||
players=3,
|
||||
courts=[court11, court12, court13, court14],
|
||||
)
|
||||
|
||||
court21 = Court(id="1", name="Court 1", number=1, isIndoor=False)
|
||||
court22 = Court(id="2", name="Court 2", number=2, isIndoor=True)
|
||||
court23 = Court(id="3", name="Court 3", number=3, isIndoor=True)
|
||||
court24 = Court(id="4", name="Court 4", number=4, isIndoor=True)
|
||||
|
||||
sport2 = Sport(
|
||||
name="Sport 2",
|
||||
id=10,
|
||||
duration=44,
|
||||
price=23,
|
||||
players=1,
|
||||
courts=[court21, court22, court23, court24],
|
||||
)
|
||||
|
||||
landing_url = Url(
|
||||
name="landing-page",
|
||||
path="landing.html",
|
||||
)
|
||||
|
||||
login_url = Url(
|
||||
name="login",
|
||||
path="login.html",
|
||||
payloadTemplate="gestion-sports/login-payload.txt",
|
||||
)
|
||||
|
||||
booking_url = Url(
|
||||
name="booking",
|
||||
path="booking.html",
|
||||
payloadTemplate="gestion-sports/booking-payload.txt",
|
||||
)
|
||||
|
||||
user_bookings_url = Url(
|
||||
name="user-bookings",
|
||||
path="user_bookings.html",
|
||||
payloadTemplate="gestion-sports/user-bookings-payload.txt",
|
||||
)
|
||||
|
||||
cancellation_url = Url(
|
||||
name="cancellation",
|
||||
path="cancel.html",
|
||||
payloadTemplate="gestion-sports/booking-cancellation-payload.txt",
|
||||
)
|
||||
|
||||
booking_opening = BookingOpening(daysBefore=10, time="03:27")
|
||||
|
||||
total_bookings = TotalBookings(peakHours=3, offPeakHours="unlimited")
|
||||
|
||||
booking_platform = BookingPlatform(
|
||||
id="gestion-sports",
|
||||
clubId=21,
|
||||
url="https://ptf1.com",
|
||||
hoursBeforeCancellation=7,
|
||||
bookingOpening=booking_opening,
|
||||
totalBookings=total_bookings,
|
||||
sports=[sport1, sport2],
|
||||
urls={
|
||||
"landing-page": landing_url,
|
||||
"login": login_url,
|
||||
"booking": booking_url,
|
||||
"user-bookings": user_bookings_url,
|
||||
"cancellation": cancellation_url,
|
||||
},
|
||||
)
|
||||
|
||||
club = Club(
|
||||
id="super_club",
|
||||
name="Super Club",
|
||||
url="https://superclub.com",
|
||||
bookingPlatform=booking_platform,
|
||||
)
|
||||
@pytest.fixture
|
||||
def court11() -> Court:
|
||||
return Court(id="1", name="Court 1", number=1, isIndoor=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def a_club() -> Club:
|
||||
return club
|
||||
def court12() -> Court:
|
||||
return Court(id="2", name="Court 2", number=2, isIndoor=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def connector() -> GestionSportsConnector:
|
||||
def court13() -> Court:
|
||||
return Court(id="3", name="Court 3", number=3, isIndoor=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def court14() -> Court:
|
||||
return Court(id="4", name="Court 4", number=4, isIndoor=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sport1(court11, court12, court13, court14) -> Sport:
|
||||
return Sport(
|
||||
name="Sport1",
|
||||
id=8,
|
||||
duration=99,
|
||||
price=54,
|
||||
players=3,
|
||||
courts=[court11, court12, court13, court14],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def court21() -> Court:
|
||||
return Court(id="1", name="Court 1", number=1, isIndoor=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def court22() -> Court:
|
||||
return Court(id="2", name="Court 2", number=2, isIndoor=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def court23() -> Court:
|
||||
return Court(id="3", name="Court 3", number=3, isIndoor=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def court24() -> Court:
|
||||
return Court(id="4", name="Court 4", number=4, isIndoor=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sport2(court21, court22, court23, court24) -> Sport:
|
||||
return Sport(
|
||||
name="Sport 2",
|
||||
id=10,
|
||||
duration=44,
|
||||
price=23,
|
||||
players=1,
|
||||
courts=[court21, court22, court23, court24],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def landing_url() -> Url:
|
||||
return Url(
|
||||
name="landing-page",
|
||||
path="landing.html",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def login_url() -> Url:
|
||||
return Url(
|
||||
name="login",
|
||||
path="login.html",
|
||||
payloadTemplate="gestion-sports/login-payload.txt",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def booking_url() -> Url:
|
||||
return Url(
|
||||
name="booking",
|
||||
path="booking.html",
|
||||
payloadTemplate="gestion-sports/booking-payload.txt",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_bookings_url() -> Url:
|
||||
return Url(
|
||||
name="user-bookings",
|
||||
path="user_bookings.html",
|
||||
payloadTemplate="gestion-sports/user-bookings-payload.txt",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cancellation_url() -> Url:
|
||||
return Url(
|
||||
name="cancellation",
|
||||
path="cancel.html",
|
||||
payloadTemplate="gestion-sports/booking-cancellation-payload.txt",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def booking_opening() -> BookingOpening:
|
||||
return BookingOpening(daysBefore=10, time="03:27")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def total_bookings() -> TotalBookings:
|
||||
return TotalBookings(peakHours=3, offPeakHours="unlimited")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def booking_platform(
|
||||
booking_opening,
|
||||
total_bookings,
|
||||
sport1,
|
||||
sport2,
|
||||
landing_url,
|
||||
login_url,
|
||||
booking_url,
|
||||
user_bookings_url,
|
||||
cancellation_url,
|
||||
) -> BookingPlatform:
|
||||
return BookingPlatform(
|
||||
id="gestion-sports",
|
||||
clubId=21,
|
||||
url="https://ptf1.com",
|
||||
hoursBeforeCancellation=7,
|
||||
bookingOpening=booking_opening,
|
||||
totalBookings=total_bookings,
|
||||
sports=[sport1, sport2],
|
||||
urls={
|
||||
"landing-page": landing_url,
|
||||
"login": login_url,
|
||||
"booking": booking_url,
|
||||
"user-bookings": user_bookings_url,
|
||||
"cancellation": cancellation_url,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def club(booking_platform) -> Club:
|
||||
return Club(
|
||||
id="super_club",
|
||||
name="Super Club",
|
||||
url="https://superclub.com",
|
||||
bookingPlatform=booking_platform,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def connector(club) -> GestionSportsConnector:
|
||||
return GestionSportsConnector(club)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue