Skip to content

Commit 5c528ef

Browse files
committed
Clean up tests and make parent optional
1 parent 92ba34f commit 5c528ef

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

caltechdata_api/customize_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ def customize_schema_rdm(json_record):
373373
if "community" in json_record:
374374
com = json_record.pop("community")
375375
parent["communities"] = {"ids": [com], "default": com}
376-
final["parent"] = parent
376+
if parent != {}:
377+
final["parent"] = parent
377378
# Not technically datacite, but transfer pids information
378379
if "pids" in json_record:
379380
final["pids"] = json_record.pop("pids")

tests/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def full_rdm_record():
147147
{"scheme": "orcid", "identifier": "0000-0001-8135-3489"}
148148
],
149149
},
150-
"affiliations": [{"name": "free-text"}, {"id": "01ggx4157"}],
150+
"affiliations": [{"name": "free-text"}, {"name": "CERN", "id": "01ggx4157"}],
151151
}
152152
],
153153
"title": "InvenioRDM",
@@ -176,7 +176,7 @@ def full_rdm_record():
176176
],
177177
},
178178
"role": {"id": "other"},
179-
"affiliations": [{"id": "01ggx4157"}],
179+
"affiliations": [{"name": "CERN", "id": "01ggx4157"}],
180180
}
181181
],
182182
"dates": [
@@ -227,7 +227,9 @@ def full_rdm_record():
227227
"funding": [
228228
{
229229
"funder": {
230-
"name": "European Commission",
230+
"title": {
231+
"en": "OpenAIRE",
232+
},
231233
"identifier": "00k4n6c32",
232234
"scheme": "ror",
233235
},

tests/test_rdm.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99

1010

1111
def test_datacite_rdm_conversion(full_datacite43_record, full_rdm_record):
12+
13+
# Remove DOI from full_datacite43_record
14+
# since it's prcessed by caltechdata_write or caltechdata_edit
15+
identifers = []
16+
for identifier in full_datacite43_record["identifiers"]:
17+
if identifer[identifiersType] != "DOI":
18+
identifers.append(identifier)
19+
full_datacite43_record["identifiers"] = identifiers
20+
1221
converted = customize_schema(full_datacite43_record, schema="43")
1322

1423
assert converted == full_rdm_record

0 commit comments

Comments
 (0)