test: e2e + unit tests for supervisor, proxy, and feature flags

- test_supervisor.py: 28 tests covering load_workflows, resolve_schedule,
  is_due, topological_waves, and proxy round-robin / sticky selection
- test_feature_flags.py: 31 tests covering migration 0019, is_flag_enabled,
  feature_gate decorator, admin toggle routes, and full toggle e2e flows
- conftest.py: seed feature flags with production defaults (markets=1,
  others=0) so all routes behave consistently in tests
- Fix is_flag_enabled bug: replace non-existent db.execute_fetchone()
  with fetch_one() helper
- Update 4 test_waitlist / test_businessplan tests that relied on
  WAITLIST_MODE patches — now enable the relevant DB flag instead

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-23 15:26:40 +01:00
parent a1faddbed6
commit b5c9a4e573
6 changed files with 770 additions and 31 deletions

View File

@@ -704,13 +704,12 @@ async def is_flag_enabled(name: str, default: bool = False) -> bool:
Reads from the feature_flags table. Flags are toggled via the admin UI
and take effect immediately — no restart needed.
"""
db = await get_db()
row = await db.execute_fetchone(
row = await fetch_one(
"SELECT enabled FROM feature_flags WHERE name = ?", (name,)
)
if row is None:
return default
return bool(row[0])
return bool(row["enabled"])
def feature_gate(flag_name: str, waitlist_template: str, **extra_context):