test(integration): address round-5 review — parse safety & timeout headroom

- _search_helpers: wrap the json.loads(search.content[0].text) parse in
  try/except (IndexError, ValueError) so empty content / malformed JSON returns
  False (keep polling) instead of escaping as a confusing traceback. Also debug-
  log an id match with a non-note doc_type to surface schema drift instead of
  silently timing out.
- test_astrolabe_session_jwt_search: drop _get_with_retry default to
  max_attempts=2 (matches the "one retry" intent) and mark both search tests
  @pytest.mark.timeout(300) so a cold model load + retry can't breach the 180s
  default pytest timeout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-17 23:08:59 +02:00
co-authored by Claude Opus 4.8
parent 7c13c6e49a
commit 829625f2a2
2 changed files with 19 additions and 4 deletions
@@ -44,7 +44,7 @@ _SEARCH_TIMEOUT = httpx.Timeout(90.0)
async def _get_with_retry(
client: httpx.AsyncClient, url: str, *, max_attempts: int = 3, **kwargs
client: httpx.AsyncClient, url: str, *, max_attempts: int = 2, **kwargs
) -> httpx.Response:
"""GET, retrying on transient transport errors (timeouts/conn resets)."""
last_exc: httpx.TransportError | None = None
@@ -74,6 +74,7 @@ async def _astrolabe_configured(client: httpx.AsyncClient, auth) -> bool:
return bool(resp.json().get("success"))
@pytest.mark.timeout(300) # cold model load + retry can exceed the 180s default
async def test_session_user_searches_without_provisioning(test_users_setup):
"""A non-admin session user searches with no OAuth/provisioning step.
@@ -111,6 +112,7 @@ async def test_session_user_searches_without_provisioning(test_users_setup):
assert "results" in body and "algorithm_used" in body
@pytest.mark.timeout(300) # cold model load + retry can exceed the 180s default
async def test_admin_session_search_succeeds():
"""The same JWT-mint path works for the admin session user."""
admin_pw = os.environ["NEXTCLOUD_PASSWORD"]