Skip to content

Commit

Permalink
Remove v1 sessions table tests for web_overview
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Oct 28, 2024
1 parent ac33063 commit e49235e
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions posthog/hogql_queries/web_analytics/test/test_web_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from unittest.mock import MagicMock, patch

from freezegun import freeze_time
from parameterized import parameterized

from posthog.clickhouse.client.execute import sync_execute
from posthog.hogql.constants import LimitContext
Expand Down Expand Up @@ -72,7 +71,7 @@ def _run_web_overview_query(
self,
date_from: str,
date_to: str,
session_table_version: SessionTableVersion = SessionTableVersion.V1,
session_table_version: SessionTableVersion = SessionTableVersion.V2,
compare: bool = True,
limit_context: Optional[LimitContext] = None,
filter_test_accounts: Optional[bool] = False,
Expand All @@ -97,19 +96,16 @@ def _run_web_overview_query(
runner = WebOverviewQueryRunner(team=self.team, query=query, limit_context=limit_context)
return runner.calculate()

@parameterized.expand([[SessionTableVersion.V1], [SessionTableVersion.V2]])
def test_no_crash_when_no_data(self, session_table_version: SessionTableVersion):
def test_no_crash_when_no_data(self):
results = self._run_web_overview_query(
"2023-12-08",
"2023-12-15",
session_table_version=session_table_version,
).results
assert [item.key for item in results] == ["visitors", "views", "sessions", "session duration", "bounce rate"]

results = self._run_web_overview_query(
"2023-12-08",
"2023-12-15",
session_table_version=session_table_version,
includeLCPScore=True,
).results
assert [item.key for item in results] == [
Expand All @@ -132,9 +128,7 @@ def test_no_crash_when_no_data(self, session_table_version: SessionTableVersion)
}
],
)
results = self._run_web_overview_query(
"2023-12-08", "2023-12-15", session_table_version=session_table_version, action=action
).results
results = self._run_web_overview_query("2023-12-08", "2023-12-15", action=action).results

assert [item.key for item in results] == [
"visitors",
Expand All @@ -143,8 +137,7 @@ def test_no_crash_when_no_data(self, session_table_version: SessionTableVersion)
"conversion rate",
]

@parameterized.expand([[SessionTableVersion.V1], [SessionTableVersion.V2]])
def test_increase_in_users(self, session_table_version: SessionTableVersion):
def test_increase_in_users(self):
s1a = str(uuid7("2023-12-02"))
s1b = str(uuid7("2023-12-12"))
s2 = str(uuid7("2023-12-11"))
Expand All @@ -159,7 +152,6 @@ def test_increase_in_users(self, session_table_version: SessionTableVersion):
results = self._run_web_overview_query(
"2023-12-08",
"2023-12-15",
session_table_version=session_table_version,
).results

visitors = results[0]
Expand Down Expand Up @@ -192,8 +184,7 @@ def test_increase_in_users(self, session_table_version: SessionTableVersion):
self.assertEqual(0, bounce.previous)
self.assertEqual(None, bounce.changeFromPreviousPct)

@parameterized.expand([[SessionTableVersion.V1], [SessionTableVersion.V2]])
def test_all_time(self, session_table_version: SessionTableVersion):
def test_all_time(self):
s1a = str(uuid7("2023-12-02"))
s1b = str(uuid7("2023-12-12"))
s2 = str(uuid7("2023-12-11"))
Expand All @@ -208,7 +199,6 @@ def test_all_time(self, session_table_version: SessionTableVersion):
"all",
"2023-12-15",
compare=False,
session_table_version=session_table_version,
).results

visitors = results[0]
Expand Down Expand Up @@ -241,15 +231,12 @@ def test_all_time(self, session_table_version: SessionTableVersion):
self.assertEqual(None, bounce.previous)
self.assertEqual(None, bounce.changeFromPreviousPct)

@parameterized.expand([[SessionTableVersion.V1], [SessionTableVersion.V2]])
def test_filter_test_accounts(self, session_table_version: SessionTableVersion):
def test_filter_test_accounts(self):
s1 = str(uuid7("2023-12-02"))
# Create 1 test account
self._create_events([("test", [("2023-12-02", s1), ("2023-12-03", s1)])])

results = self._run_web_overview_query(
"2023-12-01", "2023-12-03", session_table_version=session_table_version, filter_test_accounts=True
).results
results = self._run_web_overview_query("2023-12-01", "2023-12-03", filter_test_accounts=True).results

visitors = results[0]
self.assertEqual(0, visitors.value)
Expand All @@ -267,21 +254,17 @@ def test_filter_test_accounts(self, session_table_version: SessionTableVersion):
self.assertEqual("bounce rate", bounce.key)
self.assertEqual(None, bounce.value)

@parameterized.expand([[SessionTableVersion.V1], [SessionTableVersion.V2]])
def test_dont_filter_test_accounts(self, session_table_version: SessionTableVersion):
def test_dont_filter_test_accounts(self):
s1 = str(uuid7("2023-12-02"))
# Create 1 test account
self._create_events([("test", [("2023-12-02", s1), ("2023-12-03", s1)])])

results = self._run_web_overview_query(
"2023-12-01", "2023-12-03", session_table_version=session_table_version, filter_test_accounts=False
).results
results = self._run_web_overview_query("2023-12-01", "2023-12-03", filter_test_accounts=False).results

visitors = results[0]
self.assertEqual(1, visitors.value)

@parameterized.expand([[SessionTableVersion.V1], [SessionTableVersion.V2]])
def test_correctly_counts_pageviews_in_long_running_session(self, session_table_version: SessionTableVersion):
def test_correctly_counts_pageviews_in_long_running_session(self):
# this test is important when using the v1 sessions table as the raw sessions table will have 3 entries, one per day
s1 = str(uuid7("2023-12-01"))
self._create_events(
Expand All @@ -293,7 +276,6 @@ def test_correctly_counts_pageviews_in_long_running_session(self, session_table_
results = self._run_web_overview_query(
"2023-12-01",
"2023-12-03",
session_table_version=session_table_version,
).results

visitors = results[0]
Expand Down

0 comments on commit e49235e

Please sign in to comment.