Ejemplo n.º 1
0
    def test_form_not_valid_when_other_ids_duplicate_main_id(self):
        experiment = ExperimentFactory.create()

        form = NormandyIdForm(
            self.request,
            instance=experiment,
            data={"normandy_id": "4343", "other_normandy_ids": "4343"},
        )

        self.assertFalse(form.is_valid())
Ejemplo n.º 2
0
    def test_form_valid_when_other_ids_formatted_correctly(self):
        experiment = ExperimentFactory.create()

        form = NormandyIdForm(
            self.request,
            instance=experiment,
            data={"normandy_id": "4343", "other_normandy_ids": "4323, 5671"},
        )

        self.assertTrue(form.is_valid())
Ejemplo n.º 3
0
    def test_form_not_valid_with_bad_other_ids(self):
        experiment = ExperimentFactory.create()

        form = NormandyIdForm(
            self.request,
            instance=experiment,
            data={"normandy_id": "4343", "other_normandy_ids": "434, aaa"},
        )

        self.assertFalse(form.is_valid())
Ejemplo n.º 4
0
    def get_context_data(self, *args, **kwargs):
        if "normandy_id" in self.request.GET:
            normandy_id_form = NormandyIdForm(
                request=self.request, data=self.request.GET, instance=self.object
            )
        else:
            normandy_id_form = NormandyIdForm(request=self.request, instance=self.object)

        return super().get_context_data(
            normandy_id_form=normandy_id_form, *args, **kwargs
        )
Ejemplo n.º 5
0
    def test_form_changelog_has_message(self):
        experiment = ExperimentFactory.create()

        form = NormandyIdForm(
            self.request,
            instance=experiment,
            data={"normandy_id": "4343", "other_normandy_ids": "443"},
        )

        self.assertTrue(form.is_valid())

        form.save()

        self.assertTrue(experiment.changes.latest().message, "Recipe ID(s) Added")