Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize initial set of project dashboard tests #92

Merged
merged 1 commit into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cadasta/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.0'
__version__ = '0.8.0'
80 changes: 74 additions & 6 deletions cadasta/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ def any_org_member(request, all_fixtures):
if request.param in user['username'])


@pytest.fixture(scope='session',
params=['functest_org_member_',
'functest_data_collector_',
'functest_prj_user_'])
def any_non_pm_user(request, all_fixtures):
return next(user for user in all_fixtures['accounts.user']
if request.param in user['username'])


@pytest.fixture(scope='session',
params=['functest_generic_',
'functest_genericphone_',
Expand Down Expand Up @@ -170,8 +179,41 @@ def archivable_org(all_fixtures):

@pytest.fixture(scope='session')
def basic_prj(all_fixtures):
return next(prj for prj in all_fixtures['organization.project']
if 'functest-basic-prj-' in prj['slug'])
"""
This Pytest fixture function returns the dict corresponding to the Basic
Prj with an additional key 'members' having a value which is a list of
tuple of the project's members (users with project role in the project and
users with an admin org role in the project's organization).

The member tuple has the following structure:
- dict of core user data (straight from the fixture file)
- 2-char string representing the project role (OA/PM/DC/PU)
"""

project = next(prj for prj in all_fixtures['organization.project']
if 'functest-basic-prj-' in prj['slug'])
project['members'] = []

# Extract non-org admins
for prj_role in all_fixtures['organization.projectrole']:
if prj_role['project'] != project['pk']:
continue
for user in all_fixtures['accounts.user']:
if prj_role['user'][0] == user['username']:
project['members'].append((user, prj_role['role']))

# Extract org admins
for org in all_fixtures['organization.organization']:
if org['pk'] != project['organization']:
continue
for org_role in all_fixtures['organization.organizationrole']:
if org_role['organization'] != org['pk'] or not org_role['admin']:
continue
for user in all_fixtures['accounts.user']:
if org_role['user'][0] == user['username']:
project['members'].append((user, 'OA'))

return project


@pytest.fixture(scope='session')
Expand All @@ -182,14 +224,34 @@ def private_prj(all_fixtures):

@pytest.fixture(scope='session')
def records_prj(all_fixtures):
return next(prj for prj in all_fixtures['organization.project']
if 'functest-records-prj-' in prj['slug'])
"""This Pytest fixture function returns the dict corresponding to the
Records Prj with statistics keys added."""
project = next(prj for prj in all_fixtures['organization.project']
if 'functest-records-prj-' in prj['slug'])
project['num_locations'] = len(
[loc for loc in all_fixtures['spatial.spatialunit']
if loc['project'] == project['pk']])
project['num_parties'] = len(
[party for party in all_fixtures['party.party']
if party['project'] == project['pk']])
project['num_resources'] = len(
[res for res in all_fixtures['resources.resource']
if res['project'] == project['pk']])
return project


@pytest.fixture(scope='session')
def custom_attrs_prj(all_fixtures):
return next(prj for prj in all_fixtures['organization.project']
if 'functest-custom-attrs-prj-' in prj['slug'])
"""This Pytest fixture function returns the dict corresponding to the
Custom Attrs Prj with an additional 'questionnaire' key added with a value
corresponding to the questionnaire fixture data."""
project = next(prj for prj in all_fixtures['organization.project']
if 'functest-custom-attrs-prj-' in prj['slug'])
for questionnaire in all_fixtures['questionnaires.questionnaire']:
if questionnaire['pk'] != project['current_questionnaire']:
continue
project['questionnaire'] = questionnaire
return project


@pytest.fixture(scope='session')
Expand All @@ -216,6 +278,12 @@ def custom_conditional_attrs_prj(all_fixtures):
if 'functest-custom-conditional-attrs-prj-' in prj['slug'])


@pytest.fixture(scope='session')
def empty_prj(all_fixtures):
return next(prj for prj in all_fixtures['organization.project']
if 'functest-empty-prj-' in prj['slug'])


@pytest.fixture(scope='session')
def another_prj(all_fixtures):
return next(prj for prj in all_fixtures['organization.project']
Expand Down
62 changes: 59 additions & 3 deletions cadasta/test/fixtures/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,19 @@
"urls": "[\"http://example.com\"]",
"contacts": [
{
"name": "Contact Person",
"tel": "1234567890",
"email": "contact@example.com"
"name": "John Lennon",
"tel": "12345",
"email": "lennon@example.com"
},
{
"name": "Paul McCartney",
"tel": null,
"email": "mccartney@example.com"
},
{
"name": "Ringo Starr",
"tel": "13579",
"email": null
}
],
"extent": "SRID=4326;POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))",
Expand Down Expand Up @@ -823,6 +833,26 @@
"last_updated": "2018-02-07T00:00:00.000Z"
}
},
{
"model": "organization.project",
"pk": "nyxs9bqvr3gjgj9nxbu7fk7k",
"fields": {
"name": "FuncTest Empty Prj",
"slug": "functest-empty-prj-nyxs9bqvr3gjgj9nxbu7fk7k",
"organization": "t76ippq854bvzh5uju6tikbw",
"country": "",
"description": "",
"archived": false,
"urls": "[]",
"contacts": [],
"extent": null,
"access": "public",
"current_questionnaire": "",
"area": 0.0,
"created_date": "2018-03-17T00:00:00.000Z",
"last_updated": "2018-03-17T00:00:00.000Z"
}
},
{
"model": "organization.project",
"pk": "b2k5bruyxmh2ynicnzpeqt9k",
Expand Down Expand Up @@ -947,6 +977,19 @@
"last_updated": "2017-11-10T00:00:00.000Z"
}
},
{
"model": "organization.projectrole",
"pk": "jfbtzefxcumqccr45ekywk8y",
"fields": {
"project": "9zz5r4cn7kkhgbutnpdc3i4d",
"user": [
"functest_prj_manager_spj3de5tqkxt3dferaycyhiu"
],
"role": "PM",
"created_date": "2018-03-19T00:00:00.000Z",
"last_updated": "2018-03-19T00:00:00.000Z"
}
},
{
"model": "organization.projectrole",
"pk": "abqfhm789xpfc27zjska7c65",
Expand Down Expand Up @@ -1012,6 +1055,19 @@
"last_updated": "2018-02-07T00:00:00.000Z"
}
},
{
"model": "organization.projectrole",
"pk": "c4se35jqhtesy5yrccpybakk",
"fields": {
"project": "nyxs9bqvr3gjgj9nxbu7fk7k",
"user": [
"functest_prj_manager_spj3de5tqkxt3dferaycyhiu"
],
"role": "PM",
"created_date": "2018-03-17T00:00:00.000Z",
"last_updated": "2018-03-17T00:00:00.000Z"
}
},
{
"model": "spatial.spatialunit",
"pk": "xqzcnvuy7u9gywqkp2xa3rbn",
Expand Down
12 changes: 10 additions & 2 deletions cadasta/test/forms_tests/test_xlsform.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def verify_invalid_xlsform(filename, msg_pattern):

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

self.log_in(prj_manager)
self.open(self.prj_dashboard_path)
Expand All @@ -139,7 +139,15 @@ def test_xlsform_with_resource_in_group_is_allowed(self, prj_manager):
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_XPATH(
'//*[contains(normalize-space(),"You have designed a data '
'collection for this project but have not collected any data. '
'You can still change your schema.")]')
self.wd.BY_XPATH(
'//a[@href="{}edit/details/" and'
' contains(@class,"btn-primary") and'
' contains(.,"Upload new XLS Form")]'.format(
self.prj_dashboard_path))
self.wd.BY_LINK("Download current XLS Form")

# [REVERSION]
Expand Down
Loading