test(alerts): commit the test user before the rule's created_by FK
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 7s
CI / integration (push) Successful in 2m14s

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 14:31:25 -04:00
parent 43a5325e69
commit 534ed030b8
@@ -61,11 +61,13 @@ def test_firing_triggers_ansible_action(app, tmp_path):
async def _go():
async with app.db_sessionmaker() as s:
# User must be committed before the rule's created_by FK can reference it.
async with s.begin():
s.add(User(
id=uid, username=f"u{uid[:8]}", email=f"{uid[:8]}@e.test",
password_hash="x", role=UserRole.admin, is_active=True,
))
async with s.begin():
s.add(AlertRule(
id=rule_id, name="cpu hot", source_module="host_agent",
resource_name="srv1", metric_name="cpu_pct",