def test_funding_ref_v4(db, minimal_record_model, recid_pid): """Test creators.""" minimal_record_model.update({ 'grants': [ { 'title': 'Grant Title', 'code': '1234', 'identifiers': { 'eurepo': 'eurepo 1' }, 'internal_id': '10.1234/foo::1234', 'funder': { 'name': 'EC', 'doi': '10.1234/foo' } }, { 'title': 'Title Grant', 'code': '4321', 'identifiers': { 'eurepo': 'eurepo 2' }, 'internal_id': '10.1234/foo::4321', 'funder': { 'name': 'EC', 'doi': '10.1234/foo' } }, ] }) obj = datacite_v41.transform_record(recid_pid, minimal_record_model) assert obj['fundingReferences'] == [{ 'funderName': 'EC', 'funderIdentifier': { 'funderIdentifier': '10.1234/foo', 'funderIdentifierType': 'Crossref Funder ID', }, 'awardNumber': { 'awardNumber': '1234', 'awardURI': 'eurepo 1' }, 'awardTitle': 'Grant Title' }, { 'funderName': 'EC', 'funderIdentifier': { 'funderIdentifier': '10.1234/foo', 'funderIdentifierType': 'Crossref Funder ID', }, 'awardNumber': { 'awardNumber': '4321', 'awardURI': 'eurepo 2' }, 'awardTitle': 'Title Grant' }]
def test_contributors_v4(db, minimal_record_model, recid_pid): """Test creators.""" minimal_record_model.update({ 'contributors': [ { 'name': 'A, B', 'affiliation': 'AA', 'gnd': '1234', 'orcid': '0000-0000-0000-0000', 'type': 'Researcher' }, ], 'thesis': { 'supervisors': [{ 'name': 'B', 'affiliation': 'BA', 'type': 'Supervisor' }] } }) obj = datacite_v41.transform_record(recid_pid, minimal_record_model) assert obj['contributors'] == [ { 'affiliations': ['AA'], 'contributorName': 'A, B', 'givenName': 'B', 'familyName': 'A', 'contributorType': 'Researcher', 'nameIdentifiers': [ { 'nameIdentifier': '0000-0000-0000-0000', 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/' }, { 'nameIdentifier': '1234', 'nameIdentifierScheme': 'GND' }, ] }, { 'affiliations': ['BA'], 'contributorName': 'B', 'givenName': '', 'familyName': '', 'contributorType': 'Supervisor', 'nameIdentifiers': [], }, ]
def test_creators_v4(db, minimal_record_model, recid_pid): """Test creators.""" minimal_record_model.update({ 'creators': [ { 'name': 'A, B', 'affiliation': 'AA', 'gnd': '1234' }, { 'name': 'B', 'affiliation': 'BA', 'orcid': '0000-0000-0000-0000', 'gnd': '4321' }, ] }) obj = datacite_v41.transform_record(recid_pid, minimal_record_model) assert obj['creators'] == [{ 'affiliations': ['AA'], 'creatorName': 'A, B', 'givenName': 'B', 'familyName': 'A', 'nameIdentifiers': [{ 'nameIdentifier': '1234', 'nameIdentifierScheme': 'GND' }] }, { 'affiliations': ['BA'], 'creatorName': 'B', 'givenName': '', 'familyName': '', 'nameIdentifiers': [{ 'nameIdentifier': '0000-0000-0000-0000', 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/' }, { 'nameIdentifier': '4321', 'nameIdentifierScheme': 'GND' }] }]
def test_contributors_v4(db, minimal_record_model, recid_pid): """Test creators.""" minimal_record_model.update({ 'contributors': [{ 'name': 'A, B', 'affiliation': 'AA', 'gnd': '1234', 'orcid': '0000-0000-0000-0000', 'type': 'Researcher' }, ], 'thesis': { 'supervisors': [{ 'name': 'B', 'affiliation': 'BA', 'type': 'Supervisor' }] } }) obj = datacite_v41.transform_record(recid_pid, minimal_record_model) assert obj['contributors'] == [ { 'affiliations': ['AA'], 'contributorName': 'A, B', 'givenName': 'B', 'familyName': 'A', 'contributorType': 'Researcher', 'nameIdentifiers': [ { 'nameIdentifier': '0000-0000-0000-0000', 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/'}, { 'nameIdentifier': '1234', 'nameIdentifierScheme': 'GND'}, ] }, { 'affiliations': ['BA'], 'contributorName': 'B', 'givenName': '', 'familyName': '', 'contributorType': 'Supervisor', 'nameIdentifiers': [], }, ]
def test_funding_ref_v4(db, minimal_record_model, recid_pid): """Test creators.""" minimal_record_model.update({ 'grants': [ {'title': 'Grant Title', 'code': '1234', 'identifiers': {'eurepo': 'eurepo 1'}, 'internal_id': '10.1234/foo::1234', 'funder': {'name': 'EC', 'doi': '10.1234/foo'}}, {'title': 'Title Grant', 'code': '4321', 'identifiers': {'eurepo': 'eurepo 2'}, 'internal_id': '10.1234/foo::4321', 'funder': {'name': 'EC', 'doi': '10.1234/foo'}}, ]}) obj = datacite_v41.transform_record(recid_pid, minimal_record_model) assert obj['fundingReferences'] == [ { 'funderName': 'EC', 'funderIdentifier': { 'funderIdentifier': '10.1234/foo', 'funderIdentifierType': 'Crossref Funder ID', }, 'awardNumber': { 'awardNumber': '1234', 'awardURI': 'eurepo 1' }, 'awardTitle': 'Grant Title' }, { 'funderName': 'EC', 'funderIdentifier': { 'funderIdentifier': '10.1234/foo', 'funderIdentifierType': 'Crossref Funder ID', }, 'awardNumber': { 'awardNumber': '4321', 'awardURI': 'eurepo 2' }, 'awardTitle': 'Title Grant' } ]
def test_creators_v4(db, minimal_record_model, recid_pid): """Test creators.""" minimal_record_model.update({ 'creators': [ {'name': 'A, B', 'affiliation': 'AA', 'gnd': '1234'}, { 'name': 'B', 'affiliation': 'BA', 'orcid': '0000-0000-0000-0000', 'gnd': '4321' }, ]}) obj = datacite_v41.transform_record(recid_pid, minimal_record_model) assert obj['creators'] == [{ 'affiliations': ['AA'], 'creatorName': 'A, B', 'givenName': 'B', 'familyName': 'A', 'nameIdentifiers': [{ 'nameIdentifier': '1234', 'nameIdentifierScheme': 'GND' }]}, { 'affiliations': ['BA'], 'creatorName': 'B', 'givenName': '', 'familyName': '', 'nameIdentifiers': [{ 'nameIdentifier': '0000-0000-0000-0000', 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/' }, { 'nameIdentifier': '4321', 'nameIdentifierScheme': 'GND' }] } ]
def test_full(db, record_with_bucket, recid_pid): """Test full record metadata.""" _, full_record_model = record_with_bucket full_record_model['doi'] = '10.1234/foo' obj = datacite_v31.transform_record(recid_pid, full_record_model) expected = { "alternateIdentifiers": [ { "alternateIdentifier": "urn:lsid:ubio.org:namebank:11815", "alternateIdentifierType": "lsid" }, { "alternateIdentifier": "2011ApJS..192...18K", "alternateIdentifierType": "ads" }, { 'alternateIdentifier': '0317-8471', 'alternateIdentifierType': 'issn', }, { "alternateIdentifier": "10.1234/alternate.doi", "alternateIdentifierType": "doi" }, { "alternateIdentifier": "http://localhost/record/12345", "alternateIdentifierType": "url" }, ], "contributors": [{ "affiliation": "CERN", "contributorName": "Smith, Other", "contributorType": "Other", "nameIdentifier": { "nameIdentifier": "0000-0002-1825-0097", "nameIdentifierScheme": "ORCID", "schemeURI": "http://orcid.org/" } }, { "affiliation": "", "contributorName": "Hansen, Viggo", "contributorType": "Other", "nameIdentifier": {} }, { "affiliation": "CERN", "contributorName": "Kowalski, Manager", "contributorType": "DataManager", "nameIdentifier": {} }], "creators": [{ "affiliation": "CERN", "creatorName": "Doe, John", "nameIdentifier": { "nameIdentifier": "0000-0002-1694-233X", "nameIdentifierScheme": "ORCID", "schemeURI": "http://orcid.org/" } }, { "affiliation": "CERN", "creatorName": "Doe, Jane", "nameIdentifier": { "nameIdentifier": "0000-0002-1825-0097", "nameIdentifierScheme": "ORCID", "schemeURI": "http://orcid.org/" } }, { "affiliation": "CERN", "creatorName": "Smith, John", "nameIdentifier": {} }, { "affiliation": "CERN", "creatorName": "Nowak, Jack", "nameIdentifier": { "nameIdentifier": "170118215", "nameIdentifierScheme": "GND" } }], "dates": [{ "date": "2014-02-27", "dateType": "Issued" }], "descriptions": [{ "description": "Test Description", "descriptionType": "Abstract" }, { "description": "notes", "descriptionType": "Other" }, { "description": ("{\"references\": [\"Doe, John et al (2012). " "Some title. Zenodo. 10.5281/zenodo.12\", \"Smith, " "Jane et al (2012). Some title. Zenodo. " "10.5281/zenodo.34\"]}"), "descriptionType": "Other" }], "identifier": { "identifier": "10.1234/foo", "identifierType": "DOI" }, "language": "en", "publicationYear": "2014", "publisher": "Zenodo", "relatedIdentifiers": [{ "relationType": "Cites", "relatedIdentifier": "10.1234/foo.bar", "relatedIdentifierType": "DOI" }, { "relationType": "IsIdenticalTo", "relatedIdentifier": "1234.4325", "relatedIdentifierType": "arXiv" }, { "relationType": "Cites", "relatedIdentifier": "1234.4321", "relatedIdentifierType": "arXiv" }, { "relationType": "References", "relatedIdentifier": "1234.4328", "relatedIdentifierType": "arXiv" }, { "relationType": "IsPartOf", "relatedIdentifier": "10.1234/zenodo.4321", "relatedIdentifierType": "DOI" }, { "relationType": "HasPart", "relatedIdentifier": "10.1234/zenodo.1234", "relatedIdentifierType": "DOI" }], "resourceType": { "resourceType": "Book", "resourceTypeGeneral": "Text" }, "rightsList": [{ "rights": "Creative Commons Attribution 4.0", "rightsURI": "https://creativecommons.org/licenses/by/4.0/" }, { "rights": "Open Access", "rightsURI": "info:eu-repo/semantics/openAccess" }], "subjects": [{ "subject": "kw1" }, { "subject": "kw2" }, { "subject": "kw3" }, { "subject": "http://id.loc.gov/authorities/subjects/sh85009003", "subjectScheme": "url" }], "titles": [{ "title": "Test Title" }], "version": "1.2.5" } assert obj == expected obj = datacite_v41.transform_record(recid_pid, full_record_model) expected['creators'] = [{ 'affiliations': ['CERN'], 'creatorName': 'Doe, John', 'familyName': 'Doe', 'givenName': 'John', 'nameIdentifiers': [{ 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/', 'nameIdentifier': '0000-0002-1694-233X' }, { 'nameIdentifierScheme': 'GND', 'nameIdentifier': '170118215' }], }, { 'affiliations': ['CERN'], 'creatorName': 'Doe, Jane', 'familyName': 'Doe', 'givenName': 'Jane', 'nameIdentifiers': [{ 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/', 'nameIdentifier': '0000-0002-1825-0097' }], }, { 'affiliations': ['CERN'], 'creatorName': 'Smith, John', 'familyName': 'Smith', 'givenName': 'John', 'nameIdentifiers': [], }, { 'affiliations': ['CERN'], 'creatorName': 'Nowak, Jack', 'familyName': 'Nowak', 'givenName': 'Jack', 'nameIdentifiers': [{ 'nameIdentifierScheme': 'GND', 'nameIdentifier': '170118215' }], }] expected['contributors'] = [{ 'affiliations': ['CERN'], 'nameIdentifiers': [{ 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/', 'nameIdentifier': '0000-0002-1825-0097' }], 'contributorName': 'Smith, Other', 'familyName': 'Smith', 'givenName': 'Other', 'contributorType': 'Other', }, { 'affiliations': [''], 'nameIdentifiers': [], 'contributorName': 'Hansen, Viggo', 'familyName': 'Hansen', 'givenName': 'Viggo', 'contributorType': 'Other', }, { 'affiliations': ['CERN'], 'nameIdentifiers': [], 'contributorName': 'Kowalski, Manager', 'familyName': 'Kowalski', 'givenName': 'Manager', 'contributorType': 'DataManager', }, { 'contributorName': 'Smith, Professor', 'familyName': 'Smith', 'givenName': 'Professor', 'nameIdentifiers': [], 'contributorType': 'Supervisor', }] expected['fundingReferences'] = [] assert obj == expected
def test_full(db, record_with_bucket, recid_pid): """Test full record metadata.""" _, full_record_model = record_with_bucket full_record_model['doi'] = '10.5072/foo' obj = datacite_v31.transform_record(recid_pid, full_record_model) expected = { "alternateIdentifiers": [ { "alternateIdentifier": "urn:lsid:ubio.org:namebank:11815", "alternateIdentifierType": "lsid" }, { "alternateIdentifier": "2011ApJS..192...18K", "alternateIdentifierType": "ads" }, { 'alternateIdentifier': '0317-8471', 'alternateIdentifierType': 'issn', }, { "alternateIdentifier": "10.1234/alternate.doi", "alternateIdentifierType": "doi" }, { "alternateIdentifier": "http://localhost/record/12345", "alternateIdentifierType": "url" }, ], "contributors": [ { "affiliation": "CERN", "contributorName": "Smith, Other", "contributorType": "Other", "nameIdentifier": { "nameIdentifier": "0000-0002-1825-0097", "nameIdentifierScheme": "ORCID", "schemeURI": "http://orcid.org/" } }, { "affiliation": "", "contributorName": "Hansen, Viggo", "contributorType": "Other", "nameIdentifier": {} }, { "affiliation": "CERN", "contributorName": "Kowalski, Manager", "contributorType": "DataManager", "nameIdentifier": {} } ], "creators": [ { "affiliation": "CERN", "creatorName": "Doe, John", "nameIdentifier": { "nameIdentifier": "0000-0002-1694-233X", "nameIdentifierScheme": "ORCID", "schemeURI": "http://orcid.org/" } }, { "affiliation": "CERN", "creatorName": "Doe, Jane", "nameIdentifier": { "nameIdentifier": "0000-0002-1825-0097", "nameIdentifierScheme": "ORCID", "schemeURI": "http://orcid.org/" } }, { "affiliation": "CERN", "creatorName": "Smith, John", "nameIdentifier": {} }, { "affiliation": "CERN", "creatorName": "Nowak, Jack", "nameIdentifier": { "nameIdentifier": "170118215", "nameIdentifierScheme": "GND" } } ], "dates": [{"date": "2014-02-27", "dateType": "Issued"}], "descriptions": [ { "description": "Test Description", "descriptionType": "Abstract" }, { "description": "notes", "descriptionType": "Other" }, { "description": ( "{\"references\": [\"Doe, John et al (2012). " "Some title. Zenodo. 10.5281/zenodo.12\", \"Smith, " "Jane et al (2012). Some title. Zenodo. " "10.5281/zenodo.34\"]}" ), "descriptionType": "Other" } ], "identifier": {"identifier": "10.5072/foo", "identifierType": "DOI"}, "language": "en", "publicationYear": "2014", "publisher": "Zenodo", "relatedIdentifiers": [ { "relationType": "Cites", "relatedIdentifier": "10.1234/foo.bar", "relatedIdentifierType": "DOI" }, { "relationType": "IsIdenticalTo", "relatedIdentifier": "1234.4325", "relatedIdentifierType": "arXiv" }, { "relationType": "Cites", "relatedIdentifier": "1234.4321", "relatedIdentifierType": "arXiv" }, { "relationType": "References", "relatedIdentifier": "1234.4328", "relatedIdentifierType": "arXiv" }, { "relationType": "IsPartOf", "relatedIdentifier": "10.1234/zenodo.4321", "relatedIdentifierType": "DOI" }, { "relationType": "HasPart", "relatedIdentifier": "10.1234/zenodo.1234", "relatedIdentifierType": "DOI" }, { "relationType": "IsPartOf", "relatedIdentifier": "http://localhost/communities/zenodo", "relatedIdentifierType": "URL" } ], "resourceType": { "resourceType": "Book", "resourceTypeGeneral": "Text" }, "rightsList": [ { "rights": "Creative Commons Attribution 4.0", "rightsURI": "https://creativecommons.org/licenses/by/4.0/" }, { "rights": "Open Access", "rightsURI": "info:eu-repo/semantics/openAccess" } ], "subjects": [ {"subject": "kw1"}, {"subject": "kw2"}, {"subject": "kw3"}, { "subject": "http://id.loc.gov/authorities/subjects/sh85009003", "subjectScheme": "url" } ], "titles": [{"title": "Test title"}], "version": "1.2.5" } assert obj == expected obj = datacite_v41.transform_record(recid_pid, full_record_model) expected['creators'] = [ { 'affiliations': ['CERN'], 'creatorName': 'Doe, John', 'familyName': 'Doe', 'givenName': 'John', 'nameIdentifiers': [ { 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/', 'nameIdentifier': '0000-0002-1694-233X' }, { 'nameIdentifierScheme': 'GND', 'nameIdentifier': '170118215' } ], }, { 'affiliations': ['CERN'], 'creatorName': 'Doe, Jane', 'familyName': 'Doe', 'givenName': 'Jane', 'nameIdentifiers': [ { 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/', 'nameIdentifier': '0000-0002-1825-0097' } ], }, { 'affiliations': ['CERN'], 'creatorName': 'Smith, John', 'familyName': 'Smith', 'givenName': 'John', 'nameIdentifiers': [], }, { 'affiliations': ['CERN'], 'creatorName': 'Nowak, Jack', 'familyName': 'Nowak', 'givenName': 'Jack', 'nameIdentifiers': [ { 'nameIdentifierScheme': 'GND', 'nameIdentifier': '170118215' } ], } ] expected['contributors'] = [ { 'affiliations': ['CERN'], 'nameIdentifiers': [ { 'nameIdentifierScheme': 'ORCID', 'schemeURI': 'http://orcid.org/', 'nameIdentifier': '0000-0002-1825-0097' } ], 'contributorName': 'Smith, Other', 'familyName': 'Smith', 'givenName': 'Other', 'contributorType': 'Other', }, { 'affiliations': [''], 'nameIdentifiers': [], 'contributorName': 'Hansen, Viggo', 'familyName': 'Hansen', 'givenName': 'Viggo', 'contributorType': 'Other', }, { 'affiliations': ['CERN'], 'nameIdentifiers': [], 'contributorName': 'Kowalski, Manager', 'familyName': 'Kowalski', 'givenName': 'Manager', 'contributorType': 'DataManager', }, { 'contributorName': 'Smith, Professor', 'familyName': 'Smith', 'givenName': 'Professor', 'nameIdentifiers': [], 'contributorType': 'Supervisor', } ] expected['fundingReferences'] = [] assert obj == expected