Merge pull request #28 from conwetlab/develop

Compatibility with CKAN 2.3 (develop -> master)
This commit is contained in:
Aitor Magán García 2015-04-09 10:40:36 +02:00
commit 18623c7d1e
2 changed files with 21 additions and 8 deletions

View File

@ -108,12 +108,19 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm):
###################################################################### ######################################################################
def get_auth_functions(self): def get_auth_functions(self):
return {'package_show': auth.package_show, auth_functions = {'package_show': auth.package_show,
'package_update': auth.package_update, 'package_update': auth.package_update,
'resource_show': auth.resource_show, # 'resource_show': auth.resource_show,
constants.PACKAGE_ACQUIRED: auth.package_acquired, constants.PACKAGE_ACQUIRED: auth.package_acquired,
constants.ACQUISITIONS_LIST: auth.acquisitions_list} constants.ACQUISITIONS_LIST: auth.acquisitions_list}
# resource_show is not required in CKAN 2.3 because it delegates to
# package_show
if not tk.check_ckan_version(min_version='2.3'):
auth_functions['resource_show'] = auth.resource_show
return auth_functions
###################################################################### ######################################################################
############################ ICONFIGURER ############################# ############################ ICONFIGURER #############################
###################################################################### ######################################################################

View File

@ -62,13 +62,19 @@ class PluginTest(unittest.TestCase):
@parameterized.expand([ @parameterized.expand([
('package_show', plugin.auth.package_show), ('package_show', plugin.auth.package_show),
('package_update', plugin.auth.package_update), ('package_update', plugin.auth.package_update),
('package_show', plugin.auth.package_show), ('resource_show', plugin.auth.resource_show),
('resource_show', plugin.auth.resource_show, True, False),
('package_acquired', plugin.auth.package_acquired), ('package_acquired', plugin.auth.package_acquired),
('acquisitions_list', plugin.auth.acquisitions_list) ('acquisitions_list', plugin.auth.acquisitions_list)
]) ])
def test_auth_function(self, function_name, expected_function): def test_auth_function(self, function_name, expected_function, is_ckan_23=False, expected=True):
plugin.tk.check_ckan_version = MagicMock(return_value=is_ckan_23)
auth_functions = self.privateDatasets.get_auth_functions() auth_functions = self.privateDatasets.get_auth_functions()
if expected:
self.assertEquals(auth_functions[function_name], expected_function) self.assertEquals(auth_functions[function_name], expected_function)
else:
self.assertNotIn(function_name, auth_functions)
def test_update_config(self): def test_update_config(self):
# Call the method # Call the method