diff --git a/app/methods/lookup_methods.py b/app/methods/lookup_methods.py index 35a5488..5db0cd8 100644 --- a/app/methods/lookup_methods.py +++ b/app/methods/lookup_methods.py @@ -28,8 +28,8 @@ def get_lookup_list_v3( SELECT * FROM ( SELECT *, ROW_NUMBER() OVER ( - PARTITION BY `group` - ORDER BY + PARTITION BY `name` + ORDER BY (for_type = :for_type AND for_id = :for_id) DESC, (account_id = :account_id) DESC, created_on DESC diff --git a/tests/e2e/test_e2e_v3_lookup.py b/tests/e2e/test_e2e_v3_lookup.py index 7be1bd1..d2dfd27 100644 --- a/tests/e2e/test_e2e_v3_lookup.py +++ b/tests/e2e/test_e2e_v3_lookup.py @@ -75,13 +75,35 @@ def test_lookup_resolve(lu_type, query): print_result(f"GET /{lu_type}/resolve?q={query}", False, str(e)) return False +US_TIMEZONES = [ + "US/Alaska", "US/Arizona", "US/Central", "US/East-Indiana", + "US/Eastern", "US/Hawaii", "US/Indiana-Starke", "US/Michigan", + "US/Mountain", "US/Pacific", "US/Pacific-New", "US/Samoa", +] + +def test_timezone_us_dedup(): + """Regression: PARTITION BY `name` fix — all 12 US/* zones must appear.""" + label = "time_zone US/* deduplication (regression)" + data = test_lookup_list("time_zone") + if data is None: + return + names = {item.get("name") for item in data} + missing = [tz for tz in US_TIMEZONES if tz not in names] + if missing: + print_result(label, False, f"Missing: {missing}") + else: + print_result(label, True, f"All 12 US/* timezones present ({len(data)} total)") + if __name__ == "__main__": print(f"🚀 Starting V3 Lookup E2E Suite ({BASE_URL})\n") start_suite = time.time() - + # 1. Basic Lists (Phase 1) test_lookup_list("country") - + + print("\n--- Regression: US/* timezone deduplication ---") + test_timezone_us_dedup() + print("\n--- Testing Priority Only ---") test_lookup_list("time_zone", only_priority=True)