Esempio n. 1
0
    def test_serializer_outputs_expected_int_val(self):
        experiment = ExperimentFactory(pref_type=Experiment.PREF_TYPE_INT)
        variant = ExperimentVariantFactory.create(experiment=experiment, value="28")
        serializer = ExperimentRecipeVariantSerializer(variant)

        self.assertEqual(type(serializer.data["value"]), int)
        self.assertEqual(
            serializer.data, {"ratio": variant.ratio, "slug": variant.slug, "value": 28}
        )
Esempio n. 2
0
 def test_serializer_outputs_expected_schema(self):
     experiment = ExperimentFactory(pref_type=Experiment.PREF_TYPE_STR)
     variant = ExperimentVariantFactory.create(experiment=experiment)
     serializer = ExperimentRecipeVariantSerializer(variant)
     self.assertEqual(
         serializer.data,
         {
             "ratio": variant.ratio,
             "slug": variant.slug,
             "value": variant.value
         },
     )
Esempio n. 3
0
 def test_serializer_outputs_expected_schema_with_json_str(self):
     experiment = ExperimentFactory(pref_type=Experiment.PREF_TYPE_JSON_STR)
     serializer = ExperimentRecipePrefArgumentsSerializer(experiment)
     self.assertEqual(
         serializer.data,
         {
             "preferenceBranchType":
             experiment.pref_branch,
             "slug":
             experiment.normandy_slug,
             "experimentDocumentUrl":
             experiment.experiment_url,
             "preferenceName":
             experiment.pref_name,
             "preferenceType":
             "string",
             "branches": [
                 ExperimentRecipeVariantSerializer(variant).data
                 for variant in experiment.variants.all()
             ],
         },
     )