Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5977431

Browse files
new/tests: revision information was removed in CKAN 2.9 (ckan/ckan#3972); tests pass
1 parent 4916aae commit 5977431

2 files changed

Lines changed: 11 additions & 49 deletions

File tree

ckanext/datagov_inventory/plugin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def get_auth_functions(self):
3939
'organization_list': datagov_disallow_anonymous_access(),
4040
'package_list': datagov_disallow_anonymous_access(),
4141
'package_search': datagov_disallow_anonymous_access(),
42-
'revision_list': datagov_disallow_anonymous_access(),
43-
'revision_show': datagov_disallow_anonymous_access(),
4442
'site_read': datagov_disallow_anonymous_access(),
4543
'tag_list': datagov_disallow_anonymous_access(),
4644
'tag_show': datagov_disallow_anonymous_access(),

ckanext/datagov_inventory/tests/logic/auth/test_auth.py

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Tests for datagov_inventory plugin.py."""
22

3-
from nose.tools import assert_raises
3+
from builtins import object
4+
from pytest import raises as assert_raises
5+
import pytest
46

5-
from ckan.lib import search
67
import ckan.logic as logic
78
import ckan.model as model
89

@@ -19,22 +20,13 @@
1920
is_denied = False
2021

2122

23+
@pytest.mark.usefixtures(u"clean_index")
24+
@pytest.mark.usefixtures(u"clean_db")
2225
class TestDatagovInventoryAuth(object):
2326

24-
@classmethod
25-
def setup_class(self):
26-
'''Nose runs this method once to setup our test class.'''
27-
2827
def setup(self):
29-
'''Nose runs this method before each test method in our test class.'''
30-
3128
# Start with a clean database and index for each test
32-
search.clear_all()
3329
self.clean_datastore()
34-
model.repo.rebuild_db()
35-
36-
def teardown(self):
37-
'''Nose runs this method after each test method in our test class.'''
3830

3931
def setup_test_orgs_users(self):
4032

@@ -97,8 +89,8 @@ def factory_dataset(self, **kwargs):
9789
# Return id string for the package and resoruce just created
9890
return({'package_id': dataset['id'],
9991
'tag_id': dataset_params['tag_string'],
100-
'resource_id': dataset['resources'][0]['id'],
101-
'revision_id': dataset['revision_id']})
92+
'resource_id': dataset['resources'][0]['id']})
93+
# 'revision_id': dataset['revision_id']})
10294

10395
def assert_user_authorization(self,
10496
auth_function,
@@ -127,11 +119,10 @@ def assert_user_authorization(self,
127119
assert actual_authorization == expected_user_access_dict[user]
128120
else:
129121
# We expect users to be denied
130-
assert_raises(logic.NotAuthorized,
131-
helpers.call_auth,
132-
auth_function,
133-
context=context,
134-
id=object_id)
122+
with assert_raises(logic.NotAuthorized):
123+
helpers.call_auth(auth_function,
124+
context=context,
125+
id=object_id)
135126

136127
def test_auth_format_autocomplete(self):
137128
# Create test users and test group
@@ -285,33 +276,6 @@ def test_auth_resource_show_for_public_gsa_dataset(self):
285276
'anonymous': is_allowed
286277
}, object_id=dataset['resource_id'])
287278

288-
def test_auth_revision_list(self):
289-
# Create test users and test data
290-
self.setup_test_orgs_users()
291-
292-
self.assert_user_authorization('revision_list', {
293-
'gsa_admin': is_allowed,
294-
'gsa_editor': is_allowed,
295-
'gsa_member': is_allowed,
296-
'doi_admin': is_allowed,
297-
'doi_member': is_allowed,
298-
'anonymous': is_denied
299-
})
300-
301-
def test_auth_revision_show(self):
302-
# Create test users and test data
303-
self.setup_test_orgs_users()
304-
dataset = self.factory_dataset(owner_org='gsa', private=True)
305-
306-
self.assert_user_authorization('revision_show', {
307-
'gsa_admin': is_allowed,
308-
'gsa_editor': is_allowed,
309-
'gsa_member': is_allowed,
310-
'doi_admin': is_allowed,
311-
'doi_member': is_allowed,
312-
'anonymous': is_denied
313-
}, dataset['revision_id'])
314-
315279
def test_auth_site_read(self):
316280
# Create test users and test data
317281
self.setup_test_orgs_users()

0 commit comments

Comments
 (0)