Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/metadata_dictionary/test_github.py
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | def test_compute_metadata_github(): | ||||
"subscribers_count": 6 | "subscribers_count": 6 | ||||
} | } | ||||
""" | """ | ||||
result = MAPPINGS["GitHubMapping"]().translate(content) | result = MAPPINGS["GitHubMapping"]().translate(content) | ||||
assert result == { | assert result == { | ||||
"@context": CONTEXT, | "@context": CONTEXT, | ||||
"type": "forge:Repository", | "type": "forge:Repository", | ||||
"id": "https://github.com/SoftwareHeritage/swh-indexer", | |||||
"forge:forks": { | "forge:forks": { | ||||
"as:totalItems": 1, | "as:totalItems": 1, | ||||
"type": "as:OrderedCollection", | "type": "as:OrderedCollection", | ||||
}, | }, | ||||
"as:likes": { | "as:likes": { | ||||
"as:totalItems": 13, | "as:totalItems": 13, | ||||
"type": "as:Collection", | "type": "as:Collection", | ||||
}, | }, | ||||
"as:followers": { | "as:followers": { | ||||
"as:totalItems": 12, | "as:totalItems": 12, | ||||
"type": "as:Collection", | "type": "as:Collection", | ||||
}, | }, | ||||
"license": "https://spdx.org/licenses/GPL-3.0", | "license": "https://spdx.org/licenses/GPL-3.0", | ||||
"name": "SoftwareHeritage/swh-indexer", | "name": "SoftwareHeritage/swh-indexer", | ||||
"description": "GitHub mirror of Metadata indexer", | "description": "GitHub mirror of Metadata indexer", | ||||
"codeRepository": "https://github.com/SoftwareHeritage/swh-indexer", | "codeRepository": "https://github.com/SoftwareHeritage/swh-indexer.git", | ||||
"dateCreated": "2017-01-31T13:05:39Z", | "dateCreated": "2017-01-31T13:05:39Z", | ||||
"dateModified": "2022-06-22T08:02:20Z", | "dateModified": "2022-06-22T08:02:20Z", | ||||
} | } | ||||
def test_github_topics(): | def test_github_topics(): | ||||
content = b""" | content = b""" | ||||
{ | { | ||||
"html_url": "https://github.com/SoftwareHeritage/swh-indexer", | |||||
"topics": [ | "topics": [ | ||||
"foo", | "foo", | ||||
"bar" | "bar" | ||||
] | ] | ||||
} | } | ||||
""" | """ | ||||
result = MAPPINGS["GitHubMapping"]().translate(content) | result = MAPPINGS["GitHubMapping"]().translate(content) | ||||
assert set(result.pop("keywords", [])) == {"foo", "bar"}, result | assert set(result.pop("keywords", [])) == {"foo", "bar"}, result | ||||
assert result == { | assert result == { | ||||
"@context": CONTEXT, | "@context": CONTEXT, | ||||
"type": "forge:Repository", | "type": "forge:Repository", | ||||
"id": "https://github.com/SoftwareHeritage/swh-indexer", | |||||
} | } |