Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the fs_filename logic when uploading a new resource on the data catalog #2547

Merged
merged 5 commits into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
- Community resources changes [#2546](https://github.com/opendatateam/udata/pull/2546):
- Dataset is now correctly set at community resource creation
- Remove now useless job 'purge-orphan-community-resources'
- Using the fs_filename logic when uploading a new resource on the data catalog.[#2547](https://github.com/opendatateam/udata/pull/2547)

## 2.3.0 (2020-09-29)

Expand Down
1 change: 1 addition & 0 deletions udata/core/dataset/tasks.py
Expand Up @@ -144,6 +144,7 @@ def store_resource(csvfile, model, dataset):
with open(csvfile.name, 'rb') as infile:
stored_filename = storage.save(infile, prefix=prefix, filename=filename)
r_info = storage.metadata(stored_filename)
r_info['fs_filename'] = stored_filename
checksum = r_info.pop('checksum')
algo, checksum = checksum.split(':', 1)
r_info[algo] = checksum
Expand Down
9 changes: 7 additions & 2 deletions udata/tests/dataset/test_dataset_tasks.py
Expand Up @@ -3,8 +3,10 @@
from udata.models import Dataset, Topic, CommunityResource
from udata.core.dataset import tasks
from udata.core.dataset.factories import DatasetFactory, CommunityResourceFactory
# csv.adapter for Tag won't be registered if this is not imported :thinking:
from udata.core.tags import csv as _ # noqa
from udata.core.dataset.csv import DatasetCsvAdapter, ResourcesCsvAdapter, IssuesOrDiscussionCsvAdapter
quaxsze marked this conversation as resolved.
Show resolved Hide resolved
from udata.core.organization.csv import OrganizationCsvAdapter
from udata.core.reuse.csv import ReuseCsvAdapter
from udata.core.tags.csv import TagCsvAdapter


pytestmark = pytest.mark.usefixtures('clean_db')
Expand Down Expand Up @@ -44,3 +46,6 @@ def test_export_csv(app):
extras = [r.extras.get('csv-export:model') for r in dataset.resources]
for model in models:
assert model in extras
fs_filenames = [r.fs_filename for r in dataset.resources]
assert fs_filenames.count(None) == 0
quaxsze marked this conversation as resolved.
Show resolved Hide resolved