Skip to content

Commit

Permalink
Update test_property.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Jun 20, 2024
1 parent d4660e3 commit e5dc6f5
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions ee/clickhouse/models/test/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,25 +1222,51 @@ def test_breakdown_query_expression(
{"breakdown_param_1": "$browser"},
),
('array("mat_pp_$browser") AS value', {"breakdown_param_1": "$browser"}),
),
(
["$browser", "$browser_version"],
"events",
"prop",
"properties",
"group2_properties",
(
"array(replaceRegexpAll(JSONExtractRaw(properties, %(breakdown_param_1)s), '^\"|\"$', ''),replaceRegexpAll(JSONExtractRaw(properties, %(breakdown_param_2)s), '^\"|\"$', '')) AS prop",
{"breakdown_param_1": "$browser", "breakdown_param_2": "$browser_version"},
),
(
"""array("mat_gp2_$browser",replaceRegexpAll(JSONExtractRaw(properties, %(breakdown_param_2)s), '^\"|\"$', '')) AS prop""",
{"breakdown_param_1": "$browser", "breakdown_param_2": "$browser_version"},
),
),
)
]


@pytest.mark.django_db
@pytest.mark.parametrize(
"breakdown, table, query_alias, column, materialise_column, expected_with, expected_without",
TEST_BREAKDOWN_PROCESSING_MATERIALIZED,
)
def test_breakdown_query_expression_materialised(
clean_up_materialised_columns,
breakdown: Union[str, list[str]],
table: TableWithProperties,
query_alias: Literal["prop", "value"],
column: str,
materialise_column: str,
expected_with: str,
expected_without: str,
):
from posthog.models.team import util

util.can_enable_actor_on_events = True

materialize(table, breakdown[0], table_column="properties")
actual = get_single_or_multi_property_string_expr(
breakdown,
table,
query_alias,
column,
materialised_table_column=materialise_column,
)
assert actual == expected_with

materialize(table, breakdown[0], table_column=materialise_column) # type: ignore
actual = get_single_or_multi_property_string_expr(
breakdown,
table,
query_alias,
column,
materialised_table_column=materialise_column,
)

assert actual == expected_without


@pytest.fixture
def test_events(db, team) -> list[UUID]:
return [
Expand Down

0 comments on commit e5dc6f5

Please sign in to comment.