mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
- Added comprehensive anti-stub test suite that detects: - TODO/FIXME/STUB/FAKE/UNFINISHED patterns - Empty functions with only pass/ellipsis - NotImplementedError raises - Mock implementations in production - Debug prints in production - Skipped tests - Created strict GitHub Actions workflow that: - BLOCKS deployment if ANY forbidden patterns found - Requires ALL tests to pass (no skips allowed) - Runs security scans - Verifies all functions are implemented - Only allows PyPI publish after ALL checks pass - Added pre-commit hooks to catch issues locally before push - Updated Makefile with 'make check' that runs all quality gates - Fixed stub function issue in tools/__init__.py This ensures we NEVER deploy incomplete or stub code to production again!
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Simple mock server for testing cache endpoints."""
|
|
|
|
import sys
|
|
import json
|
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
|
|
|
|
class MockHandler(BaseHTTPRequestHandler):
|
|
def do_GET(self):
|
|
if self.path == "/cache/ping":
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "application/json")
|
|
self.end_headers()
|
|
response = {
|
|
"status": "healthy",
|
|
"cache_type": "redis",
|
|
"ping_response": True,
|
|
"set_cache_response": None,
|
|
"llm_cache_params": None,
|
|
"health_check_cache_params": None,
|
|
}
|
|
self.wfile.write(json.dumps(response).encode())
|
|
else:
|
|
self.send_response(404)
|
|
self.end_headers()
|
|
|
|
def do_POST(self):
|
|
if self.path == "/cache/delete":
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "application/json")
|
|
self.end_headers()
|
|
self.wfile.write(b"{}")
|
|
elif self.path == "/cache/flushall":
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "application/json")
|
|
self.end_headers()
|
|
self.wfile.write(b"{}")
|
|
else:
|
|
self.send_response(404)
|
|
self.end_headers()
|
|
|
|
def log_message(self, format, *args):
|
|
pass # Suppress logs
|
|
|
|
|
|
if __name__ == "__main__":
|
|
server = HTTPServer(("127.0.0.1", 4010), MockHandler)
|
|
print("Mock server running on http://127.0.0.1:4010")
|
|
print("Press Ctrl+C to stop")
|
|
try:
|
|
server.serve_forever()
|
|
except KeyboardInterrupt:
|
|
print("\nStopping server...")
|
|
sys.exit(0)
|