Beispiel #1
0
    def test_serializer_returns_error_for_non_unique_slug(self):
        ExperimentRapidFactory.create(name="non unique slug", slug="non-unique-slug")

        data = {
            "name": "non. unique slug",
            "objectives": "gotta go fast",
            "audience": "all_english",
            "features": ["picture_in_picture", "pinned_tabs"],
            "firefox_min_version": "80.0",
            "firefox_channel": Experiment.CHANNEL_RELEASE,
            "variants": self.variants_data,
        }

        serializer = ExperimentRapidSerializer(
            data=data, context={"request": self.request}
        )
        self.assertFalse(serializer.is_valid())

        self.assertIn(
            "Name maps to a pre-existing slug, please choose another name",
            serializer.errors["name"],
        )
Beispiel #2
0
    def test_serializer_update_experiment_does_not_throw_slug_err(self):
        experiment = ExperimentRapidFactory.create(
            name="non unique slug", slug="non-unique-slug"
        )

        data = {
            "name": "non unique slug",
            "objectives": "gotta go fast",
            "audience": "all_english",
            "features": ["picture_in_picture", "pinned_tabs"],
            "firefox_min_version": "80.0",
            "firefox_channel": Experiment.CHANNEL_RELEASE,
            "variants": self.variants_data,
        }

        serializer = ExperimentRapidSerializer(
            data=data, context={"request": self.request}, instance=experiment
        )
        self.assertTrue(serializer.is_valid())