From c2b47986e32428517f407f64808af3c3de2222d8 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Mon, 23 Dec 2024 04:37:45 -0800 Subject: [PATCH] chore(experiments): Test cleanup (#27090) Co-authored-by: Juraj Majerik --- .../test_experiment_trends_query_runner.py | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py b/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py index fef6608fb62ef..69cfc5720e009 100644 --- a/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py +++ b/posthog/hogql_queries/experiments/test/test_experiment_trends_query_runner.py @@ -91,8 +91,12 @@ def create_experiment( feature_flag = self.create_feature_flag(name) if start_date is None: start_date = timezone.now() + else: + start_date = timezone.make_aware(start_date) # Make naive datetime timezone-aware if end_date is None: end_date = timezone.now() + timedelta(days=14) + elif end_date is not None: + end_date = timezone.make_aware(end_date) # Make naive datetime timezone-aware return Experiment.objects.create( name=name, team=self.team, @@ -147,7 +151,6 @@ def create_data_warehouse_table_with_payments(self): filesystem=fs, use_dictionary=True, compression="snappy", - version="2.0", ) table_name = "payments" @@ -212,7 +215,6 @@ def create_data_warehouse_table_with_usage(self): filesystem=fs, use_dictionary=True, compression="snappy", - version="2.0", ) table_name = "usage" @@ -1491,15 +1493,15 @@ def test_query_runner_standard_flow(self): self.assertEqual(control_variant.absolute_exposure, 2) self.assertEqual(test_variant.absolute_exposure, 2) - self.assertAlmostEqual(result.credible_intervals["control"][0], 0.5449, places=3) - self.assertAlmostEqual(result.credible_intervals["control"][1], 4.3836, places=3) - self.assertAlmostEqual(result.credible_intervals["test"][0], 1.1009, places=3) - self.assertAlmostEqual(result.credible_intervals["test"][1], 5.8342, places=3) + self.assertAlmostEqual(result.credible_intervals["control"][0], 0.5449, delta=0.1) + self.assertAlmostEqual(result.credible_intervals["control"][1], 4.3836, delta=0.1) + self.assertAlmostEqual(result.credible_intervals["test"][0], 1.1009, delta=0.1) + self.assertAlmostEqual(result.credible_intervals["test"][1], 5.8342, delta=0.1) - self.assertAlmostEqual(result.p_value, 1.0, places=3) + self.assertAlmostEqual(result.p_value, 1.0, delta=0.1) - self.assertAlmostEqual(result.probability["control"], 0.2549, places=2) - self.assertAlmostEqual(result.probability["test"], 0.7453, places=2) + self.assertAlmostEqual(result.probability["control"], 0.2549, delta=0.1) + self.assertAlmostEqual(result.probability["test"], 0.7453, delta=0.1) self.assertEqual(result.significance_code, ExperimentSignificanceCode.NOT_ENOUGH_EXPOSURE) @@ -1614,15 +1616,15 @@ def test_query_runner_standard_flow_v2_stats(self): self.assertEqual(control_variant.absolute_exposure, 2) self.assertEqual(test_variant.absolute_exposure, 2) - self.assertAlmostEqual(result.credible_intervals["control"][0], 0.3633, places=3) - self.assertAlmostEqual(result.credible_intervals["control"][1], 2.9224, places=3) - self.assertAlmostEqual(result.credible_intervals["test"][0], 0.7339, places=3) - self.assertAlmostEqual(result.credible_intervals["test"][1], 3.8894, places=3) + self.assertAlmostEqual(result.credible_intervals["control"][0], 0.3633, delta=0.1) + self.assertAlmostEqual(result.credible_intervals["control"][1], 2.9224, delta=0.1) + self.assertAlmostEqual(result.credible_intervals["test"][0], 0.7339, delta=0.1) + self.assertAlmostEqual(result.credible_intervals["test"][1], 3.8894, delta=0.1) - self.assertAlmostEqual(result.p_value, 1.0, places=3) + self.assertAlmostEqual(result.p_value, 1.0, delta=0.1) - self.assertAlmostEqual(result.probability["control"], 0.2549, places=2) - self.assertAlmostEqual(result.probability["test"], 0.7453, places=2) + self.assertAlmostEqual(result.probability["control"], 0.2549, delta=0.1) + self.assertAlmostEqual(result.probability["test"], 0.7453, delta=0.1) self.assertEqual(result.significance_code, ExperimentSignificanceCode.NOT_ENOUGH_EXPOSURE)