110 lines
2.4 KiB
Python
110 lines
2.4 KiB
Python
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)
|