Added a lot of unit tests

This commit is contained in:
Stanislas Jouffroy 2024-03-19 00:00:59 +01:00
parent 16d4a0724c
commit bcd8dc0733
5 changed files with 182 additions and 121 deletions

View file

@ -8,10 +8,29 @@ import pendulum
import pytest
from aiohttp import ClientSession
from connectors import GestionSportsConnector
from models import Booking, BookingFilter, User
from models import Booking, BookingFilter, Club, User
from pendulum import DateTime
from yarl import URL
from tests import utils
def retrieve_booking_datetime(
a_booking_filter: BookingFilter, a_club: Club
) -> DateTime:
"""
Utility to retrieve the booking datetime from the booking filter and the club
:param a_booking_filter: the booking filter that contains the date to book
:param a_club: the club which has the number of days before the date and the booking time
"""
booking_opening = a_club.booking_platform.booking_opening
opening_time = pendulum.parse(booking_opening.opening_time)
booking_hour = opening_time.hour
booking_minute = opening_time.minute
date_to_book = a_booking_filter.date
return date_to_book.subtract(days=booking_opening.days_before).at(
booking_hour, booking_minute
)
@patch.dict(
@ -216,7 +235,7 @@ def test_wait_until_booking_time(mock_now):
sport_name="Padel", date=pendulum.parse("2024-03-21T13:30:00Z")
)
booking_datetime = utils.retrieve_booking_datetime(booking_filter, club)
booking_datetime = retrieve_booking_datetime(booking_filter, club)
seconds = [
booking_datetime.subtract(seconds=3),