Esempio n. 1
0
 def test_form_saves_outcomes(self):
     experiment = NimbusExperimentFactory.create_with_lifecycle(
         NimbusExperimentFactory.Lifecycles.CREATED,
         primary_outcomes=[],
         secondary_outcomes=[],
     )
     form = NimbusExperimentAdminForm(
         instance=experiment,
         data={
             "owner": experiment.owner,
             "status": experiment.status,
             "publish_status": experiment.publish_status,
             "name": experiment.name,
             "slug": experiment.slug,
             "proposed_duration": experiment.proposed_duration,
             "proposed_enrollment": experiment.proposed_enrollment,
             "population_percent": experiment.population_percent,
             "total_enrolled_clients": experiment.total_enrolled_clients,
             "application": experiment.application,
             "hypothesis": experiment.hypothesis,
             "primary_outcomes": "outcome1, outcome2",
             "secondary_outcomes": "outcome3, outcome4",
         },
     )
     self.assertTrue(form.is_valid(), form.errors)
     experiment = form.save()
     self.assertEqual(experiment.primary_outcomes, ["outcome1", "outcome2"])
     self.assertEqual(experiment.secondary_outcomes,
                      ["outcome3", "outcome4"])
Esempio n. 2
0
 def test_form_required_fields(self):
     experiment = NimbusExperiment.objects.create(
         owner=UserFactory.create(),
         status=NimbusExperiment.Status.DRAFT,
         name="name",
         slug="slug",
         application=NimbusExperiment.Application.DESKTOP,
     )
     form = NimbusExperimentAdminForm(
         instance=experiment,
         data={
             "owner": experiment.owner,
             "status": experiment.status,
             "publish_status": experiment.publish_status,
             "name": experiment.name,
             "slug": experiment.slug,
             "proposed_duration": experiment.proposed_duration,
             "proposed_enrollment": experiment.proposed_enrollment,
             "population_percent": experiment.population_percent,
             "total_enrolled_clients": experiment.total_enrolled_clients,
             "application": experiment.application,
             "hypothesis": experiment.hypothesis,
         },
     )
     self.assertTrue(form.is_valid(), form.errors)
Esempio n. 3
0
    def test_form_rejects_reference_branch_from_other_experiment(self):
        experiment = NimbusExperimentFactory.create()
        branch = NimbusBranchFactory.create()

        form = NimbusExperimentAdminForm(instance=experiment,
                                         data={"reference_branch": branch.id})
        self.assertFalse(form.is_valid())
        self.assertIn("reference_branch", form.errors)
Esempio n. 4
0
    def test_form_rejects_any_branch_if_no_experiment_provided(self):
        branch = NimbusBranchFactory.create()

        form = NimbusExperimentAdminForm(data={"reference_branch": branch.id})
        self.assertFalse(form.is_valid())
        self.assertIn("reference_branch", form.errors)