Replace package_deleted function name for revoke_access
This commit is contained in:
parent
014779a096
commit
1bb294832e
|
@ -111,7 +111,8 @@ def acquisitions_list(context, data_dict):
|
|||
|
||||
return result
|
||||
|
||||
def package_deleted(context, request_data):
|
||||
|
||||
def revoke_access(context, request_data):
|
||||
'''
|
||||
API action to be called in order to revoke access grants of an user.
|
||||
|
||||
|
@ -189,7 +190,7 @@ def _process_package(context, request_data):
|
|||
present = user_info['user'] in dataset[constants.ALLOWED_USERS]
|
||||
# Deletes the user only if it is in the list
|
||||
if (not method and present) or (method and not present):
|
||||
if method:
|
||||
if method:
|
||||
dataset[constants.ALLOWED_USERS].append(user_info['user'])
|
||||
else:
|
||||
dataset[constants.ALLOWED_USERS].remove(user_info['user'])
|
||||
|
@ -209,7 +210,7 @@ def _process_package(context, request_data):
|
|||
else:
|
||||
log.warn('Action -%s access to user- not completed. The dataset %s already %s access to the user %s' % (context['method'], dataset_id, context['method'], user_info['user']))
|
||||
else:
|
||||
log.warn('Dataset %s is public. Cannot %s access to users' % (dataset_id, context['method']))
|
||||
log.warn('Dataset %s is public. Cannot %s access to users' % (dataset_id, context['method']))
|
||||
warns.append('Unable to upload the dataset %s: It\'s a public dataset' % dataset_id)
|
||||
|
||||
except plugins.toolkit.ObjectNotFound:
|
||||
|
|
|
@ -24,4 +24,4 @@ SEARCHABLE = 'searchable'
|
|||
ACQUIRE_URL = 'acquire_url'
|
||||
CONTEXT_CALLBACK = 'updating_via_cb'
|
||||
PACKAGE_ACQUIRED = 'package_acquired'
|
||||
PACKAGE_DELETED = 'package_deleted'
|
||||
PACKAGE_DELETED = 'revoke_access'
|
||||
|
|
|
@ -306,7 +306,7 @@ class ActionsTest(unittest.TestCase):
|
|||
({'user91': ['ds1']}, ['ds1'], ['ds1'], ['another_user', 'another_one']), # Checking the behaviour when the unknown dataset is public
|
||||
({'user92': ['ds1']}, ['ds1'], ['ds1'], ['another_user', 'another_one','user92']),
|
||||
|
||||
# # Complex test: some users and some datasets
|
||||
# Complex test: some users and some datasets
|
||||
({'user1': ['ds1', 'ds2', 'ds3', 'ds4'], 'user2': ['ds5', 'ds6', 'ds7']}, ['ds3', 'ds6'], ['ds4', 'ds7'], []),
|
||||
({'user3': ['ds1', 'ds2', 'ds3', 'ds4'], 'user4': ['ds5', 'ds6', 'ds7']}, ['ds3', 'ds6'], ['ds4', 'ds7'], ['another_user']),
|
||||
({'user5': ['ds1', 'ds2', 'ds3', 'ds4'], 'user6': ['ds5', 'ds6', 'ds7']}, ['ds3', 'ds6'], ['ds4', 'ds7'], ['another_user', 'another_one']),
|
||||
|
@ -325,7 +325,7 @@ class ActionsTest(unittest.TestCase):
|
|||
|
||||
# Call the function
|
||||
context = {'user': 'user1', 'model': 'model', 'auth_obj': {'id': 1}, 'method': 'revoke'}
|
||||
result = actions.package_deleted(context, users_info)
|
||||
result = actions.revoke_access(context, users_info)
|
||||
|
||||
# Calculate the list of warns
|
||||
warns = []
|
||||
|
@ -344,7 +344,7 @@ class ActionsTest(unittest.TestCase):
|
|||
|
||||
# Check that the initial functions (check_access and parse_notification) has been called properly
|
||||
parse_delete.assert_called_once_with(users_info)
|
||||
actions.plugins.toolkit.check_access.assert_called_once_with('package_deleted', context, users_info)
|
||||
actions.plugins.toolkit.check_access.assert_called_once_with('revoke_access', context, users_info)
|
||||
|
||||
for user_datasets in parse_result['users_datasets']:
|
||||
for dataset_id in user_datasets['datasets']:
|
||||
|
|
Loading…
Reference in New Issue