Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_utils.py
Show First 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | def get(self, sha1): | ||||
return raw_content | return raw_content | ||||
class MockIndexerStorage(): | class MockIndexerStorage(): | ||||
"""Mock an swh-indexer storage. | """Mock an swh-indexer storage. | ||||
""" | """ | ||||
added_data = [] | added_data = [] | ||||
revision_metadata = {} | |||||
def indexer_configuration_add(self, tools): | def indexer_configuration_add(self, tools): | ||||
results = [] | results = [] | ||||
for tool in tools: | for tool in tools: | ||||
results.append(self._indexer_configuration_add_one(tool)) | results.append(self._indexer_configuration_add_one(tool)) | ||||
return results | return results | ||||
def _indexer_configuration_add_one(self, tool): | def _indexer_configuration_add_one(self, tool): | ||||
Show All 30 Lines | class MockIndexerStorage(): | ||||
def content_metadata_missing(self, sha1s): | def content_metadata_missing(self, sha1s): | ||||
yield from [] | yield from [] | ||||
def content_metadata_add(self, metadata, conflict_update=None): | def content_metadata_add(self, metadata, conflict_update=None): | ||||
self.added_data.append( | self.added_data.append( | ||||
('content_metadata', conflict_update, metadata)) | ('content_metadata', conflict_update, metadata)) | ||||
def revision_metadata_add(self, metadata, conflict_update=None): | def revision_metadata_add(self, metadata, conflict_update=None): | ||||
assert conflict_update | |||||
self.added_data.append( | self.added_data.append( | ||||
('revision_metadata', conflict_update, metadata)) | ('revision_metadata', conflict_update, metadata)) | ||||
for item in metadata: | |||||
self.revision_metadata[item['id']] = item | |||||
def revision_metadata_get(self, ids): | |||||
res = {} | |||||
for id_ in ids: | |||||
res[id_] = self.revision_metadata.get(id_) | |||||
return res | |||||
def origin_intrinsic_metadata_add(self, metadata, conflict_update=None): | def origin_intrinsic_metadata_add(self, metadata, conflict_update=None): | ||||
self.added_data.append( | self.added_data.append( | ||||
('origin_intrinsic_metadata', conflict_update, metadata)) | ('origin_intrinsic_metadata', conflict_update, metadata)) | ||||
def content_metadata_get(self, sha1s): | def content_metadata_get(self, sha1s): | ||||
return [{ | return [{ | ||||
'tool': { | 'tool': { | ||||
▲ Show 20 Lines • Show All 393 Lines • Show Last 20 Lines |