diff --git a/.env.integration b/.env.integration index cbb5a7c024..4b4bf7b6b4 100644 --- a/.env.integration +++ b/.env.integration @@ -7,6 +7,7 @@ DB_PASS=postgres DB_USER=postgres DEBUG=True DELIVERY_CONSOLE_HOST= +DS_ISSUE_HOST=https://jira.mozilla.com/browse/ EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend EMAIL_HOST= EMAIL_HOST_PASSWORD= diff --git a/app/experimenter/experiments/forms.py b/app/experimenter/experiments/forms.py index b70c86cd6e..99f3017474 100644 --- a/app/experimenter/experiments/forms.py +++ b/app/experimenter/experiments/forms.py @@ -63,15 +63,14 @@ def clean(self, value): return cleaned_value def get_ds_issue_id(self, bug_url): - ds = re.match(r"https://jira.mozilla.com/browse/DS-(\w+.*)", bug_url) - do = re.match(r"https://jira.mozilla.com/browse/DO-(\w+.*)", bug_url) + ds = re.match(r"https:\/\/jira\.mozilla\.com\/browse\/DS-(\w+.*)", bug_url) + do = re.match(r"https:\/\/jira\.mozilla\.com\/browse\/DO-(\w+.*)", bug_url) if ds: return ds.group(1) - + return do.group(1) - class BugzillaURLField(forms.URLField): def clean(self, value): diff --git a/app/experimenter/experiments/tests/test_forms.py b/app/experimenter/experiments/tests/test_forms.py index 7b0c44575a..48cf207689 100644 --- a/app/experimenter/experiments/tests/test_forms.py +++ b/app/experimenter/experiments/tests/test_forms.py @@ -15,6 +15,7 @@ from experimenter.experiments.forms import ( BugzillaURLField, + DSIssueURLField, ChangeLogMixin, CustomModelMultipleChoiceField, ExperimentArchiveForm, @@ -96,6 +97,22 @@ def test_rejects_non_bugzilla_url(self): field.clean("www.example.com") +@override_settings(DS_ISSUE_HOST="https://jira.mozilla.com/browse/") +class TestDSIssueURLField(TestCase): + + def test_accepts_ds_url_field(self): + field = DSIssueURLField() + ds_url = "{base}DS-1234".format(base=settings.DS_ISSUE_HOST) + cleaned = field.clean(ds_url) + self.assertEqual(cleaned, ds_url) + + def test_rejects_wrong_project_name(self): + field = DSIssueURLField() + ds_url = "{base}AA-1234".format(base=settings.DS_ISSUE_HOST) + with self.assertRaises(ValidationError): + field.clean(ds_url) + + class TestExperimentVariantGenericForm(TestCase): def setUp(self): diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index c6cca98f9c..d7422acf89 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -16,7 +16,7 @@ def capabilities(capabilities): def firefox_options(firefox_options): """Set Firefox Options.""" firefox_options.headless = True - firefox_options.log.level = 'trace' + firefox_options.log.level = "trace" return firefox_options @@ -40,5 +40,5 @@ def fill_overview(selenium, base_url): experiment.short_description = "Testing in here" experiment.public_name = "Public Name" experiment.public_description = "Public Description" - experiment.bugzilla_url = "http://bugzilla.com/show_bug.cgi?id=1234" + experiment.bugzilla_url = "https://jira.mozilla.com/browse/DS-123" return experiment diff --git a/tests/integration/pages/experiment_overview.py b/tests/integration/pages/experiment_overview.py index 43054d0f82..3de97d7d9c 100644 --- a/tests/integration/pages/experiment_overview.py +++ b/tests/integration/pages/experiment_overview.py @@ -36,13 +36,13 @@ class ExperimentOverview(Base): _page_wait_locator = (By.CSS_SELECTOR, "body.page-edit-overview") _name_locator = (By.CSS_SELECTOR, "#id_name") _short_description_locator = (By.CSS_SELECTOR, "#id_short_description") - _bugzilla_url_locator = ( + _ds_issue_url_locator = ( By.CSS_SELECTOR, - "id_data_science_bugzilla_url", + "#id_data_science_issue_url", ) _overview_name_locator = (By.CSS_SELECTOR, "#id_name") _overview_description_locator = (By.CSS_SELECTOR, "#id_short_description") - _overview_bugzilla_url_locator = (By.CSS_SELECTOR, "#id_data_science_bugzilla_url") + _overview_ds_issue_url_locator = (By.CSS_SELECTOR, "#id_data_science_issue_url") _overview_data_science_owner_locator = (By.CSS_SELECTOR, "#id_analysis_owner") _save_btn_locator = (By.CSS_SELECTOR, "#save-btn") _save_and_continue_btn_locator = (By.CSS_SELECTOR, "#save-and-continue-btn") @@ -91,12 +91,12 @@ def short_description(self, text=None): @property def bugzilla_url(self): - element = self.find_element(*self._bugzilla_url_locator) + element = self.find_element(*self._ds_issue_url_locator) return element.get_attribute("value") @bugzilla_url.setter def bugzilla_url(self, text=None): - element = self.find_element(*self._bugzilla_url_locator) + element = self.find_element(*self._ds_issue_url_locator) random_chars = "".join(random.choices(string.digits, k=6)) element.send_keys(f"{text}{random_chars}") return diff --git a/tests/integration/test_create_experiment.py b/tests/integration/test_create_experiment.py index 34837ac0db..1c6b5c1b58 100644 --- a/tests/integration/test_create_experiment.py +++ b/tests/integration/test_create_experiment.py @@ -14,7 +14,7 @@ def test_add_branch(base_url, selenium): experiment.short_description = "Testing in here" experiment.public_name = "Public Name" experiment.public_description = "Public Description" - experiment.bugzilla_url = "http://bugzilla.com/show_bug.cgi?id=1234" + experiment.bugzilla_url = "https://jira.mozilla.com/browse/DS-123" exp_detail = experiment.save_btn() exp_design = exp_detail.click_edit() exp_design.input_firefox_pref_name("robot rock") @@ -23,6 +23,7 @@ def test_add_branch(base_url, selenium): new_branch = exp_design.create_new_branch() assert "Branch 2" in new_branch.branch_number.text + @pytest.mark.nondestructive def test_remove_branch(base_url, selenium): """Test removing a branch.""" @@ -33,7 +34,7 @@ def test_remove_branch(base_url, selenium): experiment.short_description = "Testing in here" experiment.public_name = "Public Name" experiment.public_description = "Public Description" - experiment.bugzilla_url = "http://bugzilla.com/show_bug.cgi?id=1234" + experiment.bugzilla_url = "https://jira.mozilla.com/browse/DS-123" exp_detail = experiment.save_btn() exp_design = exp_detail.click_edit() exp_design.input_firefox_pref_name("robot rock") @@ -56,7 +57,7 @@ def test_duplicate_branch_name(base_url, selenium): experiment.short_description = "Testing in here" experiment.public_name = "Public Name" experiment.public_description = "Public Description" - experiment.bugzilla_url = "http://bugzilla.com/show_bug.cgi?id=1234" + experiment.bugzilla_url = "https://jira.mozilla.com/browse/DS-123" exp_detail = experiment.save_btn() exp_design = exp_detail.click_edit() exp_design.input_firefox_pref_name("robot rock") @@ -64,11 +65,11 @@ def test_duplicate_branch_name(base_url, selenium): exp_design.select_firefox_pref_branch() control_branch = exp_design.current_branches[0] control_branch.set_branch_name("DUPLICATE BRANCH") - control_branch.set_branch_description('THIS IS A TEST') + control_branch.set_branch_description("THIS IS A TEST") control_branch.set_branch_value("false") extra_branch = exp_design.current_branches[-1] extra_branch.set_branch_name("DUPLICATE BRANCH") - extra_branch.set_branch_description('THIS IS A TEST') + extra_branch.set_branch_description("THIS IS A TEST") extra_branch.set_branch_value("false") exp_design.click_continue() selenium.find_element_by_css_selector("#design-form .invalid-feedback")