Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Sep 25, 2023
1 parent 8721de7 commit 176bbf1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions posthog/hogql/database/test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import patch
import pytest
from django.test import override_settings
from parameterized import parameterized

from posthog.hogql.database.database import create_hogql_database, serialize_database
from posthog.test.base import BaseTest
Expand All @@ -26,6 +27,19 @@ def test_serialize_database_with_person_on_events_enabled(self):
serialized_database = serialize_database(create_hogql_database(team_id=self.team.pk))
assert json.dumps(serialized_database, indent=4) == self.snapshot

@parameterized.expand([False, True])
def test_can_select_from_each_table_at_all(self, poe_enabled: bool) -> None:
with override_settings(PERSON_ON_EVENTS_OVERRIDE=poe_enabled):
serialized_database = serialize_database(create_hogql_database(team_id=self.team.pk))
for table, possible_columns in serialized_database.items():
if table == "numbers":
continue

columns = [
x["key"] for x in possible_columns if "table" not in x and "chain" not in x and "fields" not in x
]
execute_hogql_query(f"SELECT {','.join(columns)} FROM {table}", team=self.team)

@patch("posthog.hogql.query.sync_execute", return_value=(None, None))
@pytest.mark.usefixtures("unittest_snapshot")
def test_database_with_warehouse_tables(self, patch_execute):
Expand Down

0 comments on commit 176bbf1

Please sign in to comment.