forked from retoor/devplacepy
ticket #7 attempt 1
This commit is contained in:
@@ -39,6 +39,7 @@ def _seed_done_session(owner_id="ds-session-owner"):
|
||||
"source_diversity": 0.5,
|
||||
"page_count": 3,
|
||||
"chunk_count": 12,
|
||||
"cost_usd": 0.123456,
|
||||
}
|
||||
result = {
|
||||
"query": "the question",
|
||||
@@ -47,6 +48,7 @@ def _seed_done_session(owner_id="ds-session-owner"):
|
||||
"source_diversity": 0.5,
|
||||
"page_count": 3,
|
||||
"chunk_count": 12,
|
||||
"cost_usd": 0.123456,
|
||||
"report": report,
|
||||
}
|
||||
get_table("jobs").update(
|
||||
@@ -97,6 +99,7 @@ def test_session_json_shape(app_server):
|
||||
assert body["sources"]
|
||||
assert "viewer_is_admin" in body
|
||||
assert "viewer_owns" in body
|
||||
assert body.get("cost_usd") is None # guest user, not admin
|
||||
finally:
|
||||
_clear()
|
||||
|
||||
@@ -108,6 +111,7 @@ def test_session_html_renders_without_jinja_global_collision(app_server):
|
||||
assert r.status_code == 200, r.text
|
||||
assert "the question" in r.text
|
||||
assert "dp-deepsearch-chat" in r.text
|
||||
assert "0.123456" not in r.text # guest user, cost hidden
|
||||
finally:
|
||||
_clear()
|
||||
|
||||
@@ -142,6 +146,7 @@ def test_session_reads_disk_report_before_result_commit(app_server):
|
||||
"synthesis": "agents",
|
||||
"page_count": 12,
|
||||
"chunk_count": 61,
|
||||
"cost_usd": 0.123456,
|
||||
}
|
||||
session_dir = DEEPSEARCH_DIR / uid
|
||||
session_dir.mkdir(parents=True, exist_ok=True)
|
||||
@@ -203,3 +208,26 @@ def test_export_json(app_server):
|
||||
def test_export_unknown_uid_404(app_server):
|
||||
r = requests.get(f"{BASE_URL}/tools/deepsearch/nope/export.md")
|
||||
assert r.status_code == 404
|
||||
|
||||
|
||||
def test_session_admin_sees_cost(app_server, seeded_db):
|
||||
try:
|
||||
uid = _seed_done_session("alice_test")
|
||||
s = requests.Session()
|
||||
creds = seeded_db["alice"]
|
||||
s.post(
|
||||
f"{BASE_URL}/auth/login",
|
||||
data={"email": creds["email"], "password": creds["password"]},
|
||||
allow_redirects=True,
|
||||
)
|
||||
r = s.get(f"{BASE_URL}/tools/deepsearch/{uid}/session", headers=_json_headers())
|
||||
assert r.status_code == 200, r.text
|
||||
body = r.json()
|
||||
assert body.get("cost_usd") == 0.123456
|
||||
|
||||
html = s.get(f"{BASE_URL}/tools/deepsearch/{uid}/session")
|
||||
assert html.status_code == 200, html.text
|
||||
assert "0.123456" in html.text
|
||||
assert "cost" in html.text
|
||||
finally:
|
||||
_clear()
|
||||
|
||||
Reference in New Issue
Block a user