feat: add priority filtering and sort stability to V3 Lookup System

This commit is contained in:
Scott Idem
2026-02-20 17:18:21 -05:00
parent 6bfbff309a
commit 48fc97cf46
5 changed files with 74 additions and 17 deletions

View File

@@ -20,13 +20,16 @@ def print_result(label, success, message=""):
status = "✅ PASS" if success else "❌ FAIL"
print(f"{status} | {label} {': ' + message if message else ''}")
def test_lookup_list(lu_type, site_id=None):
def test_lookup_list(lu_type, site_id=None, only_priority=False):
label = f"GET /{lu_type}/list"
url = f"{BASE_URL}/{lu_type}/list"
params = {}
if site_id:
params["site_id"] = site_id
label += f" (Site: {site_id})"
if only_priority:
params["only_priority"] = "true"
label += " (Priority Only)"
try:
start_time = time.time()
@@ -37,6 +40,16 @@ def test_lookup_list(lu_type, site_id=None):
data = response.json().get('data', [])
msg = f"Found {len(data)} items ({duration:.2f}s)"
print_result(label, True, msg)
# Print top 10 for sorting verification
if data and not site_id: # Only print for full or priority lists
limit = 10 if not only_priority else len(data)
print(f" Items:")
for i, item in enumerate(data[:limit]):
prio = item.get('priority', 0)
sort = item.get('sort', 0)
print(f" [{i+1}] {item.get('name')} (Prio: {prio}, Sort: {sort})")
return data
else:
print_result(label, False, f"Status {response.status_code}: {response.text[:100]}")
@@ -68,7 +81,9 @@ if __name__ == "__main__":
# 1. Basic Lists (Phase 1)
test_lookup_list("country")
test_lookup_list("time_zone")
print("\n--- Testing Priority Only ---")
test_lookup_list("time_zone", only_priority=True)
# 2. Whitelist Test (Phase 2)
if SITE_ID_RANDOM != "SET_ME_TO_SITE_ID":