Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/metadata_dictionary/test_npm.py
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | def test_npm_repository_normalization(): | ||||
assert result == { | assert result == { | ||||
"@context": "https://doi.org/10.5063/schema/codemeta-2.0", | "@context": "https://doi.org/10.5063/schema/codemeta-2.0", | ||||
"name": "foo", | "name": "foo", | ||||
"codeRepository": "git+https://gitlab.com/user/repo.git", | "codeRepository": "git+https://gitlab.com/user/repo.git", | ||||
"type": "SoftwareSourceCode", | "type": "SoftwareSourceCode", | ||||
} | } | ||||
def test_npm_author(): | |||||
package_json = rb"""{ | |||||
"version": "1.0.0", | |||||
"author": "Foo Bar (@example)" | |||||
}""" | |||||
result = MAPPINGS["NpmMapping"]().translate(package_json) | |||||
assert result == { | |||||
"@context": "https://doi.org/10.5063/schema/codemeta-2.0", | |||||
"type": "SoftwareSourceCode", | |||||
"author": [{"name": "Foo Bar", "type": "Person"}], | |||||
"version": "1.0.0", | |||||
} | |||||
def test_npm_invalid_uris(): | def test_npm_invalid_uris(): | ||||
package_json = rb"""{ | package_json = rb"""{ | ||||
"version": "1.0.0", | "version": "1.0.0", | ||||
"homepage": "", | "homepage": "", | ||||
"author": { | "author": { | ||||
"name": "foo", | "name": "foo", | ||||
"url": "http://example.org" | "url": "http://example.org" | ||||
} | } | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |