Skip to content

Commit

Permalink
[#2003] test package_patch: get by original id
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Nov 4, 2014
1 parent d8e9cb2 commit 7e46789
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions ckan/logic/action/patch.py
@@ -1,7 +1,11 @@
'''API functions for partial updates of existing data in CKAN'''

import ckan.logic.action.update as _update
from ckan.logic import get_action as _get_action, check_access as _check_access
from ckan.logic import (
get_action as _get_action,
check_access as _check_access,
get_or_bust as _get_or_bust,
)


def package_patch(context, data_dict):
Expand All @@ -19,7 +23,6 @@ def package_patch(context, data_dict):

_check_access('package_patch', context, data_dict)

name_or_id = data_dict.get("name") or _get_or_bust(data_dict, "id")
show_context = {
'model': context['model'],
'session': context['session'],
Expand All @@ -29,7 +32,7 @@ def package_patch(context, data_dict):

package_dict = _get_action('package_show')(
show_context,
{'id': name_or_id})
{'id': _get_or_bust(data_dict, 'id')})

patched = dict(package_dict.items() + data_dict.items())
return _update.package_update(context, patched)
7 changes: 4 additions & 3 deletions ckan/new_tests/logic/action/test_patch.py
Expand Up @@ -25,6 +25,7 @@ def test_package_patch_updating_single_field(self):
assert_equals(dataset['name'], 'somethingnew')
assert_equals(dataset['notes'], 'some test now')

assert_equals(
helpers.call_action('package_show', id='somethingnew')['notes'],
'some test now')
dataset2 = helpers.call_action('package_show', id=dataset['id'])

assert_equals(dataset2['name'], 'somethingnew')
assert_equals(dataset2['notes'], 'some test now')

0 comments on commit 7e46789

Please sign in to comment.