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, FilterObjectLocaleSerializer(experiment).data, FilterObjectCountrySerializer(experiment).data, ], ) self.assertEqual( serializer.data["arguments"], ExperimentRecipePrefArgumentsSerializer(experiment).data, )
def test_serializer_outputs_expected_schema(self): experiment = ExperimentFactory.create_with_status( Experiment.STATUS_SHIP ) serializer = ExperimentRecipePrefArgumentsSerializer(experiment) self.assertEqual( serializer.data, { "preferenceBranchType": experiment.pref_branch, "slug": experiment.normandy_slug, "experimentDocumentUrl": experiment.experiment_url, "preferenceName": experiment.pref_key, "preferenceType": experiment.pref_type, "branches": [ ExperimentRecipeVariantSerializer(variant).data for variant in experiment.variants.all() ], }, )