Skip to content

Commit

Permalink
Fix intermittent error; add Forms test (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
seav authored and oliverroick committed Feb 28, 2018
1 parent 62b6925 commit 3fd12e9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 37 deletions.
Binary file not shown.
Binary file not shown.
28 changes: 27 additions & 1 deletion cadasta/test/forms_tests/test_xlsform.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def wait_and_click_save_button(self):

@pytest.mark.uploads
def test_xlsform_with_invalid_field_is_not_allowed(self, prj_manager):
"""Verifies Forms test case #X1,#X2,#X3,#X4,#X5,#X6,#X7,#X9,#X10."""
"""Verifies Forms test cases #X1,#X2,#X3,#X4,#X5,#X6,#X7,#X9,#X10."""

self.log_in(prj_manager)
self.open(self.prj_dashboard_path)
Expand Down Expand Up @@ -124,3 +124,29 @@ def verify_invalid_xlsform(filename, msg_pattern):
verify_invalid_xlsform(
'XLSForm X10 missing end group.xlsx',
"^Unmatched begin statement: group$")

@pytest.mark.uploads
def test_xlsform_with_resource_in_group_is_allowed(self, prj_manager):
"""Verifies Forms test case #X8."""

self.log_in(prj_manager)
self.open(self.prj_dashboard_path)
self.wd.BY_LINK("Upload XLS Form").click()
dir_path = join(dirname(dirname(abspath(__file__))), 'files')
input_xpath = '//input[@type="file"]'
path = join(
dir_path, 'XLSForm X8 image, audio, video type in group.xlsx')
self.wd.BY_XPATH(input_xpath).send_keys(path)
self.wait_and_click_save_button()
self.assert_url_path(self.prj_dashboard_path)
self.wd.BY_LINK("Upload new XLS Form")
self.wd.BY_LINK("Download current XLS Form")

# [REVERSION]
self.wd.BY_LINK("Upload new XLS Form").click()
link = self.wd.BY_XPATH('//a[contains(@class, "file-remove")]')
self.scroll_element_into_view(link)
link.click()
self.wait_and_click_save_button()
self.assert_url_path(self.prj_dashboard_path)
self.wd.BY_LINK("Upload XLS Form")
51 changes: 18 additions & 33 deletions cadasta/test/project_tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,40 +176,25 @@ def test_duplicate_name_is_rejected(self, basic_prj, another_prj):
"""Verifies Projects test case #C7, #C16, #C17."""

self.log_in()
self.open('/projects/new/')
self.click_wizard_next_button()
self.update_form_field('details-organization', self.org['slug'])
self.update_form_field('details-name', basic_prj['name'])
self.update_form_field('details-description', "Project description.")
self.update_form_field('details-url', 'http://example.com')
self.update_form_field('details-contacts-0-name', 'Contact Person')
self.update_form_field('details-contacts-0-email', 'cp@example.com')
self.update_form_field('details-contacts-0-tel', '1234567890')
self.click_wizard_next_button()
self.assert_form_field_has_error(
'details-name', 'Project with this name already exists')

# Clear the previous error by inducing a different error
self.update_form_field('details-name', '')
self.click_wizard_next_button()
self.assert_form_field_has_error(
'details-name', 'This field is required.')

self.update_form_field('details-name', basic_prj['name'].upper())
self.click_wizard_next_button()
self.assert_form_field_has_error(
'details-name', 'Project with this name already exists')

# Clear the previous error by inducing a different error
self.update_form_field('details-name', '')
self.click_wizard_next_button()
self.assert_form_field_has_error(
'details-name', 'This field is required.')

self.update_form_field('details-name', another_prj['name'].upper())
self.click_wizard_next_button()
self.assert_form_field_has_error(
'details-name', 'Project with this name already exists')
def check_duplicate_name(name):
self.open('/projects/new/')
self.click_wizard_next_button()
self.update_form_field('details-organization', self.org['slug'])
self.update_form_field('details-description', "Description.")
self.update_form_field('details-url', 'http://example.com')
self.update_form_field('details-contacts-0-name', 'Contact Person')
self.update_form_field('details-contacts-0-email', 'c@example.com')
self.update_form_field('details-contacts-0-tel', '1234567890')
self.update_form_field('details-name', name)
self.click_wizard_next_button()
self.assert_form_field_has_error(
'details-name', 'Project with this name already exists')

check_duplicate_name(basic_prj['name'])
check_duplicate_name(basic_prj['name'].upper())
check_duplicate_name(another_prj['name'])
check_duplicate_name(another_prj['name'].upper())

def test_invalid_url_is_rejected(self):
"""Verifies Projects test case #C10."""
Expand Down
6 changes: 3 additions & 3 deletions cadasta/test/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@


if __name__ == '__main__':
# cadasta-test does not require Django
if 'DJANGO_SETTINGS_MODULE' in os.environ:
del os.environ['DJANGO_SETTINGS_MODULE']
# For Dev VM, explicitly point to the Django project root to avoid
# pytest-django not configured error
sys.path.append('/opt/cadasta/cadasta-platform/cadasta')

# Declare valid command-line arguments
parser = argparse.ArgumentParser(
Expand Down

0 comments on commit 3fd12e9

Please sign in to comment.