Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_metadata.py
Show First 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | def test_detect_metadata_package_json(self): | ||||
] | ] | ||||
# when | # when | ||||
results = detect_metadata(df) | results = detect_metadata(df) | ||||
expected_results = {"NpmMapping": [b"cde"]} | expected_results = {"NpmMapping": [b"cde"]} | ||||
# then | # then | ||||
self.assertEqual(expected_results, results) | self.assertEqual(expected_results, results) | ||||
def test_detect_metadata_codemeta_json_uppercase(self): | |||||
# given | |||||
df = [ | |||||
{ | |||||
"sha1_git": b"abc", | |||||
"name": b"index.html", | |||||
"target": b"abc", | |||||
"length": 897, | |||||
"status": "visible", | |||||
"type": "file", | |||||
"perms": 33188, | |||||
"dir_id": b"dir_a", | |||||
"sha1": b"bcd", | |||||
}, | |||||
{ | |||||
"sha1_git": b"aab", | |||||
"name": b"CODEMETA.json", | |||||
"target": b"aab", | |||||
"length": 712, | |||||
"status": "visible", | |||||
"type": "file", | |||||
"perms": 33188, | |||||
"dir_id": b"dir_a", | |||||
"sha1": b"bcd", | |||||
}, | |||||
] | |||||
# when | |||||
results = detect_metadata(df) | |||||
expected_results = {"CodemetaMapping": [b"bcd"]} | |||||
# then | |||||
self.assertEqual(expected_results, results) | |||||
def test_compute_metadata_valid_codemeta(self): | def test_compute_metadata_valid_codemeta(self): | ||||
raw_content = b"""{ | raw_content = b"""{ | ||||
"@context": "https://doi.org/10.5063/schema/codemeta-2.0", | "@context": "https://doi.org/10.5063/schema/codemeta-2.0", | ||||
"@type": "SoftwareSourceCode", | "@type": "SoftwareSourceCode", | ||||
"identifier": "CodeMeta", | "identifier": "CodeMeta", | ||||
"description": "CodeMeta is a concept vocabulary that can be used to standardize the exchange of software metadata across repositories and organizations.", | "description": "CodeMeta is a concept vocabulary that can be used to standardize the exchange of software metadata across repositories and organizations.", | ||||
"name": "CodeMeta: Minimal metadata schemas for science software and code, in JSON-LD", | "name": "CodeMeta: Minimal metadata schemas for science software and code, in JSON-LD", | ||||
"codeRepository": "https://github.com/codemeta/codemeta", | "codeRepository": "https://github.com/codemeta/codemeta", | ||||
▲ Show 20 Lines • Show All 841 Lines • Show Last 20 Lines |