forked from CERNDocumentServer/cds-videos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_schema_datacite.py
More file actions
66 lines (58 loc) · 2.41 KB
/
Copy pathtest_schema_datacite.py
File metadata and controls
66 lines (58 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
#
# This file is part of CDS.
# Copyright (C) 2017 CERN.
#
# CDS is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# CDS is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with CDS; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
"""CDS schema datacite tests."""
from invenio_records.api import Record
from cds.modules.records.serializers import datacite_v41
def test_video_metadata_tranform(app, video_record_metadata, recid_pid):
"""Test video metadata transformation."""
video_record_metadata["doi"] = "10.1234/foo"
obj = datacite_v41.transform_record(recid_pid, Record(video_record_metadata))
expected = {
"creators": [
{"creatorName": "paperone"},
{"creatorName": "topolino"},
{"creatorName": "nonna papera"},
{"creatorName": "pluto"},
{"creatorName": "zio paperino"},
],
"contributors": [],
"dates": [{"date": "2017-03-02", "dateType": "Issued"}],
"descriptions": [
{
"description": "in tempor reprehenderit enim eiusmod <b>"
"<i>html</i></b>",
"descriptionType": "Abstract",
}
],
"identifier": {"identifier": "10.1234/foo", "identifierType": "DOI"},
"language": "en",
"publisher": "CERN",
"publicationYear": "2017",
"resourceType": {"resourceTypeGeneral": "Audiovisual", "resourceType": None},
"subjects": [{"subject": "keyword1"}, {"subject": "keyword2"}],
"titles": [{"title": "My <b>english</b> title"}],
}
assert expected == obj
result = datacite_v41.serialize(pid=recid_pid, record=Record(video_record_metadata))
assert "<?xml version" in result