Simplified resGuest creation
This commit is contained in:
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"python.testing.pytestArgs": [
|
||||
"test"
|
||||
],
|
||||
"python.testing.unittestEnabled": false,
|
||||
"python.testing.pytestEnabled": true
|
||||
}
|
||||
@@ -7,6 +7,7 @@ requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"generateds>=2.44.3",
|
||||
"lxml>=6.0.1",
|
||||
"pytest>=8.4.2",
|
||||
"ruff>=0.13.1",
|
||||
"xsdata-pydantic[cli,lxml,soap]>=24.5",
|
||||
"xsdata[cli,lxml,soap]>=25.7",
|
||||
|
||||
27
src/main.py
27
src/main.py
@@ -6,7 +6,7 @@ from datetime import datetime, timezone
|
||||
import re
|
||||
from xsdata_pydantic.bindings import XmlSerializer
|
||||
|
||||
from simplified_access import CustomerData, CustomerFactory, PhoneTechType
|
||||
from simplified_access import CustomerData, CustomerFactory, PhoneTechType, ResGuestFactory
|
||||
|
||||
|
||||
|
||||
@@ -59,31 +59,12 @@ def main():
|
||||
language="en"
|
||||
)
|
||||
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(customer_data)
|
||||
|
||||
|
||||
profile = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile(
|
||||
customer=retrieve_customer
|
||||
)
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(customer_data)
|
||||
|
||||
# Use the actual nested Profiles class
|
||||
|
||||
|
||||
profile_info = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo(
|
||||
profile=profile
|
||||
)
|
||||
|
||||
profiles = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests.ResGuest.Profiles(
|
||||
profile_info=profile_info
|
||||
)
|
||||
|
||||
# ResGuest
|
||||
res_guest = (
|
||||
ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests.ResGuest(
|
||||
profiles=profiles
|
||||
)
|
||||
)
|
||||
res_guests = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests(
|
||||
res_guest=res_guest
|
||||
)
|
||||
|
||||
# Use the actual nested HotelReservationIds class
|
||||
hotel_res_ids = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.HotelReservationIds(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ResRetrieveRS xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<ReservationsList>
|
||||
<HotelReservation CreateDateTime="2025-09-24T12:47:54.728936+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<HotelReservation CreateDateTime="2025-09-24T13:06:48.996519+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="6b34fe24ac2ff811"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
|
||||
@@ -191,6 +191,78 @@ class CustomerFactory:
|
||||
)
|
||||
|
||||
|
||||
# Define type aliases for ResGuests types
|
||||
NotifResGuests = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests
|
||||
RetrieveResGuests = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests
|
||||
|
||||
|
||||
class ResGuestFactory:
|
||||
"""Factory class to create complete ResGuests structures with a primary customer."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_res_guests(customer_data: CustomerData) -> NotifResGuests:
|
||||
"""Create a complete ResGuests structure for OtaHotelResNotifRq with primary customer."""
|
||||
return ResGuestFactory._create_res_guests(
|
||||
NotifResGuests,
|
||||
NotifCustomer,
|
||||
customer_data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_res_guests(customer_data: CustomerData) -> RetrieveResGuests:
|
||||
"""Create a complete ResGuests structure for OtaResRetrieveRs with primary customer."""
|
||||
return ResGuestFactory._create_res_guests(
|
||||
RetrieveResGuests,
|
||||
RetrieveCustomer,
|
||||
customer_data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _create_res_guests(res_guests_class: type, customer_class: type, customer_data: CustomerData) -> Any:
|
||||
"""Internal method to create complete ResGuests structure."""
|
||||
|
||||
# Create the customer using the existing CustomerFactory
|
||||
customer = CustomerFactory._create_customer(customer_class, customer_data)
|
||||
|
||||
# Create Profile with the customer
|
||||
profile = res_guests_class.ResGuest.Profiles.ProfileInfo.Profile(
|
||||
customer=customer
|
||||
)
|
||||
|
||||
# Create ProfileInfo with the profile
|
||||
profile_info = res_guests_class.ResGuest.Profiles.ProfileInfo(
|
||||
profile=profile
|
||||
)
|
||||
|
||||
# Create Profiles with the profile_info
|
||||
profiles = res_guests_class.ResGuest.Profiles(
|
||||
profile_info=profile_info
|
||||
)
|
||||
|
||||
# Create ResGuest with the profiles
|
||||
res_guest = res_guests_class.ResGuest(
|
||||
profiles=profiles
|
||||
)
|
||||
|
||||
# Create ResGuests with the res_guest
|
||||
return res_guests_class(
|
||||
res_guest=res_guest
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def extract_primary_customer(res_guests: Union[NotifResGuests, RetrieveResGuests]) -> CustomerData:
|
||||
"""Extract the primary customer data from a ResGuests structure."""
|
||||
|
||||
# Navigate down the nested structure to get the customer
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
|
||||
# Use the existing CustomerFactory conversion method
|
||||
if isinstance(res_guests, NotifResGuests):
|
||||
return CustomerFactory.from_notif_customer(customer)
|
||||
else:
|
||||
return CustomerFactory.from_retrieve_customer(customer)
|
||||
|
||||
|
||||
# Usage examples
|
||||
if __name__ == "__main__":
|
||||
# Create customer data using simple data class
|
||||
@@ -227,4 +299,23 @@ if __name__ == "__main__":
|
||||
print("Converted back to data:", converted_data.given_name, converted_data.surname)
|
||||
|
||||
# Verify they contain the same information
|
||||
print("Original and converted data match:", customer_data == converted_data)
|
||||
print("Original and converted data match:", customer_data == converted_data)
|
||||
|
||||
print("\n--- ResGuestFactory Examples ---")
|
||||
|
||||
# Create complete ResGuests structure for OtaHotelResNotifRq - much simpler!
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(customer_data)
|
||||
print("Created NotifResGuests with customer:",
|
||||
notif_res_guests.res_guest.profiles.profile_info.profile.customer.person_name.given_name)
|
||||
|
||||
# Create complete ResGuests structure for OtaResRetrieveRs - much simpler!
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(customer_data)
|
||||
print("Created RetrieveResGuests with customer:",
|
||||
retrieve_res_guests.res_guest.profiles.profile_info.profile.customer.person_name.given_name)
|
||||
|
||||
# Extract primary customer data back from ResGuests structure
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(retrieve_res_guests)
|
||||
print("Extracted customer data:", extracted_data.given_name, extracted_data.surname)
|
||||
|
||||
# Verify roundtrip conversion
|
||||
print("Roundtrip conversion successful:", customer_data == extracted_data)
|
||||
348
test/test_simplified_access.py
Normal file
348
test/test_simplified_access.py
Normal file
@@ -0,0 +1,348 @@
|
||||
import pytest
|
||||
from typing import Union
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the src directory to the path so we can import our modules
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
from simplified_access import (
|
||||
CustomerData,
|
||||
CustomerFactory,
|
||||
ResGuestFactory,
|
||||
PhoneTechType,
|
||||
NotifCustomer,
|
||||
RetrieveCustomer,
|
||||
NotifResGuests,
|
||||
RetrieveResGuests
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_customer_data():
|
||||
"""Fixture providing sample customer data for testing."""
|
||||
return CustomerData(
|
||||
given_name="John",
|
||||
surname="Doe",
|
||||
name_prefix="Mr.",
|
||||
name_title="Jr.",
|
||||
phone_numbers=[
|
||||
("+1234567890", PhoneTechType.MOBILE),
|
||||
("+0987654321", PhoneTechType.VOICE),
|
||||
("+1111111111", None)
|
||||
],
|
||||
email_address="john.doe@example.com",
|
||||
email_newsletter=True,
|
||||
address_line="123 Main Street",
|
||||
city_name="Anytown",
|
||||
postal_code="12345",
|
||||
country_code="US",
|
||||
address_catalog=False,
|
||||
gender="Male",
|
||||
birth_date="1980-01-01",
|
||||
language="en"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_customer_data():
|
||||
"""Fixture providing minimal customer data (only required fields)."""
|
||||
return CustomerData(
|
||||
given_name="Jane",
|
||||
surname="Smith"
|
||||
)
|
||||
|
||||
|
||||
class TestCustomerData:
|
||||
"""Test the CustomerData dataclass."""
|
||||
|
||||
def test_customer_data_creation_full(self, sample_customer_data):
|
||||
"""Test creating CustomerData with all fields."""
|
||||
assert sample_customer_data.given_name == "John"
|
||||
assert sample_customer_data.surname == "Doe"
|
||||
assert sample_customer_data.name_prefix == "Mr."
|
||||
assert sample_customer_data.email_address == "john.doe@example.com"
|
||||
assert sample_customer_data.email_newsletter is True
|
||||
assert len(sample_customer_data.phone_numbers) == 3
|
||||
|
||||
def test_customer_data_creation_minimal(self, minimal_customer_data):
|
||||
"""Test creating CustomerData with only required fields."""
|
||||
assert minimal_customer_data.given_name == "Jane"
|
||||
assert minimal_customer_data.surname == "Smith"
|
||||
assert minimal_customer_data.phone_numbers == []
|
||||
assert minimal_customer_data.email_address is None
|
||||
assert minimal_customer_data.address_line is None
|
||||
|
||||
def test_phone_numbers_default_initialization(self):
|
||||
"""Test that phone_numbers gets initialized to empty list."""
|
||||
customer_data = CustomerData(given_name="Test", surname="User")
|
||||
assert customer_data.phone_numbers == []
|
||||
|
||||
|
||||
class TestCustomerFactory:
|
||||
"""Test the CustomerFactory class."""
|
||||
|
||||
def test_create_notif_customer_full(self, sample_customer_data):
|
||||
"""Test creating a NotifCustomer with full data."""
|
||||
customer = CustomerFactory.create_notif_customer(sample_customer_data)
|
||||
|
||||
assert isinstance(customer, NotifCustomer)
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
assert customer.person_name.name_prefix == "Mr."
|
||||
assert customer.person_name.name_title == "Jr."
|
||||
|
||||
# Check telephone
|
||||
assert len(customer.telephone) == 3
|
||||
assert customer.telephone[0].phone_number == "+1234567890"
|
||||
assert customer.telephone[0].phone_tech_type == "5" # MOBILE
|
||||
assert customer.telephone[1].phone_tech_type == "1" # VOICE
|
||||
assert customer.telephone[2].phone_tech_type is None
|
||||
|
||||
# Check email
|
||||
assert customer.email.value == "john.doe@example.com"
|
||||
assert customer.email.remark == "newsletter:yes"
|
||||
|
||||
# Check address
|
||||
assert customer.address.address_line == "123 Main Street"
|
||||
assert customer.address.city_name == "Anytown"
|
||||
assert customer.address.postal_code == "12345"
|
||||
assert customer.address.country_name.code == "US"
|
||||
assert customer.address.remark == "catalog:no"
|
||||
|
||||
# Check other attributes
|
||||
assert customer.gender == "Male"
|
||||
assert customer.birth_date == "1980-01-01"
|
||||
assert customer.language == "en"
|
||||
|
||||
def test_create_retrieve_customer_full(self, sample_customer_data):
|
||||
"""Test creating a RetrieveCustomer with full data."""
|
||||
customer = CustomerFactory.create_retrieve_customer(sample_customer_data)
|
||||
|
||||
assert isinstance(customer, RetrieveCustomer)
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
# Same structure as NotifCustomer, so we don't need to test all fields again
|
||||
|
||||
def test_create_customer_minimal(self, minimal_customer_data):
|
||||
"""Test creating customers with minimal data."""
|
||||
notif_customer = CustomerFactory.create_notif_customer(minimal_customer_data)
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(minimal_customer_data)
|
||||
|
||||
for customer in [notif_customer, retrieve_customer]:
|
||||
assert customer.person_name.given_name == "Jane"
|
||||
assert customer.person_name.surname == "Smith"
|
||||
assert customer.person_name.name_prefix is None
|
||||
assert customer.person_name.name_title is None
|
||||
assert len(customer.telephone) == 0
|
||||
assert customer.email is None
|
||||
assert customer.address is None
|
||||
assert customer.gender is None
|
||||
assert customer.birth_date is None
|
||||
assert customer.language is None
|
||||
|
||||
def test_email_newsletter_options(self):
|
||||
"""Test different email newsletter options."""
|
||||
# Newsletter yes
|
||||
data_yes = CustomerData(given_name="Test", surname="User",
|
||||
email_address="test@example.com", email_newsletter=True)
|
||||
customer = CustomerFactory.create_notif_customer(data_yes)
|
||||
assert customer.email.remark == "newsletter:yes"
|
||||
|
||||
# Newsletter no
|
||||
data_no = CustomerData(given_name="Test", surname="User",
|
||||
email_address="test@example.com", email_newsletter=False)
|
||||
customer = CustomerFactory.create_notif_customer(data_no)
|
||||
assert customer.email.remark == "newsletter:no"
|
||||
|
||||
# Newsletter not specified
|
||||
data_none = CustomerData(given_name="Test", surname="User",
|
||||
email_address="test@example.com", email_newsletter=None)
|
||||
customer = CustomerFactory.create_notif_customer(data_none)
|
||||
assert customer.email.remark is None
|
||||
|
||||
def test_address_catalog_options(self):
|
||||
"""Test different address catalog options."""
|
||||
# Catalog no
|
||||
data_no = CustomerData(given_name="Test", surname="User",
|
||||
address_line="123 Street", address_catalog=False)
|
||||
customer = CustomerFactory.create_notif_customer(data_no)
|
||||
assert customer.address.remark == "catalog:no"
|
||||
|
||||
# Catalog yes
|
||||
data_yes = CustomerData(given_name="Test", surname="User",
|
||||
address_line="123 Street", address_catalog=True)
|
||||
customer = CustomerFactory.create_notif_customer(data_yes)
|
||||
assert customer.address.remark == "catalog:yes"
|
||||
|
||||
# Catalog not specified
|
||||
data_none = CustomerData(given_name="Test", surname="User",
|
||||
address_line="123 Street", address_catalog=None)
|
||||
customer = CustomerFactory.create_notif_customer(data_none)
|
||||
assert customer.address.remark is None
|
||||
|
||||
def test_from_notif_customer_roundtrip(self, sample_customer_data):
|
||||
"""Test converting NotifCustomer back to CustomerData."""
|
||||
customer = CustomerFactory.create_notif_customer(sample_customer_data)
|
||||
converted_data = CustomerFactory.from_notif_customer(customer)
|
||||
|
||||
assert converted_data == sample_customer_data
|
||||
|
||||
def test_from_retrieve_customer_roundtrip(self, sample_customer_data):
|
||||
"""Test converting RetrieveCustomer back to CustomerData."""
|
||||
customer = CustomerFactory.create_retrieve_customer(sample_customer_data)
|
||||
converted_data = CustomerFactory.from_retrieve_customer(customer)
|
||||
|
||||
assert converted_data == sample_customer_data
|
||||
|
||||
def test_phone_tech_type_conversion(self):
|
||||
"""Test that PhoneTechType enum values are properly converted."""
|
||||
data = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
phone_numbers=[
|
||||
("+1111111111", PhoneTechType.VOICE),
|
||||
("+2222222222", PhoneTechType.FAX),
|
||||
("+3333333333", PhoneTechType.MOBILE)
|
||||
]
|
||||
)
|
||||
|
||||
customer = CustomerFactory.create_notif_customer(data)
|
||||
assert customer.telephone[0].phone_tech_type == "1" # VOICE
|
||||
assert customer.telephone[1].phone_tech_type == "3" # FAX
|
||||
assert customer.telephone[2].phone_tech_type == "5" # MOBILE
|
||||
|
||||
|
||||
class TestResGuestFactory:
|
||||
"""Test the ResGuestFactory class."""
|
||||
|
||||
def test_create_notif_res_guests(self, sample_customer_data):
|
||||
"""Test creating NotifResGuests structure."""
|
||||
res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
|
||||
assert isinstance(res_guests, NotifResGuests)
|
||||
|
||||
# Navigate down the nested structure
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
assert customer.email.value == "john.doe@example.com"
|
||||
|
||||
def test_create_retrieve_res_guests(self, sample_customer_data):
|
||||
"""Test creating RetrieveResGuests structure."""
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
|
||||
assert isinstance(res_guests, RetrieveResGuests)
|
||||
|
||||
# Navigate down the nested structure
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
assert customer.email.value == "john.doe@example.com"
|
||||
|
||||
def test_create_res_guests_minimal(self, minimal_customer_data):
|
||||
"""Test creating ResGuests with minimal customer data."""
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(minimal_customer_data)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(minimal_customer_data)
|
||||
|
||||
for res_guests in [notif_res_guests, retrieve_res_guests]:
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "Jane"
|
||||
assert customer.person_name.surname == "Smith"
|
||||
assert customer.email is None
|
||||
assert customer.address is None
|
||||
|
||||
def test_extract_primary_customer_notif(self, sample_customer_data):
|
||||
"""Test extracting primary customer from NotifResGuests."""
|
||||
res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
def test_extract_primary_customer_retrieve(self, sample_customer_data):
|
||||
"""Test extracting primary customer from RetrieveResGuests."""
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
def test_roundtrip_conversion_notif(self, sample_customer_data):
|
||||
"""Test complete roundtrip: CustomerData -> NotifResGuests -> CustomerData."""
|
||||
res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
def test_roundtrip_conversion_retrieve(self, sample_customer_data):
|
||||
"""Test complete roundtrip: CustomerData -> RetrieveResGuests -> CustomerData."""
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
|
||||
class TestPhoneTechType:
|
||||
"""Test the PhoneTechType enum."""
|
||||
|
||||
def test_enum_values(self):
|
||||
"""Test that enum values are correct."""
|
||||
assert PhoneTechType.VOICE.value == "1"
|
||||
assert PhoneTechType.FAX.value == "3"
|
||||
assert PhoneTechType.MOBILE.value == "5"
|
||||
|
||||
|
||||
class TestIntegration:
|
||||
"""Integration tests combining both factories."""
|
||||
|
||||
def test_both_factories_produce_same_customer_data(self, sample_customer_data):
|
||||
"""Test that both factories can work with the same customer data."""
|
||||
# Create using CustomerFactory
|
||||
notif_customer = CustomerFactory.create_notif_customer(sample_customer_data)
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(sample_customer_data)
|
||||
|
||||
# Create using ResGuestFactory and extract customers
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
|
||||
notif_from_res_guests = notif_res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
retrieve_from_res_guests = retrieve_res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
|
||||
# Compare customer names (structure should be identical)
|
||||
assert notif_customer.person_name.given_name == notif_from_res_guests.person_name.given_name
|
||||
assert notif_customer.person_name.surname == notif_from_res_guests.person_name.surname
|
||||
assert retrieve_customer.person_name.given_name == retrieve_from_res_guests.person_name.given_name
|
||||
assert retrieve_customer.person_name.surname == retrieve_from_res_guests.person_name.surname
|
||||
|
||||
def test_complex_customer_workflow(self):
|
||||
"""Test a complex workflow with multiple operations."""
|
||||
# Create original data
|
||||
original_data = CustomerData(
|
||||
given_name="Alice",
|
||||
surname="Johnson",
|
||||
phone_numbers=[
|
||||
("+1555123456", PhoneTechType.MOBILE),
|
||||
("+1555654321", PhoneTechType.VOICE)
|
||||
],
|
||||
email_address="alice.johnson@company.com",
|
||||
email_newsletter=False,
|
||||
address_line="456 Business Ave",
|
||||
city_name="Metropolis",
|
||||
postal_code="67890",
|
||||
country_code="CA",
|
||||
address_catalog=True,
|
||||
gender="Female",
|
||||
language="fr"
|
||||
)
|
||||
|
||||
# Create ResGuests for both types
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(original_data)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(original_data)
|
||||
|
||||
# Extract data back from both
|
||||
notif_extracted = ResGuestFactory.extract_primary_customer(notif_res_guests)
|
||||
retrieve_extracted = ResGuestFactory.extract_primary_customer(retrieve_res_guests)
|
||||
|
||||
# All should be equal
|
||||
assert original_data == notif_extracted
|
||||
assert original_data == retrieve_extracted
|
||||
assert notif_extracted == retrieve_extracted
|
||||
54
uv.lock
generated
54
uv.lock
generated
@@ -9,6 +9,7 @@ source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "generateds" },
|
||||
{ name = "lxml" },
|
||||
{ name = "pytest" },
|
||||
{ name = "ruff" },
|
||||
{ name = "xsdata", extra = ["cli", "lxml", "soap"] },
|
||||
{ name = "xsdata-pydantic", extra = ["cli", "lxml", "soap"] },
|
||||
@@ -18,6 +19,7 @@ dependencies = [
|
||||
requires-dist = [
|
||||
{ name = "generateds", specifier = ">=2.44.3" },
|
||||
{ name = "lxml", specifier = ">=6.0.1" },
|
||||
{ name = "pytest", specifier = ">=8.4.2" },
|
||||
{ name = "ruff", specifier = ">=0.13.1" },
|
||||
{ name = "xsdata", extras = ["cli", "lxml", "soap"], specifier = ">=25.7" },
|
||||
{ name = "xsdata-pydantic", extras = ["cli", "lxml", "soap"], specifier = ">=24.5" },
|
||||
@@ -140,6 +142,15 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "2.1.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", size = 4793 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jinja2"
|
||||
version = "3.1.6"
|
||||
@@ -224,6 +235,24 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/4f/65/6079a46068dfceaeabb5dcad6d674f5f5c61a6fa5673746f42a9f4c233b3/MarkupSafe-3.0.2-cp313-cp313t-win_amd64.whl", hash = "sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f", size = 15739 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "25.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.6.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic"
|
||||
version = "2.11.9"
|
||||
@@ -267,6 +296,31 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/6f/9a/e73262f6c6656262b5fdd723ad90f518f579b7bc8622e43a942eec53c938/pydantic_core-2.33.2-cp313-cp313t-win_amd64.whl", hash = "sha256:c2fc0a768ef76c15ab9238afa6da7f69895bb5d1ee83aeea2e3509af4472d0b9", size = 1935777 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pygments"
|
||||
version = "2.19.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "8.4.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||
{ name = "iniconfig" },
|
||||
{ name = "packaging" },
|
||||
{ name = "pluggy" },
|
||||
{ name = "pygments" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a3/5c/00a0e072241553e1a7496d638deababa67c5058571567b92a7eaa258397c/pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01", size = 1519618 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a8/a4/20da314d277121d6534b3a980b29035dcd51e6744bd79075a6ce8fa4eb8d/pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79", size = 365750 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "requests"
|
||||
version = "2.32.5"
|
||||
|
||||
Reference in New Issue
Block a user