Skip to content

Commit

Permalink
api: support unicode filenames
Browse files Browse the repository at this point in the history
Signed-off-by: Jacopo Notarstefano <jacopo.notarstefano@gmail.com>
  • Loading branch information
jacquerie authored and lnielsen committed Nov 28, 2017
1 parent 8988189 commit 9715a29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion invenio_records_files/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def __next__(self):
def __contains__(self, key):
"""Test if file exists."""
return ObjectVersion.get_by_bucket(
self.bucket).filter_by(key=str(key)).count()
self.bucket).filter_by(key=key).count()

def __getitem__(self, key):
"""Get a specific file."""
Expand Down
8 changes: 8 additions & 0 deletions tests/test_invenio_records_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ def test_files_property(app, db, location, bucket):
assert 'hello.txt' in record.files


def test_files_unicode(app, db, location, record_with_bucket):
record = record_with_bucket

# Create a file with a unicode filename.
record.files[u'hellö.txt'] = BytesIO(b'Hello world!')
assert u'hellö.txt' in record.files


def test_files_extra_data(app, db, location, record_with_bucket):
"""Test record files property."""
record = record_with_bucket
Expand Down

0 comments on commit 9715a29

Please sign in to comment.