Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_utils.py
Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | def content_metadata_get(self, sha1s): | ||||
'context': 'NpmMapping' | 'context': 'NpmMapping' | ||||
}, | }, | ||||
'version': '0.0.1', | 'version': '0.0.1', | ||||
'id': 6, | 'id': 6, | ||||
'name': 'swh-metadata-translator' | 'name': 'swh-metadata-translator' | ||||
}, | }, | ||||
'id': b'cde', | 'id': b'cde', | ||||
'translated_metadata': { | 'translated_metadata': { | ||||
'issueTracker': { | '@context': 'https://doi.org/10.5063/schema/codemeta-2.0', | ||||
'url': 'https://github.com/librariesio/yarn-parser/issues' | 'codemeta:issueTracker': | ||||
}, | 'https://github.com/librariesio/yarn-parser/issues', | ||||
'version': '1.0.0', | 'codemeta:version': '1.0.0', | ||||
'name': 'yarn-parser', | 'codemeta:name': 'yarn-parser', | ||||
'author': 'Andrew Nesbitt', | 'codemeta:author': 'Andrew Nesbitt', | ||||
'url': 'https://github.com/librariesio/yarn-parser#readme', | 'codemeta:url': | ||||
'processorRequirements': {'node': '7.5'}, | 'https://github.com/librariesio/yarn-parser#readme', | ||||
'other': { | 'codemeta:processorRequirements': {'node': '7.5'}, | ||||
'scripts': { | 'codemeta:license': 'AGPL-3.0', | ||||
'start': 'node index.js' | 'codemeta:keywords': ['yarn', 'parse', 'lock', 'dependencies'], | ||||
}, | 'codemeta:codeRepository': | ||||
'main': 'index.js' | 'git+https://github.com/librariesio/yarn-parser.git', | ||||
}, | 'codemeta:description': | ||||
'license': 'AGPL-3.0', | 'Tiny web service for parsing yarn.lock files', | ||||
'keywords': ['yarn', 'parse', 'lock', 'dependencies'], | |||||
'codeRepository': { | |||||
'type': 'git', | |||||
'url': 'git+https://github.com/librariesio/yarn-parser.git' | |||||
}, | |||||
'description': 'Tiny web service for parsing yarn.lock files', | |||||
'softwareRequirements': { | |||||
'yarn': '^0.21.0', | |||||
'express': '^4.14.0', | |||||
'body-parser': '^1.15.2'} | |||||
} | } | ||||
}] | }] | ||||
class MockStorage(): | class MockStorage(): | ||||
"""Mock a real swh-storage storage to simplify reading indexers' | """Mock a real swh-storage storage to simplify reading indexers' | ||||
outputs. | outputs. | ||||
""" | """ | ||||
def origin_get(self, id_): | def origin_get(self, id_): | ||||
for origin in ORIGINS: | for origin in ORIGINS: | ||||
for (k, v) in id_.items(): | for (k, v) in id_.items(): | ||||
if origin[k] != v: | if origin[k] != v: | ||||
break | break | ||||
else: | else: | ||||
# This block is run if and only if we didn't break, | # This block is run iff we didn't break, ie. if all supplied | ||||
# ie. if all supplied parts of the id are set to the | # parts of the id are set to the expected value. | ||||
# expected value. | |||||
return origin | return origin | ||||
assert False, id_ | assert False, id_ | ||||
def snapshot_get_latest(self, origin_id): | def snapshot_get_latest(self, origin_id): | ||||
if origin_id in SNAPSHOTS: | if origin_id in SNAPSHOTS: | ||||
return SNAPSHOTS[origin_id] | return SNAPSHOTS[origin_id] | ||||
else: | else: | ||||
assert False, origin_id | assert False, origin_id | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |