Skip to content

Commit

Permalink
more test clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Oct 19, 2023
1 parent 4148644 commit 6900e19
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
class TestDraftRegistrationDetailEndpoint(TestDraftRegistrationDetail):
@pytest.fixture()
def url_draft_registrations(self, project_public, draft_registration):
return '/{}draft_registrations/{}/'.format(
API_BASE, draft_registration._id)
return f'/{API_BASE}draft_registrations/{draft_registration._id}/'

# Overrides TestDraftRegistrationDetail
def test_admin_group_member_can_view(self, app, user, draft_registration, project_public,
Expand All @@ -37,32 +36,32 @@ def test_can_view_draft(
user_read_contrib, user_non_contrib,
url_draft_registrations, group, group_mem):

# test_read_only_contributor_can_view_draft
def test_read_only_contributor_can_view_draft(self, app, user_read_contrib, url_draft_registrations):
res = app.get(
url_draft_registrations,
auth=user_read_contrib.auth,
expect_errors=False)
)
assert res.status_code == 200

# test_read_write_contributor_can_view_draft
def test_read_write_contributor_can_view_draft(self, app, user_write_contrib, url_draft_registrations):
res = app.get(
url_draft_registrations,
auth=user_write_contrib.auth,
expect_errors=False)
)
assert res.status_code == 200

def test_cannot_view_draft(
self, app, project_public,
user_non_contrib, url_draft_registrations):

# test_logged_in_non_contributor_cannot_view_draft
def test_logged_in_non_contributor_cannot_view_draft(self, app, user_non_contrib, url_draft_registrations):
res = app.get(
url_draft_registrations,
auth=user_non_contrib.auth,
expect_errors=True)
assert res.status_code == 403

# test_unauthenticated_user_cannot_view_draft
def test_unauthenticated_user_cannot_view_draft(self, app, user_non_contrib, url_draft_registrations):
res = app.get(url_draft_registrations, expect_errors=True)
assert res.status_code == 401

Expand Down Expand Up @@ -101,7 +100,7 @@ def test_detail_view_returns_editable_fields_no_specified_node(self, app, user):
assert attributes['node_license'] is None
assert not attributes['has_project']

res.json['data']['links']['self'] == url
assert res.json['data']['links']['self'] == url
relationships = res.json['data']['relationships']

assert 'affiliated_institutions' in relationships
Expand Down
3 changes: 1 addition & 2 deletions api_tests/nodes/views/test_node_draft_registration_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def test_admin_can_view_draft(self, app, user, draft_registration, schema, url_d
assert data['attributes']['registration_metadata'] == {}

def test_admin_group_member_can_view(self, app, user, url_draft_registrations, group_mem):

res = app.get(url_draft_registrations, auth=group_mem.auth)
assert res.status_code == 200

Expand All @@ -76,7 +75,7 @@ def test_group_mem_read_cannot_view(self, app, group, group_mem, project_public,
res = app.get(url_draft_registrations, auth=group_mem.auth, expect_errors=True)
assert res.status_code == 403

def test_cannot_view_deleted_draft( self, app, user, url_draft_registrations):
def test_cannot_view_deleted_draft(self, app, user, url_draft_registrations):
res = app.delete_json_api(url_draft_registrations, auth=user.auth)
assert res.status_code == 204

Expand Down
4 changes: 3 additions & 1 deletion api_tests/users/views/test_user_draft_registration_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def test_non_contrib_view_permissions(
assert data[0]['id'] == draft_registration._id
assert data[0]['attributes']['registration_metadata'] == {}

def test_read_only_contributor_can_view_draft_list(self, app, user_read_contrib, url_draft_registrations):
def test_read_only_contributor_can_view_draft_list(
self, app, draft_registration, user_read_contrib, url_draft_registrations
):
res = app.get(
url_draft_registrations,
auth=user_read_contrib.auth
Expand Down

0 comments on commit 6900e19

Please sign in to comment.