From 937704c74692cc6830c17c99e8bdf82e646ad565 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Fri, 31 Jul 2026 09:13:09 -0400 Subject: [PATCH] test: move live API probe out of unit discovery --- backend/scripts/check_api.py | 35 +++++++++++++++++++++++++++++++++++ backend/tests/test_api.py | 17 ----------------- 2 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 backend/scripts/check_api.py delete mode 100644 backend/tests/test_api.py diff --git a/backend/scripts/check_api.py b/backend/scripts/check_api.py new file mode 100644 index 0000000..1333cbf --- /dev/null +++ b/backend/scripts/check_api.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +"""Manually probe an already-running SuperBrain API instance. + +This is intentionally a command-line diagnostic rather than a unit test: it +needs the local runtime token and a server listening on the requested address. +""" + +import argparse +import json +from pathlib import Path + +import requests + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument("--base-url", default="http://localhost:5000") + args = parser.parse_args() + + token_path = Path(__file__).resolve().parent.parent / "token.txt" + if not token_path.is_file(): + raise SystemExit(f"Token file not found: {token_path}") + + response = requests.get( + f"{args.base_url.rstrip('/')}/recent?limit=10", + headers={"X-API-Key": token_path.read_text(encoding="utf-8").strip()}, + timeout=10, + ) + print(f"Status Code: {response.status_code}") + print(json.dumps(response.json(), indent=2)) + return 0 if response.ok else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/backend/tests/test_api.py b/backend/tests/test_api.py deleted file mode 100644 index 24b4567..0000000 --- a/backend/tests/test_api.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 -import requests -import json - -# Read token -with open('token.txt', 'r') as f: - token = f.read().strip() - -# Test the /recent endpoint -response = requests.get( - 'http://localhost:5000/recent?limit=10', - headers={'X-API-Key': token} -) - -print(f"Status Code: {response.status_code}") -print(f"\nResponse:") -print(json.dumps(response.json(), indent=2))