Skip to content

Commit

Permalink
Add some HOGQL_INSIGHTS_OVERRIDE overrides in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed May 22, 2024
1 parent e8e59c6 commit 1f2469c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions posthog/api/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ def create(self, validated_data: dict[str, Any], **kwargs) -> Team:

return team

def _clear_team_insight_cache(self, team: Team) -> None:
# :KLUDGE: This is incorrect as it doesn't wipe caches not currently linked to insights. Fix this some day!
def _handle_timezone_update(self, team: Team) -> None:
# TODO: Remove when legacy insight calculation is no more,
# as the HogQL backend's caching always includes timezone in the cache key
hashes = InsightCachingState.objects.filter(team=team).values_list("cache_key", flat=True)
cache.delete_many(hashes)

Expand Down
2 changes: 2 additions & 0 deletions posthog/api/test/dashboards/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def test_shared_dashboard(self):
response = self.client.get("/shared_dashboard/testtoken")
self.assertEqual(response.status_code, status.HTTP_200_OK)

@override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # .../insights/trend/ can't run in HogQL yet
def test_return_cached_results_bleh(self):
dashboard = Dashboard.objects.create(team=self.team, name="dashboard")
filter_dict = {
Expand Down Expand Up @@ -930,6 +931,7 @@ def test_duplication_fail_for_different_team(self):
expected_status=status.HTTP_400_BAD_REQUEST,
)

@override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # .../insights/trend/ can't run in HogQL yet
def test_return_cached_results_dashboard_has_filters(self):
# Regression test, we were

Expand Down
1 change: 1 addition & 0 deletions posthog/api/test/test_insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ def test_save_new_funnel(self) -> None:
self.assertEqual(objects[0].filters["layout"], "horizontal")
self.assertEqual(len(objects[0].short_id), 8)

@override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # synchronously_update_cache is a legacy-only code path
@patch("posthog.api.insight.synchronously_update_cache", wraps=synchronously_update_cache)
def test_insight_refreshing_legacy(self, spy_update_insight_cache) -> None:
dashboard_id, _ = self.dashboard_api.create_dashboard({"filters": {"date_from": "-14d"}})
Expand Down
2 changes: 2 additions & 0 deletions posthog/api/test/test_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from asgiref.sync import sync_to_async
from django.core.cache import cache
from django.http import HttpResponse
from django.test import override_settings
from freezegun import freeze_time
from parameterized import parameterized
from rest_framework import status
Expand Down Expand Up @@ -503,6 +504,7 @@ def test_cant_set_primary_dashboard_to_another_teams_dashboard(self):
response_data = response.json()
self.assertEqual(response_data["primary_dashboard"], None)

@override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # .../insights/trend/ can't run in HogQL yet
def test_update_timezone_remove_cache(self):
# Seed cache with some insights
self.client.post(
Expand Down

0 comments on commit 1f2469c

Please sign in to comment.