Skip to content

Commit

Permalink
Merge c83bddf into ee02d8c
Browse files Browse the repository at this point in the history
  • Loading branch information
roksys committed Feb 14, 2019
2 parents ee02d8c + c83bddf commit d0fad3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions invenio_files_rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,8 @@ def validate_key(self, key, key_):

def __repr__(self):
"""Return representation of location."""
return '{0}:{2}:{1}'.format(
self.bucket_id, self.key, self.version_id)
return u"{0}:{2}:{1}".format(
self.bucket_id, self.key, self.version_id).encode('utf-8')

@hybrid_property
def mimetype(self):
Expand Down
12 changes: 10 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,20 @@ def test_object_create(app, db, dummy_location):
# I.e. it is considered a delete marker.
obj3 = ObjectVersion.create(b, "deleted_obj")

# Create a new object containing key in unicode
obj4 = ObjectVersion.create(b, u"hellö")

# Object __repr__
assert str(obj1) == \
"{0}:{1}:{2}".format(obj1.bucket_id, obj1.version_id, obj1.key)
u"{0}:{1}:{2}".format(
obj1.bucket_id, obj1.version_id, obj1.key).encode('utf-8')

assert str(obj4) == \
u"{0}:{1}:{2}".format(
obj4.bucket_id, obj4.version_id, obj4.key).encode('utf-8')

# Sanity check
assert ObjectVersion.query.count() == 3
assert ObjectVersion.query.count() == 4

# Assert that obj2 is the head version
obj = ObjectVersion.get(b.id, "test", version_id=obj1.version_id)
Expand Down

0 comments on commit d0fad3c

Please sign in to comment.