Skip to content

Commit

Permalink
Update test_insight_cache.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed May 23, 2024
1 parent ee7e7c0 commit 8fa0b5f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions posthog/caching/test/test_insight_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ def create_insight_caching_state(
**kw,
):
with mute_selected_signals():
with override_settings(HOGQL_INSIGHTS_OVERRIDE=False):
# HogQL-based insights handle caching fully inside query runners,
# so the tests in this file only pertain to the legacy engine
insight = create_insight(team, user, filters=filters)
insight = create_insight(team, user, filters=filters)

upsert(team, insight)

Expand Down Expand Up @@ -133,6 +130,9 @@ def test_fetch_states_in_need_of_updating(team: Team, user: User, params, expect

@pytest.mark.django_db
@freeze_time("2020-01-04T13:01:01Z")
@override_settings(
HOGQL_INSIGHTS_OVERRIDE=False # get_safe_cache is too low-level for HogQL, which serializes differently
)
def test_update_cache(team: Team, user: User, cache):
caching_state = create_insight_caching_state(team, user, refresh_attempt=1)

Expand Down Expand Up @@ -170,9 +170,11 @@ def test_update_cache_updates_identical_cache_keys(team: Team, user: User, cache
@pytest.mark.django_db
@freeze_time("2020-01-04T13:01:01Z")
@patch("posthog.caching.insight_cache.update_cache_task")
@patch("posthog.caching.insight_cache.calculate_for_filter_based_insight", side_effect=Exception())
@patch("posthog.caching.insight_cache.process_query_dict", side_effect=Exception()) # HogQL branch
@patch("posthog.caching.insight_cache.calculate_for_filter_based_insight", side_effect=Exception()) # Legacy branch
def test_update_cache_when_calculation_fails(
spy_calculate_for_filter_based_insight,
spy_process_query_dict,
spy_update_cache_task,
team: Team,
user: User,
Expand Down

0 comments on commit 8fa0b5f

Please sign in to comment.