def test_calculate_bucket_value(self):
        experiment = create_simple_experiment()
        experiment.num_buckets = 1000
        self.assertEqual(experiment._calculate_bucket("t2_1"), long(867))

        seeded_cfg = {
            "id": 1,
            "name": "test_experiment",
            "owner": "test",
            "type": "single_variant",
            "version": "1",
            "start_ts": time.time() - THIRTY_DAYS,
            "stop_ts": time.time() + THIRTY_DAYS,
            "enabled": True,
            "experiment": {
                "variants": [
                    {
                        "name": "variant_1",
                        "size": 0.1,
                    },
                    {
                        "name": "variant_2",
                        "size": 0.1,
                    },
                ],
                "experiment_version":
                1,
                "shuffle_version":
                1,
                "bucket_seed":
                "some new seed",
            }
        }

        seeded_experiment = parse_experiment(seeded_cfg)

        self.assertNotEqual(seeded_experiment.seed, experiment.seed)
        self.assertIsNot(seeded_experiment.seed, None)
        seeded_experiment.num_buckets = 1000
        self.assertEqual(
            seeded_experiment._calculate_bucket("t2_1"),
            long(924),
        )
Esempio n. 2
0
 def test_calculate_bucket_value(self):
     cfg = {
         "id": 1,
         "name": "test",
         "owner": "test",
         "type": "r2",
         "version": "1",
         "start_ts": time.time() - THIRTY_DAYS,
         "stop_ts": time.time() + THIRTY_DAYS,
         "experiment": {
             "variants": {
                 "control_1": 10,
                 "control_2": 10,
             }
         }
     }
     experiment = parse_experiment(cfg)
     experiment.num_buckets = 1000
     self.assertEqual(experiment._calculate_bucket("t2_1"), long(236))
     cfg = {
         "id": 1,
         "name": "test",
         "owner": "test",
         "type": "r2",
         "version": "1",
         "start_ts": time.time() - THIRTY_DAYS,
         "stop_ts": time.time() + THIRTY_DAYS,
         "experiment": {
             "seed": "test-seed",
             "variants": {
                 "control_1": 10,
                 "control_2": 10,
             }
         }
     }
     seeded_experiment = parse_experiment(cfg)
     self.assertNotEqual(seeded_experiment.seed, experiment.seed)
     self.assertIsNot(seeded_experiment.seed, None)
     seeded_experiment.num_buckets = 1000
     self.assertEqual(
         seeded_experiment._calculate_bucket("t2_1"),
         long(595),
     )
Esempio n. 3
0
 def test_calculate_bucket_value(self):
     cfg = {
         "id": 1,
         "name": "test",
         "owner": "test",
         "type": "r2",
         "expires":
         (datetime.utcnow() + THIRTY_DAYS).strftime(ISO_DATE_FMT),
         "experiment": {
             "variants": {
                 "control_1": 10,
                 "control_2": 10,
             }
         }
     }
     experiment = parse_experiment(cfg)
     experiment.num_buckets = 1000
     self.assertEqual(experiment._calculate_bucket("t2_1"), long(236))
     cfg = {
         "id": 1,
         "name": "test",
         "owner": "test",
         "type": "r2",
         "expires":
         (datetime.utcnow() + THIRTY_DAYS).strftime(ISO_DATE_FMT),
         "experiment": {
             "seed": "test-seed",
             "variants": {
                 "control_1": 10,
                 "control_2": 10,
             }
         }
     }
     seeded_experiment = parse_experiment(cfg)
     self.assertNotEqual(seeded_experiment.seed, experiment.seed)
     self.assertIsNot(seeded_experiment.seed, None)
     seeded_experiment.num_buckets = 1000
     self.assertEqual(
         seeded_experiment._calculate_bucket("t2_1"),
         long(595),
     )