-
Notifications
You must be signed in to change notification settings - Fork 3
fix(tests): repair main test suite — daemon fast-path cascade + entry-point pollution #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,9 +43,16 @@ def _envelope(payload: dict) -> bytes: | |||||||||
|
|
||||||||||
|
|
||||||||||
| def _make_search_dispatcher(payload: dict): | ||||||||||
| """Return a fake ``urlopen`` that returns ``payload`` for every call.""" | ||||||||||
| """Return a fake ``urlopen`` that returns ``payload`` for every call. | ||||||||||
|
|
||||||||||
| ``GET`` requests (REST fast-path) get the bare payload; ``POST`` | ||||||||||
| requests (MCP tools/call) get the JSON-RPC envelope. Lets the same | ||||||||||
| fixture serve ``/search/fast`` and ``mempalace_search`` fallback. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| def fake_urlopen(req, timeout=None): | ||||||||||
| if getattr(req, "data", None) is None: | ||||||||||
| return _FakeResp(json.dumps(payload).encode()) | ||||||||||
| return _FakeResp(_envelope(payload)) | ||||||||||
|
|
||||||||||
| return fake_urlopen | ||||||||||
|
|
@@ -429,6 +436,13 @@ def test_limit_overrides_results(self): | |||||||||
| captured = {} | ||||||||||
|
|
||||||||||
| def fake_urlopen(req, timeout=None): | ||||||||||
| if getattr(req, "data", None) is None: | ||||||||||
| # REST fast-path GET — capture ``limit`` from query string. | ||||||||||
| from urllib.parse import urlparse, parse_qs | ||||||||||
|
|
||||||||||
| qs = parse_qs(urlparse(req.full_url).query) | ||||||||||
| captured["arguments"] = {"limit": int(qs["limit"][0])} | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
|
||||||||||
| return _FakeResp(json.dumps({"results": [], "warnings": []}).encode()) | ||||||||||
| captured["arguments"] = json.loads(req.data.decode())["params"]["arguments"] | ||||||||||
| return _FakeResp(_envelope({"results": [], "warnings": []})) | ||||||||||
|
|
||||||||||
|
|
@@ -445,6 +459,12 @@ def test_results_used_when_limit_unset(self): | |||||||||
| captured = {} | ||||||||||
|
|
||||||||||
| def fake_urlopen(req, timeout=None): | ||||||||||
| if getattr(req, "data", None) is None: | ||||||||||
| from urllib.parse import urlparse, parse_qs | ||||||||||
|
|
||||||||||
| qs = parse_qs(urlparse(req.full_url).query) | ||||||||||
| captured["arguments"] = {"limit": int(qs["limit"][0])} | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
|
||||||||||
| return _FakeResp(json.dumps({"results": [], "warnings": []}).encode()) | ||||||||||
| captured["arguments"] = json.loads(req.data.decode())["params"]["arguments"] | ||||||||||
| return _FakeResp(_envelope({"results": [], "warnings": []})) | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
'rank'key inhithas a value ofNoneor is not a numeric type (e.g., a string), callinground()directly on it will raise aTypeError. To ensure robustness against unexpected daemon responses, we should defensively convert the value to a float and handle potential conversion errors safely.References