Skip to content

Commit

Permalink
chore(experiments): Test cleanup (#27090)
Browse files Browse the repository at this point in the history
Co-authored-by: Juraj Majerik <[email protected]>
  • Loading branch information
danielbachhuber and jurajmajerik authored Dec 23, 2024
1 parent ca73fa2 commit c2b4798
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit c2b4798

Please sign in to comment.