80 lines
2 KiB
Python
80 lines
2 KiB
Python
import json
|
|
|
|
import pendulum
|
|
import pytest
|
|
from aiohttp import ClientSession
|
|
|
|
from resa_padel.gestion_sports.gestion_sports_connector import \
|
|
GestionSportsConnector
|
|
from resa_padel.gestion_sports.gestion_sports_payload_builder import \
|
|
GestionSportsPayloadBuilder
|
|
from resa_padel.models import BookingFilter, User
|
|
|
|
user = User(login="padel.testing@jouf.fr", password="ridicule", club_id="123")
|
|
|
|
courts = [606, 607, 608]
|
|
sport_id = 217
|
|
booking_date = pendulum.now().add(days=6).set(hour=18, minute=0, second=0)
|
|
booking_filter = BookingFilter(court_ids=courts, sport_id=sport_id, date=booking_date)
|
|
|
|
booking_failure_response = json.dumps(
|
|
{
|
|
"status": "error",
|
|
"message": "Désolé mais vous avez 1 réservation en cours au Padel en heures pleines et le réglement"
|
|
" n'autorise qu'une réservation en heures pleines à la fois au Padel!",
|
|
}
|
|
)
|
|
|
|
booking_success_response = json.dumps(
|
|
{
|
|
"status": "ok",
|
|
"message": "Merci, votre réservation s'est bien effectuée, vous allez recevoir un email"
|
|
" avec le récapitulatif de votre réservation, pensez à le conserver.",
|
|
"id_resa": 3503741,
|
|
}
|
|
)
|
|
|
|
date_format = "%d/%m/%Y"
|
|
time_format = "%H:%M"
|
|
booking_payload = (
|
|
GestionSportsPayloadBuilder()
|
|
.date(booking_date.date().strftime(date_format))
|
|
.time(booking_date.time().strftime(time_format))
|
|
.sport_id(sport_id)
|
|
.court_id(courts[0])
|
|
.build_booking_payload()
|
|
)
|
|
|
|
session = ClientSession()
|
|
gestion_sports_url = "https://toulousepadelclub.gestion-sports.com"
|
|
gs_connector = GestionSportsConnector(session, gestion_sports_url)
|
|
|
|
|
|
@pytest.fixture
|
|
def a_user() -> User:
|
|
return user
|
|
|
|
|
|
@pytest.fixture
|
|
def a_booking_filter() -> BookingFilter:
|
|
return booking_filter
|
|
|
|
|
|
@pytest.fixture
|
|
def a_booking_success_response() -> str:
|
|
return booking_success_response
|
|
|
|
|
|
@pytest.fixture
|
|
def a_booking_failure_response() -> str:
|
|
return booking_failure_response
|
|
|
|
|
|
@pytest.fixture
|
|
def a_booking_payload() -> str:
|
|
return booking_payload
|
|
|
|
|
|
@pytest.fixture
|
|
def a_connector():
|
|
return gs_connector
|