Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_fossology_license.py
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | class TestFossologyLicenseIndexer(CommonContentIndexerTest, unittest.TestCase): | ||||
"""Language indexer test scenarios: | """Language indexer test scenarios: | ||||
- Known sha1s in the input list have their data indexed | - Known sha1s in the input list have their data indexed | ||||
- Unknown sha1 in the input list are not indexed | - Unknown sha1 in the input list are not indexed | ||||
""" | """ | ||||
def get_indexer_results(self, ids): | def get_indexer_results(self, ids): | ||||
yield from self.idx_storage.content_ctags_get(ids) | yield from self.idx_storage.content_fossology_license_get(ids) | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp() | super().setUp() | ||||
self.indexer = FossologyLicenseTestIndexer() | self.indexer = FossologyLicenseTestIndexer() | ||||
self.idx_storage = self.indexer.idx_storage | self.idx_storage = self.indexer.idx_storage | ||||
fill_storage(self.indexer.storage) | |||||
fill_obj_storage(self.indexer.objstorage) | |||||
self.id0 = '01c9379dfc33803963d07c1ccc748d3fe4c96bb5' | self.id0 = '01c9379dfc33803963d07c1ccc748d3fe4c96bb5' | ||||
self.id1 = '688a5ef812c53907562fe379d4b3851e69c7cb15' | self.id1 = '688a5ef812c53907562fe379d4b3851e69c7cb15' | ||||
self.id2 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709' # empty content | self.id2 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709' # empty content | ||||
tool_id = self.indexer.tool['id'] | |||||
tool = {k.replace('tool_', ''): v | |||||
for (k, v) in self.indexer.tool.items()} | |||||
# then | # then | ||||
self.expected_results = { | self.expected_results = { | ||||
self.id0: { | self.id0: { | ||||
'id': self.id0, | 'tool': tool, | ||||
'indexer_configuration_id': tool_id, | |||||
'licenses': SHA1_TO_LICENSES[self.id0], | 'licenses': SHA1_TO_LICENSES[self.id0], | ||||
}, | }, | ||||
self.id1: { | self.id1: { | ||||
'id': self.id1, | 'tool': tool, | ||||
'indexer_configuration_id': tool_id, | |||||
'licenses': SHA1_TO_LICENSES[self.id1], | 'licenses': SHA1_TO_LICENSES[self.id1], | ||||
}, | }, | ||||
self.id2: { | self.id2: { | ||||
'id': self.id2, | 'tool': tool, | ||||
'indexer_configuration_id': tool_id, | |||||
'licenses': SHA1_TO_LICENSES[self.id2], | 'licenses': SHA1_TO_LICENSES[self.id2], | ||||
} | } | ||||
} | } | ||||
class FossologyLicenseRangeIndexerTest( | class FossologyLicenseRangeIndexerTest( | ||||
NoDiskIndexer, InjectLicenseIndexer, FossologyLicenseRangeIndexer): | NoDiskIndexer, InjectLicenseIndexer, FossologyLicenseRangeIndexer): | ||||
"""Testing the range indexer on fossology license. | """Testing the range indexer on fossology license. | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |