Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Dec 10, 2024
1 parent b7eee41 commit 1c900f7
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import cast
import pytest

from posthog.hogql_queries.legacy_compatibility.filter_to_query import (
Expand Down Expand Up @@ -1820,3 +1821,27 @@ def test_ignores_digit_only_keys(self):
indexes = hidden_legend_keys_to_breakdowns(hidden_legend_keys)

self.assertEqual(indexes, ["Opera"])


class TestDashboardTemplateConversion(BaseTest):
def test_trend_series_with_variables(self):
filter = {
"insight": "TRENDS",
"events": ["{VARIABLE}"],
}

query = cast(TrendsQuery, filter_to_query(filter, allow_variables=True))

self.assertEqual(query.series, ["{VARIABLE}"])

def test_retention_entities_with_variables(self):
filter = {
"insight": "RETENTION",
"target_entity": "{VARIABLE1}",
"returning_entity": "{VARIABLE2}",
}

query = cast(RetentionQuery, filter_to_query(filter, allow_variables=True))

self.assertEqual(query.retentionFilter.targetEntity, "{VARIABLE1}")
self.assertEqual(query.retentionFilter.returningEntity, "{VARIABLE2}")

0 comments on commit 1c900f7

Please sign in to comment.