Files
wyndham-ARR/tests/test_booking_review_migration.py
2026-07-31 15:11:42 +08:00

34 lines
1.3 KiB
Python

from __future__ import annotations
import unittest
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
UP_PATH = PROJECT_ROOT / "database" / "015_booking_excel_review_drafts.sql"
DOWN_PATH = PROJECT_ROOT / "database" / "015_booking_excel_review_drafts.down.sql"
class BookingReviewMigrationTests(unittest.TestCase):
def test_up_migration_adds_durable_draft_and_item_review_state(self) -> None:
sql = UP_PATH.read_text(encoding="utf-8")
self.assertIn("CREATE TABLE booking.extraction_drafts", sql)
self.assertIn("CREATE TABLE booking.extraction_draft_items", sql)
self.assertIn("'reviewing', 'activated', 'superseded'", sql)
self.assertIn("'confirmed', 'pending', 'deleted'", sql)
self.assertIn("activated_source_batch_id", sql)
self.assertIn("source_fragment", sql)
self.assertIn("room_type_code IS NULL", sql)
def test_down_migration_refuses_to_drop_an_open_review(self) -> None:
sql = DOWN_PATH.read_text(encoding="utf-8")
self.assertIn("draft_status = 'reviewing'", sql)
self.assertIn("DROP TABLE booking.extraction_draft_items", sql)
self.assertIn("DROP TABLE booking.extraction_drafts", sql)
if __name__ == "__main__":
unittest.main(verbosity=2)