The Suggestions page: the support agent's draft replies (~/aimsight-support), read-only from Supabase Conversations (table and bucket suggestions): status, reason, the reply to copy and its figures to download; SUPABASE_CONVERSATIONS_* from the app's .env (the service's EnvironmentFile); nothing is sent from the app
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54bcce1281
commit
f0470295fa
6 files changed
+170
-4
No files matched your search
+35
-1
@@ -448,8 +448,42 @@ def check_points():
|
||||
validity.points.FOLDER = before
|
||||
|
||||
|
||||
def check_suggestions():
|
||||
# the Suggestions page (suggestions.py): the support agent's rows read from Supabase Conversations, mocked here
|
||||
import suggestions
|
||||
saved = {k: os.environ.pop(k, None) for k in ("SUPABASE_CONVERSATIONS_URL", "SUPABASE_CONVERSATIONS_KEY")}
|
||||
real_get = suggestions._get
|
||||
try:
|
||||
assert "SUPABASE_CONVERSATIONS" in refuses(suggestions.list_suggestions)
|
||||
os.environ.update(SUPABASE_CONVERSATIONS_URL="https://x.supabase.co", SUPABASE_CONVERSATIONS_KEY="k")
|
||||
asked = []
|
||||
|
||||
def fake(path):
|
||||
asked.append(path)
|
||||
if path.startswith("/rest/v1/suggestions"):
|
||||
return json.dumps([{"id": 12, "conversation_uuid": "c1", "status": "ready", "reply": "Bonjour",
|
||||
"figures": [{"path": "12/1.png", "caption": "glare"}]}]).encode()
|
||||
if path.startswith("/rest/v1/conversations"):
|
||||
return json.dumps([{"uuid": "c1", "reference_number": "151", "subject": "Crissier"}]).encode()
|
||||
return b"png"
|
||||
suggestions._get = fake
|
||||
rows = suggestions.list_suggestions()
|
||||
assert rows[0]["reference"] == "151" and rows[0]["subject"] == "Crissier" and rows[0]["reply"] == "Bonjour", rows
|
||||
refuses(suggestions.figure, "../x")
|
||||
refuses(suggestions.figure, "1/a.png")
|
||||
assert suggestions.figure("12/1.png") == b"png" and asked[-1] == "/storage/v1/object/suggestions/12/1.png", asked
|
||||
r = server.suggestion_figure("12/1.png")
|
||||
assert r.media_type == "image/png" and r.headers["x-content-type-options"] == "nosniff"
|
||||
finally:
|
||||
suggestions._get = real_get
|
||||
for k, v in saved.items():
|
||||
os.environ.pop(k, None)
|
||||
if v is not None:
|
||||
os.environ[k] = v
|
||||
|
||||
|
||||
CHECKS = [check_server, check_station, check_optimization, check_analysis, check_validation, check_support, check_conversations,
|
||||
check_points]
|
||||
check_points, check_suggestions]
|
||||
|
||||
if __name__ == "__main__":
|
||||
name = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
|
||||
Reference in new issue
Block a user