From 7c4e1ff36bf7ad1e26eb2965229ad15d9a11af13 Mon Sep 17 00:00:00 2001 From: Jonas Linter <{email_address}> Date: Tue, 25 Nov 2025 21:04:18 +0100 Subject: [PATCH] Updated test_api. Had to change hotel_ids used in test_requests. Previously any hotel_id was valid now only registered ones are. Doesn't make a difference in prod --- tests/test_api.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 6adb3df..c0d0309 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -417,7 +417,7 @@ class TestGenericWebhookEndpoint: """Test successful generic webhook submission with real form data.""" unique_id = uuid.uuid4().hex[:8] test_data = { - "hotel_data": {"hotelname": "Bemelmans", "hotelcode": "39054_001"}, + "hotel_data": {"hotelname": "Bemelmans", "hotelcode": "HOTEL123"}, "form_data": { "sprache": "it", "anreise": "14.10.2025", @@ -451,14 +451,14 @@ class TestGenericWebhookEndpoint: assert "timestamp" in data assert ( data["message"] - == "Generic webhook data received and processed successfully" + == "Generic webhook data processed successfully" ) def test_generic_webhook_creates_customer_and_reservation(self, client): """Test that webhook creates customer and reservation in database.""" unique_id = uuid.uuid4().hex[:8] test_data = { - "hotel_data": {"hotelname": "Test Hotel", "hotelcode": "TEST123"}, + "hotel_data": {"hotelname": "Test Hotel", "hotelcode": "HOTEL123"}, "form_data": { "sprache": "de", "anreise": "25.12.2025", @@ -517,7 +517,7 @@ class TestGenericWebhookEndpoint: (r for r in reservations if r.customer_id == customer.id), None ) assert reservation is not None, "Reservation should be created" - assert reservation.hotel_code == "TEST123" + assert reservation.hotel_code == "HOTEL123" assert reservation.hotel_name == "Test Hotel" assert reservation.num_adults == 2 assert reservation.num_children == 1 @@ -537,7 +537,7 @@ class TestGenericWebhookEndpoint: def test_generic_webhook_missing_dates(self, client): """Test webhook with missing required dates.""" test_data = { - "hotel_data": {"hotelname": "Test", "hotelcode": "123"}, + "hotel_data": {"hotelname": "Test", "hotelcode": "HOTEL123"}, "form_data": { "sprache": "de", "name": "John", @@ -555,7 +555,7 @@ class TestGenericWebhookEndpoint: def test_generic_webhook_invalid_date_format(self, client): """Test webhook with invalid date format.""" test_data = { - "hotel_data": {"hotelname": "Test", "hotelcode": "123"}, + "hotel_data": {"hotelname": "Test", "hotelcode": "HOTEL123"}, "form_data": { "sprache": "en", "anreise": "2025-10-14", # Wrong format, should be DD.MM.YYYY @@ -577,7 +577,7 @@ class TestGenericWebhookEndpoint: """Test webhook properly handles children ages.""" unique_id = uuid.uuid4().hex[:8] test_data = { - "hotel_data": {"hotelname": "Family Hotel", "hotelcode": "FAM001"}, + "hotel_data": {"hotelname": "Family Hotel", "hotelcode": "HOTEL123"}, "form_data": { "sprache": "it", "anreise": "01.08.2025", @@ -608,9 +608,9 @@ class TestGenericWebhookEndpoint: result = await session.execute(select(Reservation)) reservations = result.scalars().all() reservation = next( - (r for r in reservations if r.hotel_code == "FAM001"), None + (r for r in reservations if r.hotel_code == "HOTEL123"), None ) - assert reservation is not None + assert reservation is not None, "Reservation should be created" assert reservation.num_children == 3 # children_ages is stored as CSV string children_ages = [ @@ -631,9 +631,9 @@ class TestGenericWebhookEndpoint: ), None, ) - assert customer is not None - assert customer.phone is None # Empty phone should be None - assert customer.name_prefix is None # -- should be filtered out + assert customer is not None, "Customer should be created" + assert customer.phone is None, "Empty phone should be None" + assert customer.name_prefix is None, "Name prefix '--' should be filtered out" import asyncio @@ -914,7 +914,7 @@ class TestErrorHandling: headers={"Content-Type": "application/json"}, ) - assert response.status_code == 422 + assert response.status_code == 400 def test_wix_webhook_missing_required_fields(self, client): """Test webhook with missing required fields."""