Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
Signed-off-by: Johnny Mariéthoz <[email protected]>
  • Loading branch information
jma committed Jan 31, 2024
1 parent 51e9fd2 commit 09d682b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 9 additions & 7 deletions sonar/modules/documents/marshmallow/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ class ThumbnailSchemaV1(StrictKeysMixin):

class Meta:
"""Meta for file schema."""
unknown = EXCLUDE

key = SanitizedUnicode()
label = SanitizedUnicode()
type = SanitizedUnicode()
order = fields.Integer()
restriction = fields.Dict(dump_only=True)
links = fields.Dict(dump_only=True)
thumbnail = SanitizedUnicode(dump_only=True)



class FileSchemaV1(ThumbnailSchemaV1):
"""File schema."""

Expand All @@ -64,20 +73,13 @@ class Meta:
bucket = SanitizedUnicode()
file_id = SanitizedUnicode()
version_id = SanitizedUnicode()
key = SanitizedUnicode()
mimetype = SanitizedUnicode()
checksum = SanitizedUnicode()
size = fields.Integer()
label = SanitizedUnicode()
type = SanitizedUnicode()
order = fields.Integer()
external_url = SanitizedUnicode()
access = SanitizedUnicode()
restricted_outside_organisation = fields.Boolean()
embargo_date = SanitizedUnicode()
restriction = fields.Dict(dump_only=True)
links = fields.Dict(dump_only=True)
thumbnail = SanitizedUnicode(dump_only=True)
permissions = fields.Dict(dump_only=True)

@pre_dump
Expand Down
6 changes: 5 additions & 1 deletion tests/api/documents/test_documents_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def test_get(client, document_with_file):
assert res.status_code == 200
assert res.json['hits']['total']['value'] == 1
# the search results does not contains permissions
assert not res.json['hits']['hits'][0]['metadata']['_files'][0].get("permissions")
fdata = res.json['hits']['hits'][0]['metadata']['_files'][0]
assert list(fdata.keys()) == [
'key', 'label', 'type', 'order', 'restriction', 'links', 'thumbnail'
]
assert not fdata.get("permissions")

# the item result should contains permissions
res = client.get(url_for('invenio_records_rest.doc_item', pid_value=document_with_file['pid']))
Expand Down

0 comments on commit 09d682b

Please sign in to comment.