The demo account — one shared user that whitelisted emails entered from the login page, reset on a schedule — goes end to end (owner decision, E34): demo.py and the reset job, users.is_demo and demo_whitelist (migration 0098 deletes the demo user, its audit rows, the reset job's override and notices, then drops the column and table; the downgrade restores the empty schema), the /auth/demo entry, the admin whitelist and reset, the Demo tab, the banner, the login page's "Try the demo", and every is_demo branch in routes, userscope, scheduler and the UI. require_human only ever refused the demo account, so its 87 uses become current_user (owner-approved); require_write_scope keeps its own check. The login page's "or" divider now shows only beside the Google button: without the demo entry under it, an instance without Google would have said "or" to nothing. A contract test (removedFeatures) fails on the word anywhere in the backend, frontend, e2e or scripts — seen red on a planted hit. Size ceilings tightened for the modules that shrank; admin.py is back under the limit.
31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
"""E30: an admin action that counts something keeps the count as data in its audit row's `after`, under
|
|
the key the audit log names in the reader's language (`scheduler.result.<key>`, frontend
|
|
auditColumns.tsx) — not only in the English `summary`. A renamed key would fall back to the raw word.
|
|
DB lane (Postgres).
|
|
"""
|
|
|
|
from sqlalchemy import select
|
|
|
|
from app.models import AuditLog
|
|
|
|
|
|
def _after(db, action: str) -> dict:
|
|
db.expire_all()
|
|
return db.execute(select(AuditLog.after).where(AuditLog.action == action)).scalar_one()
|
|
|
|
|
|
def test_clearing_the_audit_log_keeps_the_count_as_data(as_user, db, make_user):
|
|
admin = make_user(email="boss@example.com", role="admin")
|
|
db.add_all([AuditLog(action="sync_pause"), AuditLog(action="sync_resume")])
|
|
db.commit()
|
|
assert as_user(admin).delete("/api/admin/audit").json()["cleared"] == 2
|
|
assert _after(db, "audit_clear") == {"cleared": 2}
|
|
|
|
|
|
def test_a_discovery_purge_keeps_its_counts_as_data(as_user, db, make_user):
|
|
admin = make_user(email="boss@example.com", role="admin")
|
|
body = as_user(admin).post("/api/admin/purge-discovery").json()
|
|
body.pop("ok")
|
|
assert _after(db, "discovery_purge") == body
|
|
assert {"videos_deleted", "channels_deleted", "search_videos_deleted"} <= set(body)
|