I think acknowledgments work just fine now

This commit is contained in:
Jonas Linter
2025-10-09 09:38:54 +02:00
parent 1b3ebb3cad
commit 95b17b8776
2 changed files with 43 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import logging import logging
import traceback import traceback
from dataclasses import dataclass from dataclasses import dataclass
from datetime import UTC, datetime from datetime import UTC
from enum import Enum from enum import Enum
from typing import Any from typing import Any
@@ -786,7 +786,7 @@ def _process_single_reservation(
) )
hotel_reservation = HotelReservation( hotel_reservation = HotelReservation(
create_date_time=datetime.now(UTC).isoformat(), create_date_time=reservation.created_at.replace(tzinfo=UTC).isoformat(),
res_status=HotelReservationResStatus.REQUESTED, res_status=HotelReservationResStatus.REQUESTED,
room_stay_reservation="true", room_stay_reservation="true",
unique_id=unique_id, unique_id=unique_id,

View File

@@ -713,7 +713,11 @@ class TestAcknowledgments:
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_acknowledgments_work_with_date_filters( async def test_acknowledgments_work_with_date_filters(
self, alpinebits_server, populated_db_session, client_info self,
alpinebits_server,
populated_db_session,
client_info,
read_request_xml_no_date_filter,
): ):
"""Test 5: Verify acknowledgments still work when SelectionCriteria date filters are applied.""" """Test 5: Verify acknowledgments still work when SelectionCriteria date filters are applied."""
# Read request with date filter # Read request with date filter
@@ -749,9 +753,14 @@ class TestAcknowledgments:
): ):
initial_count = len(initial_parsed.reservations_list.hotel_reservation) initial_count = len(initial_parsed.reservations_list.hotel_reservation)
assert initial_count > 0, "Initial count with date filter should be > 0"
assert initial_count == 1, (
"Should only return one reservation with this date filter"
)
# Acknowledge one reservation that falls within the date range # Acknowledge one reservation that falls within the date range
# The sample_reservation has dates 2024-12-25 to 2024-12-31, which should be in range # The sample_reservation was created at 2024-11-01 and thus falls out of range
sample_unique_id = "RES-2024-001" sample_unique_id = "RES-2024-002"
md5_hash = hashlib.md5(sample_unique_id.encode()).hexdigest() md5_hash = hashlib.md5(sample_unique_id.encode()).hexdigest()
acked_request = AckedRequest( acked_request = AckedRequest(
@@ -762,6 +771,31 @@ class TestAcknowledgments:
populated_db_session.add(acked_request) populated_db_session.add(acked_request)
await populated_db_session.commit() await populated_db_session.commit()
without_filter_read = await alpinebits_server.handle_request(
request_action_name="OTA_Read:GuestRequests",
request_xml=read_request_xml_no_date_filter,
client_info=client_info,
version="2024-10",
dbsession=populated_db_session,
)
without_filter_parsed = parser.from_string(
without_filter_read.xml_content, OtaResRetrieveRs
)
without_filter_count = 0
if (
without_filter_parsed.reservations_list
and without_filter_parsed.reservations_list.hotel_reservation
):
without_filter_count = len(
without_filter_parsed.reservations_list.hotel_reservation
)
assert without_filter_count == 1, (
"Without date filter, should return one reservation after acknowledgment"
)
# Second read with same date filter # Second read with same date filter
second_response = await alpinebits_server.handle_request( second_response = await alpinebits_server.handle_request(
request_action_name="OTA_Read:GuestRequests", request_action_name="OTA_Read:GuestRequests",
@@ -781,8 +815,10 @@ class TestAcknowledgments:
): ):
second_count = len(second_parsed.reservations_list.hotel_reservation) second_count = len(second_parsed.reservations_list.hotel_reservation)
# Should have fewer reservations even with date filter # Should have exactly the same amount of reservations
assert second_count < initial_count assert second_count == initial_count, (
"Acknowledgment should not affect count when date filter is applied"
)
if __name__ == "__main__": if __name__ == "__main__":