Explorar o código

TG-28 TG-31: Add DB drop utility, API verification script, update project commit protocol docs, secure users.txt from tracking

FerRo988 hai 4 semanas
pai
achega
a77dd593e1
Modificáronse 4 ficheiros con 47 adicións e 0 borrados
  1. BIN=BIN
      .gitignore
  2. 1 0
      PROJECT_CONTEXT.md
  3. 44 0
      api_verify.py
  4. 2 0
      drop_foods.py

BIN=BIN
.gitignore


+ 1 - 0
PROJECT_CONTEXT.md

@@ -34,6 +34,7 @@ LocalFoodAI is a local food AI that provides full nutritional value information
 - **Review Policy:** "Request Review" (Antigravity must not auto-proceed). User must approve Python/DB logic.
 - **Commit Format:** Every commit message must start with `TG-<task_id>: <description>`.
 - **Taiga-Gogs Integration:** Webhooks track progress via commit messages.
+- **Task Completion Protocol:** When a task finishes: 1) Ask the user for permission to commit/push. 2) Push to Git. 3) Attach a proof-of-work file (like a video recording or documentation `.zip`) to the specific Taiga task.
 
 ## 4. Documentation Requirements (For Final Grade)
 - **Technical Document:** Installation/config guide, tech stack explanation, LLM selection rationale, diagram of local communication, proof of 100% data privacy.

+ 44 - 0
api_verify.py

@@ -0,0 +1,44 @@
+import time
+import httpx
+import asyncio
+import json
+
+async def run_tests():
+    url = "http://127.0.0.1:8000"
+    
+    async with httpx.AsyncClient() as client:
+        # Create test user for token
+        try:
+            await client.post(f"{url}/api/register", json={"username":"validator","password":"pwdtest123","confirmPassword":"pwdtest123"})
+        except:
+            pass
+        
+        res = await client.post(f"{url}/api/login", json={"username":"validator","password":"pwdtest123"})
+        token = res.json().get("token", "")
+        headers = {"Authorization": f"Bearer {token}"}
+        
+        print("=== TEST 1: Empty Query ===")
+        t0 = time.perf_counter()
+        r1 = await client.get(f"{url}/api/food/search?q=", headers=headers)
+        t1 = time.perf_counter()
+        print(f"Timing: {(t1-t0)*1000:.2f} ms")
+        print(f"Payload snippet: {r1.text[:100]}")
+        
+        print("\n=== TEST 2: Single Letter ('c') ===")
+        t0 = time.perf_counter()
+        r2 = await client.get(f"{url}/api/food/search?q=c", headers=headers)
+        t1 = time.perf_counter()
+        print(f"Timing: {(t1-t0)*1000:.2f} ms")
+        res2 = r2.json().get('results', [])
+        print(f"Returned Items: {len(res2)}")
+        if res2: 
+            print(f"Expected Field Verification: {list(res2[0].keys())}")
+        
+        print("\n=== TEST 3: No Match ('xyzabcd') ===")
+        t0 = time.perf_counter()
+        r3 = await client.get(f"{url}/api/food/search?q=xyzabcd", headers=headers)
+        t1 = time.perf_counter()
+        print(f"Timing: {(t1-t0)*1000:.2f} ms")
+        print(f"Response: {r3.json()}")
+
+asyncio.run(run_tests())

+ 2 - 0
drop_foods.py

@@ -0,0 +1,2 @@
+import sqlite3
+sqlite3.connect('/home/roni/LocalFoodAI/localfood.db').execute('DROP TABLE IF EXISTS foods')