: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
chore(marketing-analytics): run conversion goal util tests without a database (#107381)
posthog[bot]191d39696f6c
diff --git a/products/marketing_analytics/backend/hogql_queries/test_utils.py b/products/marketing_analytics/backend/hogql_queries/test_utils.pyindex e8e98c5ca247..db09e509b9a0 100644--- a/products/marketing_analytics/backend/hogql_queries/test_utils.py+++ b/products/marketing_analytics/backend/hogql_queries/test_utils.py@@ -1,6 +1,6 @@from typing import Any-from posthog.test.base import BaseTest+from django.test import SimpleTestCasefrom parameterized import parameterizedfrom pydantic import (@@ -60,8 +60,10 @@ DATA_WAREHOUSE_NODE_GOAL_WITHOUT_ID_FIELD: dict[str, Any] = {"schema_map": {},}+TEAM_PK = 0-class TestConvertTeamConversionGoalsToObjects(BaseTest):++class TestConvertTeamConversionGoalsToObjects(SimpleTestCase):@parameterized.expand([("events_node_with_dw_fields", EVENTS_NODE_GOAL_WITH_DW_FIELDS, ConversionGoalFilter1),@@ -75,14 +77,14 @@ class TestConvertTeamConversionGoalsToObjects(BaseTest):])def test_converts_goal_to_expected_filter(self, _name, goal, expected_type):- result = convert_team_conversion_goals_to_objects([goal], self.team.pk)+ result = convert_team_conversion_goals_to_objects([goal], TEAM_PK)self.assertEqual(len(result), 1)self.assertIsInstance(result[0], expected_type)self.assertEqual(result[0].conversion_goal_id, goal["conversion_goal_id"])def test_data_warehouse_node_derives_id_field_from_distinct_id_field(self):- result = convert_team_conversion_goals_to_objects([DATA_WAREHOUSE_NODE_GOAL_WITHOUT_ID_FIELD], self.team.pk)+ result = convert_team_conversion_goals_to_objects([DATA_WAREHOUSE_NODE_GOAL_WITHOUT_ID_FIELD], TEAM_PK)self.assertEqual(len(result), 1)goal = result[0]@@ -102,7 +104,7 @@ class TestConvertTeamConversionGoalsToObjects(BaseTest):"schema_map": {},}- self.assertEqual(convert_team_conversion_goals_to_objects([goal_without_id], self.team.pk), [])+ self.assertEqual(convert_team_conversion_goals_to_objects([goal_without_id], TEAM_PK), [])with self.assertRaises(PydanticValidationError) as caught:TypeAdapter(MarketingAnalyticsConversionGoalList).validate_python([goal_without_id])@@ -114,7 +116,7 @@ class TestConvertTeamConversionGoalsToObjects(BaseTest):)def test_events_node_drops_data_warehouse_fields(self):- result = convert_team_conversion_goals_to_objects([EVENTS_NODE_GOAL_WITH_DW_FIELDS], self.team.pk)+ result = convert_team_conversion_goals_to_objects([EVENTS_NODE_GOAL_WITH_DW_FIELDS], TEAM_PK)self.assertEqual(len(result), 1)goal = result[0]