created a gestion sports services class that handles the connection while the connector is dedicated to the requests

This commit is contained in:
Stanislas Jouffroy 2024-03-20 23:11:43 +01:00
parent bcd8dc0733
commit e6023e0687
12 changed files with 513 additions and 593 deletions

View file

@ -0,0 +1,110 @@
import pytest
from gestion_sports_services import GestionSportsServices
from tests.unit_tests import responses
@pytest.mark.asyncio
async def test_booking_success(
aioresponses,
connector,
club,
user,
booking_filter,
booking_success_from_start,
):
responses.set_full_booking_requests_responses(
aioresponses, connector, booking_success_from_start
)
court_booked = await GestionSportsServices.book(club, user, booking_filter)
assert court_booked.id == 2
@pytest.mark.asyncio
async def test_booking_failure(
aioresponses,
gs_services,
connector,
club,
user,
booking_filter,
booking_failure_from_start,
):
responses.set_full_booking_requests_responses(
aioresponses, connector, booking_failure_from_start
)
court_booked = await gs_services.book(club, user, booking_filter)
assert court_booked is None
@pytest.mark.asyncio
async def test_user_has_available_booking_slots(
aioresponses,
gs_services,
connector,
user,
club,
user_has_ongoing_bookings_from_start,
):
responses.set_full_user_bookings_responses(
aioresponses, connector, user_has_ongoing_bookings_from_start
)
has_user_available_slots = await gs_services.has_user_available_slots(user, club)
assert has_user_available_slots
@pytest.mark.asyncio
async def test_user_has_no_available_booking_slots(
aioresponses,
gs_services,
connector,
user,
club,
user_has_no_ongoing_bookings_from_start,
):
responses.set_full_user_bookings_responses(
aioresponses, connector, user_has_no_ongoing_bookings_from_start
)
has_user_available_slots = await gs_services.has_user_available_slots(user, club)
assert not has_user_available_slots
@pytest.mark.asyncio
async def test_cancel_booking(
aioresponses,
gs_services,
connector,
user,
club,
booking_filter,
cancellation_success_from_start,
):
responses.set_full_cancellation_responses(
aioresponses, connector, cancellation_success_from_start
)
await gs_services.cancel_booking(user, club, booking_filter)
@pytest.mark.asyncio
async def test_cancel_booking_id(
aioresponses,
gs_services,
connector,
user,
club,
cancellation_success_from_start,
):
responses.set_full_cancellation_responses(
aioresponses, connector, cancellation_success_from_start
)
await gs_services.cancel_booking_id(user, club, 65464)