Skip to content

Commit

Permalink
[#1273] fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Nov 19, 2013
1 parent 091eb3b commit 57397c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -142,15 +142,15 @@ def resource_dictize(res, context):
model = context['model']
resource = d.table_dictize(res, context)
resource_group_id = resource['resource_group_id']
resource_group = model.Session.query(
model.ResourceGroup).get(resource_group_id)
extras = resource.pop("extras", None)
if extras:
resource.update(extras)
resource['format'] = _unified_resource_format(res.format)
# some urls do not have the protocol this adds http:// to these
url = resource['url']
if resource.get('url_type') == 'upload' and not context.get('for_edit'):
resource_group = model.Session.query(
model.ResourceGroup).get(resource_group_id)
last_part = url.split('/')[-1]
cleaned_name = munge.munge_filename(last_part)
resource['url'] = h.url_for(controller='package',
Expand Down
3 changes: 3 additions & 0 deletions ckan/lib/uploader.py
Expand Up @@ -151,6 +151,7 @@ class ResourceUpload(object):
def __init__(self, resource):
path = get_storage_path()
if not path:
self.storage_path = None
return
self.storage_path = os.path.join(path, 'resources')
try:
Expand Down Expand Up @@ -187,6 +188,8 @@ def get_path(self, id):


def upload(self, id, max_size=10):
if not self.storage_path:
return
directory = self.get_directory(id)
filepath = self.get_path(id)
if self.filename:
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/action/update.py
Expand Up @@ -235,7 +235,7 @@ def resource_update(context, data_dict):
resource = pkg_dict['resources'][n]
upload.upload(resource['id'], uploader.get_max_resource_size())
model.repo.commit()
return resource
return _get_action('resource_show')(context, {'id': id})


def package_update(context, data_dict):
Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/logic/test_action.py
Expand Up @@ -832,10 +832,10 @@ def test_19_update_resource(self):

resource_updated.pop('url')
resource_updated.pop('revision_id')
resource_updated.pop('revision_timestamp')
resource_updated.pop('revision_timestamp', None)
resource_created.pop('url')
resource_created.pop('revision_id')
resource_created.pop('revision_timestamp')
resource_created.pop('revision_timestamp', None)
assert_equal(resource_updated, resource_created)

def test_20_task_status_update(self):
Expand Down

0 comments on commit 57397c2

Please sign in to comment.