Skip to content

Commit 00b7bd1

Browse files
committed
Clean up tests and make parent optional
1 parent 92ba34f commit 00b7bd1

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ def full_rdm_record():
147147
{"scheme": "orcid", "identifier": "0000-0001-8135-3489"}
148148
],
149149
},
150-
"affiliations": [{"name": "free-text"}, {"id": "01ggx4157"}],
150+
"affiliations": [
151+
{"name": "free-text"},
152+
{"name": "CERN", "id": "01ggx4157"},
153+
],
151154
}
152155
],
153156
"title": "InvenioRDM",
@@ -176,7 +179,7 @@ def full_rdm_record():
176179
],
177180
},
178181
"role": {"id": "other"},
179-
"affiliations": [{"id": "01ggx4157"}],
182+
"affiliations": [{"name": "CERN", "id": "01ggx4157"}],
180183
}
181184
],
182185
"dates": [
@@ -227,7 +230,9 @@ def full_rdm_record():
227230
"funding": [
228231
{
229232
"funder": {
230-
"name": "European Commission",
233+
"title": {
234+
"en": "OpenAIRE",
235+
},
231236
"identifier": "00k4n6c32",
232237
"scheme": "ror",
233238
},

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+
identifiers = []
16+
for identifier in full_datacite43_record["identifiers"]:
17+
if identifier["identifierType"] != "DOI":
18+
identifiers.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)