Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/data.py
Show First 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | for origin in _TEST_ORIGINS: | ||||
), | ), | ||||
) | ) | ||||
) | ) | ||||
for rev_log in storage.revision_shortlog(origin_revisions): | for rev_log in storage.revision_shortlog(origin_revisions): | ||||
rev_id = rev_log[0] | rev_id = rev_log[0] | ||||
revisions.add(rev_id) | revisions.add(rev_id) | ||||
for rev in storage.revision_get(origin_revisions): | for rev in storage.revision_get(sorted(origin_revisions)): | ||||
if rev is None: | if rev is None: | ||||
continue | continue | ||||
dir_id = rev.directory | dir_id = rev.directory | ||||
directories.add(hash_to_hex(dir_id)) | directories.add(hash_to_hex(dir_id)) | ||||
for entry in dir_iterator(storage, dir_id): | for entry in dir_iterator(storage, dir_id): | ||||
if entry["type"] == "file": | if entry["type"] == "file": | ||||
sha1s.add(entry["sha1"]) | sha1s.add(entry["sha1"]) | ||||
content_path[entry["sha1"]] = "/".join( | content_path[entry["sha1"]] = "/".join( | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | def _init_tests_data(): | ||||
# Return tests data | # Return tests data | ||||
return { | return { | ||||
"search": search, | "search": search, | ||||
"storage": storage, | "storage": storage, | ||||
"idx_storage": idx_storage, | "idx_storage": idx_storage, | ||||
"counters": counters, | "counters": counters, | ||||
"origins": _TEST_ORIGINS, | "origins": _TEST_ORIGINS, | ||||
"contents": contents, | "contents": list(sorted(contents, key=lambda c: c["sha1"])), | ||||
"directories": list(directories), | "directories": list(sorted(directories)), | ||||
"releases": list(releases), | "releases": list(sorted(releases)), | ||||
"revisions": list(map(hash_to_hex, revisions)), | "revisions": list(sorted(map(hash_to_hex, revisions))), | ||||
"snapshots": list(snapshots), | "snapshots": list(sorted(snapshots)), | ||||
"swhids": swhids, | "swhids": swhids, | ||||
} | } | ||||
def _init_indexers(tests_data): | def _init_indexers(tests_data): | ||||
ardumont: why do you need to sort things out here? | |||||
Done Inline ActionsSet iterations in Python do not have a guaranteed order across runs so these sorting operations here. Nevertheless swhids is a list so the sorting should not be needed here, need to check. anlambert: Set iterations in Python [[ https://stackoverflow.com/questions/3848091/set-iteration-order… | |||||
Not Done Inline Actionsright ardumont: right | |||||
# Instantiate content indexers that will be used in tests | # Instantiate content indexers that will be used in tests | ||||
# and force them to use the memory storages | # and force them to use the memory storages | ||||
indexers = {} | indexers = {} | ||||
for idx_name, idx_class, idx_config in ( | for idx_name, idx_class, idx_config in ( | ||||
("mimetype_indexer", MimetypeIndexer, _TEST_MIMETYPE_INDEXER_CONFIG), | ("mimetype_indexer", MimetypeIndexer, _TEST_MIMETYPE_INDEXER_CONFIG), | ||||
("license_indexer", FossologyLicenseIndexer, _TEST_LICENSE_INDEXER_CONFIG), | ("license_indexer", FossologyLicenseIndexer, _TEST_LICENSE_INDEXER_CONFIG), | ||||
("ctags_indexer", CtagsIndexer, _TEST_CTAGS_INDEXER_CONFIG), | ("ctags_indexer", CtagsIndexer, _TEST_CTAGS_INDEXER_CONFIG), | ||||
): | ): | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
why do you need to sort things out here?