: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
test: bulk_create teams in set_recorder_script test (#57868)
Raúl Negrón-Otero04bcef4b36c9
diff --git a/posthog/management/commands/test/test_set_recorder_script.py b/posthog/management/commands/test/test_set_recorder_script.pyindex cca70a17cf66..3370e8b198c9 100644--- a/posthog/management/commands/test/test_set_recorder_script.py+++ b/posthog/management/commands/test/test_set_recorder_script.py@@ -120,8 +120,13 @@ class TestSetRecorderScriptCommand(BaseTest):assert 30 < updated_teams < 70, f"Expected roughly 50 teams updated, got {updated_teams}"def test_bulk_updates_in_batches(self):- for i in range(2500):- Team.objects.create(organization=self.organization, name=f"Team {i}")+ # Use bulk_create with a shared project to avoid 2500 individual+ # Team.objects.create() calls (each of which also creates a Project+ # in its own transaction). The test only cares that 2500 teams exist+ # for the management command to iterate over.+ Team.objects.bulk_create(+ [Team(organization=self.organization, project=self.project, name=f"Team {i}") for i in range(2500)]+ )out = StringIO()call_command(