: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(posthog-ai): move the context-now pin test off the database tier (#116896)
posthog[bot]22f49099bfb5
diff --git a/products/posthog_ai/scripts/hogql_example/test/test_hogql_example.py b/products/posthog_ai/scripts/hogql_example/test/test_hogql_example.pyindex 806e0269fa00..43ea32741169 100644--- a/products/posthog_ai/scripts/hogql_example/test/test_hogql_example.py+++ b/products/posthog_ai/scripts/hogql_example/test/test_hogql_example.py@@ -59,17 +59,6 @@ class TestRenderHogQLExample(BaseTest):assert "2025-12-10" in resultassert "2025-12-03" in result- def test_pins_context_now_as_well_as_the_date_range(self) -> None:- # Some runners resolve sub-ranges off `context.now` rather than off query_date_range, so- # both surfaces have to be pinned. A stub stands in for the runner because the branch is- # generic: reaching it through a real query kind ties this suite to whichever product- # owns that kind, and the trends case above already covers the pipeline end to end.- runner = SimpleNamespace(context=SimpleNamespace(now=None))-- hogql_example_module._pin_runner_now(runner, hogql_example_module._FROZEN_DATETIME)-- assert runner.context.now == hogql_example_module._FROZEN_DATETIME-@patch("django.conf.settings.DEBUG", True)def test_render_does_not_mock_the_global_clock(self) -> None:# Clock mocking is process-global, so a freeze here hands concurrent Temporal@@ -107,6 +96,17 @@ class TestRenderHogQLExample(BaseTest):class TestRenderHogQLExampleMocked:"""Cheap mock-based tests for control-flow branches that don't need a DB."""+ def test_pins_context_now_as_well_as_the_date_range(self) -> None:+ # Some runners resolve sub-ranges off `context.now` rather than off query_date_range, so+ # both surfaces have to be pinned. A stub stands in for the runner because the branch is+ # generic: reaching it through a real query kind ties this suite to whichever product+ # owns that kind, and the trends case above already covers the pipeline end to end.+ runner = SimpleNamespace(context=SimpleNamespace(now=None))++ hogql_example_module._pin_runner_now(runner, hogql_example_module._FROZEN_DATETIME)++ assert runner.context.now == hogql_example_module._FROZEN_DATETIME+@patch("posthog.hogql.printer.utils.to_printed_hogql", return_value="SELECT 1")@patch("posthog.hogql.filters.replace_filters")@patch("posthog.hogql_queries.query_runner.get_query_runner")