Fixed incorrect overlap detection
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
@@ -231,6 +232,36 @@ async def test_closing_season_entries_marked_correctly(db_session: AsyncSession)
|
||||
assert len(closing_rows) == 2
|
||||
assert all(row.bookable_type_2 is None for row in closing_rows)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_closing_seasons_test_file(db_session: AsyncSession):
|
||||
await insert_test_hotel(db_session)
|
||||
action = make_action()
|
||||
|
||||
Path(__file__).parent / "test_data" / "ClosingSeasons.xml"
|
||||
|
||||
xml = (Path(__file__).parent / "test_data" / "ClosingSeasons.xml").read_text()
|
||||
|
||||
response = await action.handle(
|
||||
"OTA_HotelInvCountNotif:FreeRooms",
|
||||
xml,
|
||||
Version.V2024_10,
|
||||
make_client_info(),
|
||||
db_session,
|
||||
)
|
||||
assert response.status_code == HttpStatusCode.OK, f"Response was not OK {response.xml_content}"
|
||||
|
||||
inventories = (await db_session.execute(select(HotelInventory))).scalars().all()
|
||||
closing_inventory = next(inv for inv in inventories if inv.inv_type_code == "__CLOSE")
|
||||
assert closing_inventory.inv_code is None
|
||||
|
||||
rows = (
|
||||
await db_session.execute(select(RoomAvailability).order_by(RoomAvailability.date))
|
||||
).scalars().all()
|
||||
closing_rows = [row for row in rows if row.is_closing_season]
|
||||
# Closing season from 2025-12-20 to 2025-12-23 = 4 days
|
||||
assert len(closing_rows) == 4
|
||||
assert all(row.bookable_type_2 is None for row in closing_rows)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_closing_season_not_allowed_in_delta(db_session: AsyncSession):
|
||||
|
||||
Reference in New Issue
Block a user