From 9094f3e3b7e4af0e032c785516116828770ab708 Mon Sep 17 00:00:00 2001 From: Jonas Linter <{email_address}> Date: Tue, 7 Oct 2025 17:25:27 +0200 Subject: [PATCH] More tests. Hard to say how useful they are though. Need further work --- tests/test_alpine_bits_server_read.py | 46 +++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/tests/test_alpine_bits_server_read.py b/tests/test_alpine_bits_server_read.py index 54fa608..1cd1157 100644 --- a/tests/test_alpine_bits_server_read.py +++ b/tests/test_alpine_bits_server_read.py @@ -8,9 +8,8 @@ from datetime import UTC, date, datetime import pytest from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine -from xsdata.formats.dataclass.parsers import XmlParser -from xsdata.formats.dataclass.serializers import XmlSerializer from xsdata.formats.dataclass.serializers.config import SerializerConfig +from xsdata_pydantic.bindings import XmlParser, XmlSerializer from alpine_bits_python.alpine_bits_helpers import create_res_retrieve_response from alpine_bits_python.alpinebits_server import AlpineBitsClientInfo @@ -216,9 +215,16 @@ class TestCreateResRetrieveResponse: "Response should have reservations_list attribute" ) - assert hasattr(response.reservations_list, "reservation"), ( + assert hasattr(response.reservations_list, "hotel_reservation"), ( "reservations_list should have reservation attribute" ) + + assert len(response.reservations_list.hotel_reservation) == 1 + res: OtaResRetrieveRs.ReservationsList.HotelReservation = ( + response.reservations_list.hotel_reservation[0] + ) + + assert res.unique_id is not None, "Reservation should have unique_id" # Verify the response can be serialized to XML config = SerializerConfig( pretty_print=True, xml_declaration=True, encoding="UTF-8" @@ -229,10 +235,10 @@ class TestCreateResRetrieveResponse: ) assert xml_output is not None - assert b"RES-2024-001" in xml_output - assert b"John" in xml_output - assert b"Doe" in xml_output - assert b"HOTEL123" in xml_output + assert "RES-2024-001" in xml_output + assert "John" in xml_output + assert "Doe" in xml_output + assert "HOTEL123" in xml_output def test_multiple_reservations( self, @@ -259,10 +265,10 @@ class TestCreateResRetrieveResponse: response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"} ) - assert b"RES-2024-001" in xml_output - assert b"RES-2024-002" in xml_output - assert b"John" in xml_output - assert b"Jane" in xml_output + assert "RES-2024-001" in xml_output + assert "RES-2024-002" in xml_output + assert "John" in xml_output + assert "Jane" in xml_output def test_reservation_with_children(self, sample_reservation, sample_customer): """Test reservation with children ages.""" @@ -280,7 +286,7 @@ class TestCreateResRetrieveResponse: assert response is not None # Children should be represented in guest counts - assert b"GuestCount" in xml_output or b"Child" in xml_output + assert "GuestCount" in xml_output or "Child" in xml_output class TestXMLParsing: @@ -329,17 +335,17 @@ class TestXMLParsing: ) # Verify it's valid XML - assert xml_output.startswith(b'') - assert b"OTA_ResRetrieveRS" in xml_output + assert xml_output.startswith('') + assert "OTA_ResRetrieveRS" in xml_output # Verify customer data is present - assert b"John" in xml_output - assert b"Doe" in xml_output - assert b"john.doe@example.com" in xml_output + assert "John" in xml_output + assert "Doe" in xml_output + assert "john.doe@example.com" in xml_output # Verify reservation data is present - assert b"RES-2024-001" in xml_output - assert b"HOTEL123" in xml_output + assert "RES-2024-001" in xml_output + assert "HOTEL123" in xml_output class TestEdgeCases: @@ -444,7 +450,7 @@ class TestEdgeCases: assert response is not None # UTM parameters should be in comments or other fields - assert b"RES-UTM-TEST" in xml_output + assert "RES-UTM-TEST" in xml_output if __name__ == "__main__":