Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Apr 16, 2024
1 parent 8148b11 commit f1a2f78
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions posthog/hogql/database/schema/test/test_cohort_people.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from posthog.hogql.parser import parse_select
from posthog.hogql.query import execute_hogql_query
from posthog.models import Person, Cohort
from posthog.test.base import (
APIBaseTest,
ClickhouseTestMixin,
)


class TestCohortPeopleTable(ClickhouseTestMixin, APIBaseTest):
def test_select_star(self):
Person.objects.create(
team_id=self.team.pk,
distinct_ids=["1"],
properties={"$some_prop": "something", "$another_prop": "something1"},
)
Person.objects.create(
team_id=self.team.pk,
distinct_ids=["2"],
properties={"$some_prop": "something", "$another_prop": "something2"},
)
cohort1 = Cohort.objects.create(
team=self.team,
groups=[
{
"properties": [
{"key": "$some_prop", "value": "something", "type": "person"},
]
}
],
name="cohort1",
)
cohort1.calculate_people_ch(pending_version=0)

response = execute_hogql_query(
parse_select(
"select *, person.properties.$another_prop from cohort_people order by person.properties.$another_prop"
),
self.team,
)
assert response.columns == ["person_id", "cohort_id", "$another_prop"]
assert len(response.results) == 2
assert response.results[0][2] == "something1"
assert response.results[1][2] == "something2"

0 comments on commit f1a2f78

Please sign in to comment.