Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(subscriptions): fix async db access in delivery record test (#115890)

Thomas Obermüller2ad2e34e1562
diff --git a/posthog/temporal/tests/test_subscriptions_workflows.py b/posthog/temporal/tests/test_subscriptions_workflows.py
index 5cf9b446119c..4483b1572433 100644
--- a/posthog/temporal/tests/test_subscriptions_workflows.py
+++ b/posthog/temporal/tests/test_subscriptions_workflows.py
@@ -1205,9 +1205,11 @@ async def test_create_delivery_record_persists_row_and_idempotency_key_dedupes(t
insight = await sync_to_async(Insight.objects.create)(team=team, short_id="delrec01", name="Delivery record")
subscription = await sync_to_async(create_subscription)(team=team, insight=insight, created_by=user)
context_dashboard = await sync_to_async(Dashboard.objects.create)(team=team, name="Context dashboard")
- await sync_to_async(SubscriptionContext.objects.for_team(team.id).create)(
- team_id=team.id, subscription=subscription, dashboard=context_dashboard
- )
+ await sync_to_async(
+ lambda: SubscriptionContext.objects.for_team(team.id).create(
+ team_id=team.id, subscription=subscription, dashboard=context_dashboard
+ )
+ )()
env = ActivityEnvironment()
inputs = CreateDeliveryRecordInputs(