Saving recommended updates by the Svelte Gemini agent.
This commit is contained in:
@@ -11,7 +11,7 @@ headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
def test_search(obj_type, query, description):
|
||||
def test_search(obj_type, query, description, params=None):
|
||||
"""
|
||||
Helper to run a search test and print results.
|
||||
"""
|
||||
@@ -19,7 +19,8 @@ def test_search(obj_type, query, description):
|
||||
url = f"{BASE_URL}/{obj_type}/search"
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=headers, json=query)
|
||||
response = requests.post(url, headers=headers, json=query, params=params)
|
||||
print(f"URL: {response.url}")
|
||||
print(f"Status Code: {response.status_code}")
|
||||
|
||||
data = response.json()
|
||||
@@ -47,36 +48,37 @@ def test_search(obj_type, query, description):
|
||||
if __name__ == "__main__":
|
||||
print(f"Starting Aether V3 Search Tests against {BASE_URL}\n")
|
||||
|
||||
# 1. Simple Equality
|
||||
# Tests 'eq' operator on 'journal'
|
||||
query_eq = {
|
||||
"and": [
|
||||
{"field": "enable", "op": "eq", "value": True}
|
||||
]
|
||||
# 1. Standardized Global Search (q property)
|
||||
query_q = {
|
||||
"q": "%" # Standardized full-text search across indexed columns
|
||||
}
|
||||
test_search("journal", query_eq, "Simple Equality (enable=True)")
|
||||
test_search("journal", query_q, "Global Search (q property)")
|
||||
|
||||
# 2. LIKE search
|
||||
# Tests 'like' operator with wildcards on 'name' field (corrected from 'title')
|
||||
# Using '%' to catch any journals with names
|
||||
query_like = {
|
||||
"and": [
|
||||
{"field": "name", "op": "like", "value": "%"}
|
||||
]
|
||||
# 2. Hybrid Filtering (POST Body + Query Params)
|
||||
query_simple = {
|
||||
"and": [{"field": "name", "op": "like", "value": "%"}]
|
||||
}
|
||||
test_search("journal", query_like, "LIKE search (name LIKE '%')")
|
||||
params_hybrid = {"enabled": "disabled"} # Should find disabled journals if any
|
||||
test_search("journal", query_simple, "Hybrid Filtering (Body + ?enabled=disabled)", params=params_hybrid)
|
||||
|
||||
# 3. Numeric Comparison
|
||||
# Tests 'gt' (Greater Than) operator
|
||||
query_gt = {
|
||||
"and": [
|
||||
{"field": "id", "op": "gt", "value": 0}
|
||||
]
|
||||
# 3. View Selection (view parameter)
|
||||
# Testing with 'site_domain' which has 'tbl_alt' defined as 'v_site_domain_fqdn_id'
|
||||
query_site = {"q": "%"}
|
||||
params_view = {"view": "alt"}
|
||||
test_search("site_domain", query_site, "View Selection (view=alt)", params=params_view)
|
||||
|
||||
# 4. Explicit Parent Filtering
|
||||
# Testing 'journal_entry' belonging to a journal (journal_id=1 exists based on previous tests)
|
||||
# We'll use the 'for_obj_type' and 'for_obj_id' as query params
|
||||
# Assuming id_random 'DCAV-06-35-85' exists for journal_id 1
|
||||
query_empty = {}
|
||||
params_parent = {
|
||||
"for_obj_type": "journal",
|
||||
"for_obj_id": "DCAV-06-35-85"
|
||||
}
|
||||
test_search("journal", query_gt, "Numeric Comparison (internal id > 0)")
|
||||
test_search("journal_entry", query_empty, "Explicit Parent Filtering (?for_obj_type=journal)", params=params_parent)
|
||||
|
||||
# 4. Complex Nested Logic (AND + OR)
|
||||
# Tests recursive grouping: (enable=True) AND (name LIKE % % OR summary IS NOT NULL)
|
||||
# 5. Complex Nested Logic (Recap)
|
||||
query_nested = {
|
||||
"and": [
|
||||
{"field": "enable", "op": "eq", "value": True},
|
||||
@@ -90,48 +92,4 @@ if __name__ == "__main__":
|
||||
}
|
||||
test_search("journal", query_nested, "Nested Logic (AND + OR group)")
|
||||
|
||||
# 5. IN List
|
||||
# Tests 'in' operator with a list of values
|
||||
# Based on previous results, we know id 1 exists for journal
|
||||
query_in = {
|
||||
"and": [
|
||||
{"field": "journal_id", "op": "in", "value": [1, 2, 3]}
|
||||
]
|
||||
}
|
||||
test_search("journal_entry", query_in, "IN List search (journal_entry with journal_id in [1,2,3])")
|
||||
|
||||
# 6. NULL Check
|
||||
# Tests 'is_null' operator
|
||||
query_null = {
|
||||
"and": [
|
||||
{"field": "notes", "op": "is_null"}
|
||||
]
|
||||
}
|
||||
test_search("site", query_null, "Null Check (notes is NULL)")
|
||||
|
||||
# 7. Event Search
|
||||
query_event = {
|
||||
"and": [
|
||||
{"field": "enable", "op": "eq", "value": True},
|
||||
{"field": "name", "op": "like", "value": "%"}
|
||||
]
|
||||
}
|
||||
test_search("event", query_event, "Event Search (enable=True and has name)")
|
||||
|
||||
# 8. Event Badge Search
|
||||
query_badge = {
|
||||
"and": [
|
||||
{"field": "event_id", "op": "gt", "value": 0}
|
||||
]
|
||||
}
|
||||
test_search("event_badge", query_badge, "Event Badge Search (event_id > 0)")
|
||||
|
||||
# 9. Event Location Search
|
||||
query_location = {
|
||||
"and": [
|
||||
{"field": "name", "op": "like", "value": "%"}
|
||||
]
|
||||
}
|
||||
test_search("event_location", query_location, "Event Location Search (has name)")
|
||||
|
||||
print("Tests Complete.")
|
||||
print("Tests Complete.")
|
||||
|
||||
Reference in New Issue
Block a user