Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_indexer.py
# Copyright (C) 2020 The Software Heritage developers | # Copyright (C) 2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Any, Dict, List, Optional, Union | from typing import Any, Dict, List, Optional | ||||
from unittest.mock import Mock | from unittest.mock import Mock | ||||
import pytest | import pytest | ||||
from swh.indexer.indexer import ( | from swh.indexer.indexer import ( | ||||
ContentIndexer, | ContentIndexer, | ||||
ContentPartitionIndexer, | ContentPartitionIndexer, | ||||
OriginIndexer, | OriginIndexer, | ||||
RevisionIndexer, | RevisionIndexer, | ||||
) | ) | ||||
from swh.indexer.storage import PagedResult, Sha1 | from swh.indexer.storage import PagedResult, Sha1 | ||||
from swh.model.model import Revision | |||||
from .utils import BASE_TEST_CONFIG | from .utils import BASE_TEST_CONFIG | ||||
class _TestException(Exception): | class _TestException(Exception): | ||||
pass | pass | ||||
class CrashingIndexerMixin: | class CrashingIndexerMixin: | ||||
USE_TOOLS = False | USE_TOOLS = False | ||||
def index( | def index( | ||||
self, id: Union[bytes, Dict, Revision], data: Optional[bytes] = None, **kwargs | self, id: Any, data: Optional[Any] = None, **kwargs | ||||
) -> List[Dict[str, Any]]: | ) -> List[Dict[str, Any]]: | ||||
raise _TestException() | raise _TestException() | ||||
def persist_index_computations(self, results, policy_update) -> Dict[str, int]: | def persist_index_computations(self, results, policy_update) -> Dict[str, int]: | ||||
return {} | return {} | ||||
def indexed_contents_in_partition( | def indexed_contents_in_partition( | ||||
self, partition_id: int, nb_partitions: int, page_token: Optional[str] = None | self, partition_id: int, nb_partitions: int, page_token: Optional[str] = None | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |