about summary refs log tree commit diff
path: root/test/python/test_search.py
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabua@gmail.com>2026-10-04 12:14:11 +0300
committerAlexander_Kabui <alexanderkabua@gmail.com>2026-10-05 21:53:57 +0300
commit98b71eb8c080c21ca458961805019170c794fdc7 (patch)
treec08c751223fb13f4721a5a95e161cefba5a8ee80 /test/python/test_search.py
parent1b40aa1f557eadd8894996fff6081d2917e28f20 (diff)
downloadgenenetwork4-98b71eb8c080c21ca458961805019170c794fdc7.tar.gz
* src/routes/search.rs (search): map any gn3 4xx with an error body to 422
Production gn3 puts the diagnostic under "error" and leaks Python
reprs under "error_type", so the old "parsererror" match never
fired and malformed queries fell to 502 with no actionable feedback.
Match on "error" alone; gn3 5xx stays 502.

* tests/search.rs test/python/test_search.py (search): stub replays
production's error body shape.
Diffstat (limited to 'test/python/test_search.py')
-rw-r--r--test/python/test_search.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/python/test_search.py b/test/python/test_search.py
index 1d2118e..d8c5cc5 100644
--- a/test/python/test_search.py
+++ b/test/python/test_search.py
@@ -24,10 +24,12 @@ class Gn3StubHandler(http.server.BaseHTTPRequestHandler):
     def do_GET(self):
         query = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)
         if "&&" in query.get("query", [""])[0]:
+            # Mirrors production gn3's shape (live-checked Oct 4):
+            # diagnostic under "error", Python repr under "error_type".
             body = json.dumps(
                 {
-                    "error": "parsererror",
-                    "error_message": "Syntax error in query: unexpected &&",
+                    "error": "Syntax: <expression> AND <expression>",
+                    "error_type": "b'QueryParserError'",
                 }
             ).encode()
             self.send_response(http.client.BAD_REQUEST)
@@ -91,7 +93,7 @@ class SearchTest(ServerTestCase):
         status, body = self.get("/search?q=a%26%26b")
         self.assertEqual(status, http.client.UNPROCESSABLE_ENTITY)
         self.assertEqual(body["code"], "invalid_query")
-        self.assertIn("Syntax error in query", body["detail"])
+        self.assertIn("Syntax: <expression> AND <expression>", body["detail"])
 
     def test_search_caps_limit(self):
         status, _ = self.get("/search?q=alcohol&limit=9999")