Skip to content

Commit

Permalink
Update last_modified
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Sep 3, 2021
1 parent 31607bb commit 2274def
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ckanext/cloudstorage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ def __init__(self, resource):
self.file_upload = _get_underlying_file(upload_field_storage)
resource['url'] = self.filename
resource['url_type'] = 'upload'
resource['last_modified'] = datetime.utcnow()
elif multipart_name and self.can_use_advanced_aws:
# This means that file was successfully uploaded and stored
# at cloud.
# Currently implemented just AWS version
resource['url'] = munge.munge_filename(multipart_name)
resource['url_type'] = 'upload'
resource['last_modified'] = datetime.utcnow()
elif self._clear and resource.get('id'):
# Apparently, this is a created-but-not-commited resource whose
# file upload has been canceled. We're copying the behaviour of
Expand Down
8 changes: 3 additions & 5 deletions ckanext/cloudstorage/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import pytest
import mock

import ckan.plugins.toolkit as tk

Expand All @@ -11,12 +10,11 @@
@pytest.mark.ckan_config('ckan.plugins', 'cloudstorage')
@pytest.mark.usefixtures('with_driver_options', 'with_plugins')
class TestResourceDownload(object):
def test_utils_used_by_download_route(self, app, monkeypatch):
def test_utils_used_by_download_route(self, app, mocker):
url = tk.url_for('resource.download', id='a', resource_id='b')
func = mock.Mock(return_value='')
monkeypatch.setattr(utils, 'resource_download', func)
mocker.patch('ckanext.cloudstorage.utils.resource_download')
app.get(url)
func.assert_called_once_with('a', 'b', None)
utils.resource_doewnload.assert_called_once_with('a', 'b', None)

@pytest.mark.usefixtures('clean_db')
def test_status_codes(self, app):
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest-mock==3.6.1

0 comments on commit 2274def

Please sign in to comment.