Example #1
0
    def test_invalid_bugzilla_url(self):
        self.data["data_science_issue_url"] = "https://example.com/notbugzilla"

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertFalse(form.is_valid())
Example #2
0
    def test_unique_name_with_same_slug_raises_error(self):
        ExperimentFactory.create(slug="slug")
        self.data["name"] = "slug#"

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertFalse(form.is_valid())
Example #3
0
    def test_ds_issue_url_required_for_non_rollout(self):
        self.data["type"] = Experiment.TYPE_PREF
        del self.data["data_science_issue_url"]

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertFalse(form.is_valid())
Example #4
0
    def test_empty_slug_raises_error(self):
        self.data["name"] = "#"

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertFalse(form.is_valid())
Example #5
0
    def test_changelog_values(self):
        experiment = Experiment()
        experiment.save()

        ds_url = "{base}DS-123".format(base=settings.DS_ISSUE_HOST)
        bug_url = "{base}show_bug.cgi?id=123".format(
            base=settings.BUGZILLA_HOST)
        related_exp = ExperimentFactory.create()
        project = ProjectFactory.create()

        data = {
            "type": Experiment.TYPE_PREF,
            "name": "A new experiment!",
            "short_description": "Let us learn new things",
            "data_science_issue_url": ds_url,
            "owner": self.user.id,
            "analysis_owner": self.user.id,
            "engineering_owner": "Lisa the Engineer",
            "public_description": "Let us learn new public things",
            "related_to": [related_exp],
            "feature_bugzilla_url": bug_url,
            "related_work": "Designs: https://www.example.com/myproject/",
            "projects": [project],
        }

        form = ExperimentOverviewForm(request=self.request,
                                      data=data,
                                      instance=experiment)
        self.assertTrue(form.is_valid())
        experiment = form.save()
        latest_changes = experiment.changes.latest()

        expected_data = {
            "analysis_owner": {
                "display_name": "Data Science Owner",
                "new_value": experiment.analysis_owner.id,
                "old_value": None,
            },
            "data_science_issue_url": {
                "display_name": "Data Science Issue URL",
                "new_value": "https://jira.example.com/browse/DS-123",
                "old_value": None,
            },
            "engineering_owner": {
                "display_name": "Engineering Owner",
                "new_value": "Lisa the Engineer",
                "old_value": None,
            },
            "feature_bugzilla_url": {
                "display_name": "Feature Bugzilla URL",
                "new_value":
                "https://bugzilla.example.com/show_bug.cgi?id=123",
                "old_value": None,
            },
            "name": {
                "display_name": "Public Name",
                "new_value": "A new experiment!",
                "old_value": None,
            },
            "owner": {
                "display_name": "Delivery Owner",
                "new_value": experiment.owner.id,
                "old_value": None,
            },
            "projects": {
                "display_name": "Related Projects",
                "new_value": [{
                    "slug": project.slug
                }],
                "old_value": None,
            },
            "public_description": {
                "display_name": "Public Description",
                "new_value": "Let us learn new public things",
                "old_value": None,
            },
            "related_to": {
                "display_name": "Related Deliveries",
                "new_value": [related_exp.id],
                "old_value": None,
            },
            "related_work": {
                "display_name": "Related Work URLs",
                "new_value": "Designs: https://www.example.com/myproject/",
                "old_value": None,
            },
            "short_description": {
                "display_name": "Internal Description",
                "new_value": "Let us learn new things",
                "old_value": None,
            },
        }
        self.maxDiff = None
        self.assertEqual(expected_data, latest_changes.changed_values)
Example #6
0
    def test_large_enrollment_duration_is_invalid(self):
        self.data["proposed_enrollment"] = Experiment.MAX_DURATION + 1

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertFalse(form.is_valid())
Example #7
0
    def test_enrollment_is_optional(self):
        del self.data["proposed_enrollment"]

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertTrue(form.is_valid())
Example #8
0
    def test_enrollment_must_be_less_or_equal_duration(self):
        self.data["proposed_enrollment"] = 2
        self.data["proposed_duration"] = 1

        form = ExperimentOverviewForm(request=self.request, data=self.data)
        self.assertFalse(form.is_valid())