コード例 #1
0
 def test_serializer_outputs_expected_schema_for_addon_experiment(self):
     experiment = ExperimentFactory.create_with_status(
         Experiment.STATUS_SHIP,
         type=Experiment.TYPE_ADDON,
         locales=[LocaleFactory.create()],
         countries=[CountryFactory.create()],
     )
     serializer = ExperimentRecipeSerializer(experiment)
     self.assertEqual(serializer.data["action_name"], "opt-out-study")
     self.assertEqual(serializer.data["name"], experiment.name)
     self.assertEqual(
         serializer.data["comment"], experiment.client_matching
     )
     self.assertEqual(
         serializer.data["filter_object"],
         [
             FilterObjectBucketSampleSerializer(experiment).data,
             FilterObjectChannelSerializer(experiment).data,
             FilterObjectLocaleSerializer(experiment).data,
             FilterObjectCountrySerializer(experiment).data,
         ],
     )
     self.assertEqual(
         serializer.data["arguments"],
         ExperimentRecipeAddonArgumentsSerializer(experiment).data,
     )
コード例 #2
0
    def test_serializer_outputs_expected_schema_for_pref_experiment(self):
        experiment = ExperimentFactory.create_with_status(
            Experiment.STATUS_SHIP,
            type=Experiment.TYPE_PREF,
            locales=[LocaleFactory.create()],
            countries=[CountryFactory.create()],
        )
        serializer = ExperimentRecipeSerializer(experiment)
        self.assertEqual(serializer.data["action_name"],
                         "preference-experiment")
        self.assertEqual(serializer.data["name"], experiment.name)
        self.assertEqual(serializer.data["comment"],
                         experiment.client_matching)
        self.assertEqual(
            serializer.data["filter_object"],
            [
                FilterObjectBucketSampleSerializer(experiment).data,
                FilterObjectChannelSerializer(experiment).data,
                FilterObjectVersionsSerializer(experiment).data,
                FilterObjectLocaleSerializer(experiment).data,
                FilterObjectCountrySerializer(experiment).data,
            ],
        )
        self.assertEqual(
            serializer.data["arguments"],
            ExperimentRecipePrefArgumentsSerializer(experiment).data,
        )

        self.assertEqual(serializer.data["experimenter_slug"], experiment.slug)
コード例 #3
0
 def test_serializer_outputs_expected_schema(self):
     experiment = ExperimentFactory.create(
         population_percent=Decimal("12.34"))
     serializer = FilterObjectBucketSampleSerializer(experiment)
     self.assertEqual(
         serializer.data,
         {
             "type": "bucketSample",
             "input": ["normandy.recipe.id", "normandy.userId"],
             "start": 0,
             "count": 1234,
             "total": 10000,
         },
     )