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.

fix(test): Use assertIn with individual values (#67130)

mendral-app[bot]ce110527aab7
diff --git a/ee/hogai/chat_agent/query_planner/test/test_toolkit.py b/ee/hogai/chat_agent/query_planner/test/test_toolkit.py
index d9a9dbccaa6f..69cf3a753b0e 100644
--- a/ee/hogai/chat_agent/query_planner/test/test_toolkit.py
+++ b/ee/hogai/chat_agent/query_planner/test/test_toolkit.py
@@ -1,4 +1,4 @@
-from datetime import UTC, datetime
+from datetime import UTC, datetime, timedelta
from textwrap import dedent
from freezegun import freeze_time
@@ -138,25 +138,29 @@ class TestTaxonomyAgentToolkit(ClickhouseTestMixin, APIBaseTest):
team=self.team, type=PropertyDefinition.Type.PERSON, name="id", property_type=PropertyType.Numeric
)
+ # The persons HogQL table excludes rows with created_at >= now() + 1 day (see
+ # select_from_persons_table in posthog/hogql/database/schema/persons.py), so timestamps
+ # must stay in the real past. Anchor to the real clock and space out by minutes so each
+ # person sorts deterministically by created_at regardless of when the test runs.
+ base_time = datetime.now(UTC)
for i in range(25):
id = f"person{i}"
- with freeze_time(f"2024-01-01T00:{i}:00Z"):
+ with freeze_time(base_time - timedelta(minutes=25 - i)):
_create_person(
distinct_ids=[id],
properties={"taxonomy_email": f"{id}@example.com", "id": i},
team=self.team,
)
- with freeze_time(f"2024-01-02T00:00:00Z"):
+ with freeze_time(base_time):
_create_person(
distinct_ids=["person25"],
properties={"taxonomy_email": "[email protected]", "id": 25},
team=self.team,
)
- self.assertIn(
- toolkit.retrieve_entity_property_values("person", "taxonomy_email"),
- )
+ result = toolkit.retrieve_entity_property_values("person", "taxonomy_email")
+ self.assertIn(person, result)
self.assertIn(
"1 more distinct value",
toolkit.retrieve_entity_property_values("person", "id"),