Skip to content
Snippets Groups Projects
Commit fa0b1de2 authored by vlorentz's avatar vlorentz
Browse files

metadata_dictionary: Fix crash on null list item in an uri_field.

parent a0fdaedd
No related branches found
No related tags found
No related merge requests found
......@@ -243,7 +243,8 @@ class DictMapping(BaseMapping):
graph.add((root, codemeta_key, rdflib.URIRef(v)))
elif k in self.uri_fields and isinstance(v, list):
for item in v:
graph.add((root, codemeta_key, rdflib.URIRef(item)))
if isinstance(item, str):
graph.add((root, codemeta_key, rdflib.URIRef(item)))
else:
continue
......
......@@ -160,6 +160,28 @@ def test_index_content_metadata_npm(storage, obj_storage):
assert expected_results == results
def test_npm_null_list_item_normalization():
package_json = b"""{
"name": "foo",
"keywords": [
"foo",
null
],
"homepage": [
"http://example.org/",
null
]
}"""
result = MAPPINGS["NpmMapping"]().translate(package_json)
assert result == {
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"name": "foo",
"type": "SoftwareSourceCode",
"url": "http://example.org/",
"keywords": "foo",
}
def test_npm_bugs_normalization():
# valid dictionary
package_json = b"""{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment