Esempio n. 1
0
 def test_serializer_outputs_expected_schema(self):
     locale1 = LocaleFactory.create(code="ab")
     locale2 = LocaleFactory.create(code="cd")
     experiment = ExperimentFactory.create(locales=[locale1, locale2])
     serializer = FilterObjectLocaleSerializer(experiment)
     self.assertEqual(serializer.data["type"], "locale")
     self.assertEqual(set(serializer.data["locales"]), set(["ab", "cd"]))
Esempio n. 2
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,
     )
Esempio n. 3
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)