fix: support bilingual Booking Excel headers

This commit is contained in:
Wyndham ARR
2026-08-11 15:29:42 +08:00
parent ca3e8e18fa
commit c947230471
15 changed files with 366 additions and 30 deletions

View File

@@ -3,6 +3,7 @@ from __future__ import annotations
import base64
import hashlib
import json
import re
import tempfile
import unittest
from datetime import date
@@ -1077,5 +1078,26 @@ class ControlledDownloadTests(unittest.TestCase):
reader.read(bad)
class BookingHeaderI18nContractTests(unittest.TestCase):
def test_booking_header_errors_have_three_locale_messages(self) -> None:
script = (STATIC_ROOT / "i18n.js").read_text(encoding="utf-8")
expected = {
"BOOKING_EXCEL_HEADERS_MISSING": "error.booking_headers_missing",
"BOOKING_EXCEL_HEADERS_AMBIGUOUS": "error.booking_headers_ambiguous",
}
for code, key in expected.items():
self.assertIn(f'{code}: "{key}"', script)
match = re.search(
rf'^\s*"{re.escape(key)}": (\[.*\]),$',
script,
re.MULTILINE,
)
self.assertIsNotNone(match, key)
values = json.loads(match.group(1))
self.assertEqual(len(values), 3, key)
self.assertTrue(all(values), key)
self.assertRegex(values[2], r"[\u0e00-\u0e7f]", key)
if __name__ == "__main__":
unittest.main()