Fallback to empty list when block type is not present on cache.json
This commit is contained in:
Родитель
94d9124461
Коммит
97105111c3
|
@ -114,15 +114,15 @@ class MLBFStorageLoader(BaseMLBFLoader):
|
|||
|
||||
@cached_property
|
||||
def blocked_items(self) -> List[str]:
|
||||
return self._data.get(self.data_type_key(MLBFDataType.BLOCKED))
|
||||
return self._data.get(self.data_type_key(MLBFDataType.BLOCKED), [])
|
||||
|
||||
@cached_property
|
||||
def soft_blocked_items(self) -> List[str]:
|
||||
return self._data.get(self.data_type_key(MLBFDataType.SOFT_BLOCKED))
|
||||
return self._data.get(self.data_type_key(MLBFDataType.SOFT_BLOCKED), [])
|
||||
|
||||
@cached_property
|
||||
def not_blocked_items(self) -> List[str]:
|
||||
return self._data.get(self.data_type_key(MLBFDataType.NOT_BLOCKED))
|
||||
return self._data.get(self.data_type_key(MLBFDataType.NOT_BLOCKED), [])
|
||||
|
||||
|
||||
class MLBFDataBaseLoader(BaseMLBFLoader):
|
||||
|
|
|
@ -133,6 +133,16 @@ class TestMLBFStorageLoader(_MLBFBase):
|
|||
loader = MLBFStorageLoader(self.storage)
|
||||
assert loader._raw == self._data
|
||||
|
||||
def test_fallback_to_empty_list_for_missing_key(self):
|
||||
for key in self._data.keys():
|
||||
new_data = self._data.copy()
|
||||
new_data.pop(key)
|
||||
with self.storage.open('cache.json', 'w') as f:
|
||||
json.dump(new_data, f)
|
||||
loader = MLBFStorageLoader(self.storage)
|
||||
assert loader._raw == {**new_data, key: []}
|
||||
|
||||
|
||||
|
||||
class TestMLBFDataBaseLoader(_MLBFBase):
|
||||
def test_load_returns_expected_data(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче