Activated free rooms
This commit is contained in:
@@ -124,7 +124,7 @@ async def test_complete_set_creates_inventory_and_availability(db_session: Async
|
||||
)
|
||||
).scalars().all()
|
||||
assert len(rows) == 3
|
||||
assert rows[0].count_type_2 == 4
|
||||
assert rows[0].bookable_type_2 == 4
|
||||
assert rows[0].update_type == "CompleteSet"
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ async def test_complete_set_replaces_previous_availability(db_session: AsyncSess
|
||||
).scalars().all()
|
||||
assert len(rows) == 1
|
||||
assert rows[0].date.isoformat() == "2025-02-01"
|
||||
assert rows[0].count_type_2 == 1
|
||||
assert rows[0].bookable_type_2 == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -186,7 +186,7 @@ async def test_delta_updates_only_specified_dates(db_session: AsyncSession):
|
||||
rows = (
|
||||
await db_session.execute(select(RoomAvailability).order_by(RoomAvailability.date))
|
||||
).scalars().all()
|
||||
counts = {row.date.isoformat(): row.count_type_2 for row in rows}
|
||||
counts = {row.date.isoformat(): row.bookable_type_2 for row in rows}
|
||||
assert counts == {
|
||||
"2025-03-01": 2,
|
||||
"2025-03-02": 7,
|
||||
@@ -229,7 +229,7 @@ async def test_closing_season_entries_marked_correctly(db_session: AsyncSession)
|
||||
).scalars().all()
|
||||
closing_rows = [row for row in rows if row.is_closing_season]
|
||||
assert len(closing_rows) == 2
|
||||
assert all(row.count_type_2 is None for row in closing_rows)
|
||||
assert all(row.bookable_type_2 is None for row in closing_rows)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -366,3 +366,197 @@ async def test_invalid_xml_returns_error(db_session: AsyncSession):
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.BAD_REQUEST
|
||||
assert "Invalid XML payload" in response.xml_content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_mixing_categories_and_rooms_is_rejected(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
# First inventory is a category (no InvCode), second is an individual room (with InvCode)
|
||||
xml = build_complete_set_xml(
|
||||
"""
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-01" End="2025-08-10" InvTypeCode="DOUBLE" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="3" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-21" End="2025-08-30" InvTypeCode="DOUBLE" InvCode="108" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="1" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
"""
|
||||
)
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.BAD_REQUEST
|
||||
assert "Mixing room categories and individual rooms" in response.xml_content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_mixing_rooms_and_categories_is_rejected(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
# First inventory is an individual room (with InvCode), second is a category (no InvCode)
|
||||
xml = build_complete_set_xml(
|
||||
"""
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-21" End="2025-08-30" InvTypeCode="DOUBLE" InvCode="108" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="1" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-01" End="2025-08-10" InvTypeCode="DOUBLE" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="3" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
"""
|
||||
)
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.BAD_REQUEST
|
||||
assert "Mixing room categories and individual rooms" in response.xml_content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_multiple_categories_are_allowed(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
# Multiple category reports (all without InvCode) should be allowed
|
||||
xml = build_complete_set_xml(
|
||||
"""
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-01" End="2025-08-10" InvTypeCode="DOUBLE" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="3" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-11" End="2025-08-20" InvTypeCode="SINGLE" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="2" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
"""
|
||||
)
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.OK
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_multiple_rooms_are_allowed(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
# Multiple individual room reports (all with InvCode) should be allowed
|
||||
xml = build_complete_set_xml(
|
||||
"""
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-01" End="2025-08-10" InvTypeCode="DOUBLE" InvCode="101" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="1" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-08-11" End="2025-08-20" InvTypeCode="DOUBLE" InvCode="102" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="1" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
"""
|
||||
)
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.OK
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_closing_season_with_categories_is_allowed(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
# Closing season followed by category reports should be allowed
|
||||
xml = build_complete_set_xml(
|
||||
"""
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-04-01" End="2025-04-02" AllInvCode="true"/>
|
||||
</Inventory>
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-04-03" End="2025-04-10" InvTypeCode="DOUBLE" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="3" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
"""
|
||||
)
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.OK
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_closing_season_with_rooms_is_allowed(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
# Closing season followed by individual room reports should be allowed
|
||||
xml = build_complete_set_xml(
|
||||
"""
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-04-01" End="2025-04-02" AllInvCode="true"/>
|
||||
</Inventory>
|
||||
<Inventory>
|
||||
<StatusApplicationControl Start="2025-04-03" End="2025-04-10" InvTypeCode="DOUBLE" InvCode="101" />
|
||||
<InvCounts>
|
||||
<InvCount CountType="2" Count="1" />
|
||||
</InvCounts>
|
||||
</Inventory>
|
||||
"""
|
||||
)
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.OK
|
||||
|
||||
Reference in New Issue
Block a user