Ejemplo n.º 1
0
 def test_invalid_experiment_treatment_branch_requires_description(self):
     experiment = NimbusExperimentFactory.create_with_status(
         NimbusExperiment.Status.DRAFT,
         application=NimbusExperiment.Application.DESKTOP.value,
         feature_config=NimbusFeatureConfigFactory(
             application=NimbusExperiment.Application.DESKTOP.value),
     )
     treatment_branch = NimbusBranchFactory.create(experiment=experiment,
                                                   description="")
     experiment.branches.add(treatment_branch)
     experiment.save()
     serializer = NimbusReadyForReviewSerializer(
         experiment,
         data=NimbusReadyForReviewSerializer(
             experiment,
             context={
                 "user": self.user
             },
         ).data,
         context={"user": self.user},
     )
     self.assertFalse(serializer.is_valid())
     self.assertEqual(
         serializer.errors["treatment_branches"][1],
         ["Description cannot be blank."],
     )
Ejemplo n.º 2
0
 def resolve_ready_for_review(self, info):
     serializer = NimbusReadyForReviewSerializer(
         self,
         data=NimbusReadyForReviewSerializer(self).data,
     )
     ready = serializer.is_valid()
     return NimbusReadyForReviewType(message=serializer.errors, ready=ready)
Ejemplo n.º 3
0
 def test_valid_experiment(self):
     experiment = NimbusExperimentFactory.create_with_status(
         NimbusExperiment.Status.DRAFT,
         application=NimbusExperiment.Application.DESKTOP.value,
         feature_config=NimbusFeatureConfigFactory(
             application=NimbusExperiment.Application.DESKTOP.value),
     )
     serializer = NimbusReadyForReviewSerializer(
         experiment,
         data=NimbusReadyForReviewSerializer(
             experiment,
             context={
                 "user": self.user
             },
         ).data,
         context={"user": self.user},
     )
     self.assertTrue(serializer.is_valid())
Ejemplo n.º 4
0
 def test_invalid_experiment_requires_non_zero_population_percent(self):
     experiment = NimbusExperimentFactory.create_with_status(
         NimbusExperiment.Status.DRAFT,
         population_percent=0.0,
     )
     serializer = NimbusReadyForReviewSerializer(
         experiment,
         data=NimbusReadyForReviewSerializer(
             experiment,
             context={
                 "user": self.user
             },
         ).data,
         context={"user": self.user},
     )
     self.assertFalse(serializer.is_valid())
     self.assertEqual(
         str(serializer.errors["population_percent"][0]),
         "Ensure this value is greater than or equal to 0.0001.",
     )
Ejemplo n.º 5
0
 def test_invalid_experiment_reference_branch_requires_description(self):
     experiment = NimbusExperimentFactory.create_with_status(
         NimbusExperiment.Status.DRAFT,
         application=NimbusExperiment.Application.DESKTOP.value,
         feature_config=NimbusFeatureConfigFactory(
             application=NimbusExperiment.Application.DESKTOP.value),
     )
     experiment.reference_branch.description = ""
     experiment.save()
     serializer = NimbusReadyForReviewSerializer(
         experiment,
         data=NimbusReadyForReviewSerializer(
             experiment,
             context={
                 "user": self.user
             },
         ).data,
         context={"user": self.user},
     )
     self.assertFalse(serializer.is_valid())
     self.assertEqual(
         serializer.errors,
         {"reference_branch": ["Description cannot be blank."]},
     )
Ejemplo n.º 6
0
 def test_invalid_experiment_default_hypothesis(self):
     experiment = NimbusExperimentFactory.create_with_status(
         NimbusExperiment.Status.DRAFT,
         application=NimbusExperiment.Application.DESKTOP.value,
         feature_config=NimbusFeatureConfigFactory(
             application=NimbusExperiment.Application.DESKTOP.value),
     )
     experiment.hypothesis = NimbusExperiment.HYPOTHESIS_DEFAULT
     experiment.save()
     serializer = NimbusReadyForReviewSerializer(
         experiment,
         data=NimbusReadyForReviewSerializer(
             experiment,
             context={
                 "user": self.user
             },
         ).data,
         context={"user": self.user},
     )
     self.assertFalse(serializer.is_valid())
     self.assertEqual(
         serializer.errors,
         {"hypothesis": ["Hypothesis cannot be the default value."]},
     )