More tests. Hard to say how useful they are though. Need further work
This commit is contained in:
@@ -8,9 +8,8 @@ from datetime import UTC, date, datetime
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
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.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.alpine_bits_helpers import create_res_retrieve_response
|
||||||
from alpine_bits_python.alpinebits_server import AlpineBitsClientInfo
|
from alpine_bits_python.alpinebits_server import AlpineBitsClientInfo
|
||||||
@@ -216,9 +215,16 @@ class TestCreateResRetrieveResponse:
|
|||||||
"Response should have reservations_list attribute"
|
"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"
|
"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
|
# Verify the response can be serialized to XML
|
||||||
config = SerializerConfig(
|
config = SerializerConfig(
|
||||||
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
||||||
@@ -229,10 +235,10 @@ class TestCreateResRetrieveResponse:
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert xml_output is not None
|
assert xml_output is not None
|
||||||
assert b"RES-2024-001" in xml_output
|
assert "RES-2024-001" in xml_output
|
||||||
assert b"John" in xml_output
|
assert "John" in xml_output
|
||||||
assert b"Doe" in xml_output
|
assert "Doe" in xml_output
|
||||||
assert b"HOTEL123" in xml_output
|
assert "HOTEL123" in xml_output
|
||||||
|
|
||||||
def test_multiple_reservations(
|
def test_multiple_reservations(
|
||||||
self,
|
self,
|
||||||
@@ -259,10 +265,10 @@ class TestCreateResRetrieveResponse:
|
|||||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert b"RES-2024-001" in xml_output
|
assert "RES-2024-001" in xml_output
|
||||||
assert b"RES-2024-002" in xml_output
|
assert "RES-2024-002" in xml_output
|
||||||
assert b"John" in xml_output
|
assert "John" in xml_output
|
||||||
assert b"Jane" in xml_output
|
assert "Jane" in xml_output
|
||||||
|
|
||||||
def test_reservation_with_children(self, sample_reservation, sample_customer):
|
def test_reservation_with_children(self, sample_reservation, sample_customer):
|
||||||
"""Test reservation with children ages."""
|
"""Test reservation with children ages."""
|
||||||
@@ -280,7 +286,7 @@ class TestCreateResRetrieveResponse:
|
|||||||
|
|
||||||
assert response is not None
|
assert response is not None
|
||||||
# Children should be represented in guest counts
|
# 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:
|
class TestXMLParsing:
|
||||||
@@ -329,17 +335,17 @@ class TestXMLParsing:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Verify it's valid XML
|
# Verify it's valid XML
|
||||||
assert xml_output.startswith(b'<?xml version="1.0" encoding="UTF-8"?>')
|
assert xml_output.startswith('<?xml version="1.0" encoding="UTF-8"?>')
|
||||||
assert b"OTA_ResRetrieveRS" in xml_output
|
assert "OTA_ResRetrieveRS" in xml_output
|
||||||
|
|
||||||
# Verify customer data is present
|
# Verify customer data is present
|
||||||
assert b"John" in xml_output
|
assert "John" in xml_output
|
||||||
assert b"Doe" in xml_output
|
assert "Doe" in xml_output
|
||||||
assert b"john.doe@example.com" in xml_output
|
assert "john.doe@example.com" in xml_output
|
||||||
|
|
||||||
# Verify reservation data is present
|
# Verify reservation data is present
|
||||||
assert b"RES-2024-001" in xml_output
|
assert "RES-2024-001" in xml_output
|
||||||
assert b"HOTEL123" in xml_output
|
assert "HOTEL123" in xml_output
|
||||||
|
|
||||||
|
|
||||||
class TestEdgeCases:
|
class TestEdgeCases:
|
||||||
@@ -444,7 +450,7 @@ class TestEdgeCases:
|
|||||||
|
|
||||||
assert response is not None
|
assert response is not None
|
||||||
# UTM parameters should be in comments or other fields
|
# 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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user