Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tiftran committed Feb 28, 2020
1 parent 54b0dc3 commit 184294d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
1 change: 1 addition & 0 deletions .env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 3 additions & 4 deletions app/experimenter/experiments/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 17 additions & 0 deletions app/experimenter/experiments/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from experimenter.experiments.forms import (
BugzillaURLField,
DSIssueURLField,
ChangeLogMixin,
CustomModelMultipleChoiceField,
ExperimentArchiveForm,
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
10 changes: 5 additions & 5 deletions tests/integration/pages/experiment_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/test_create_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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."""
Expand All @@ -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")
Expand All @@ -56,19 +57,19 @@ 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")
exp_design.select_firefox_pref_type()
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")

0 comments on commit 184294d

Please sign in to comment.