Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/utils.py
Show First 20 Lines • Show All 785 Lines • ▼ Show 20 Lines | def test_generate_content_get(self): | ||||
assert actual_results["status"] == "eventful", actual_results | assert actual_results["status"] == "eventful", actual_results | ||||
def test_generate_content_get_no_result(self): | def test_generate_content_get_no_result(self): | ||||
"""No result indexed returns False""" | """No result indexed returns False""" | ||||
actual_results = self.indexer.run(1, 2**512, incremental=False) | actual_results = self.indexer.run(1, 2**512, incremental=False) | ||||
assert actual_results == {"status": "uneventful"} | assert actual_results == {"status": "uneventful"} | ||||
def mock_compute_license(path): | |||||
"""path is the content identifier""" | |||||
if isinstance(id, bytes): | |||||
path = path.decode("utf-8") | |||||
# path is something like /tmp/tmpXXX/<sha1> so we keep only the sha1 part | |||||
id_ = path.split("/")[-1] | |||||
return {"licenses": SHA1_TO_LICENSES.get(hash_to_bytes(id_), [])} |