Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/tests/conftest.py
# Copyright (C) 2016-2021 The Software Heritage developers | # Copyright (C) 2016-2022 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 datetime import datetime, timezone | from datetime import datetime, timezone | ||||
import os | import os | ||||
from typing import Dict, List | from typing import Dict, List | ||||
from unittest.mock import patch | from unittest.mock import patch | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
@pytest.fixture | @pytest.fixture | ||||
def listed_origins(listed_origins_by_type) -> List[ListedOrigin]: | def listed_origins(listed_origins_by_type) -> List[ListedOrigin]: | ||||
"""Return a (fixed) set of listed origins""" | """Return a (fixed) set of listed origins""" | ||||
return sum(listed_origins_by_type.values(), []) | return sum(listed_origins_by_type.values(), []) | ||||
@pytest.fixture | @pytest.fixture | ||||
def listed_origins_with_non_enabled(listed_origins) -> List[ListedOrigin]: | |||||
"""Return a (fixed) set of listed origins""" | |||||
for i, origin in enumerate(listed_origins): | |||||
origin.enabled = i % 2 == 0 | |||||
return listed_origins | |||||
@pytest.fixture | |||||
def storage(swh_storage): | def storage(swh_storage): | ||||
"""An instance of in-memory storage that gets injected | """An instance of in-memory storage that gets injected | ||||
into the CLI functions.""" | into the CLI functions.""" | ||||
with patch("swh.storage.get_storage") as get_storage_mock: | with patch("swh.storage.get_storage") as get_storage_mock: | ||||
get_storage_mock.return_value = swh_storage | get_storage_mock.return_value = swh_storage | ||||
yield swh_storage | yield swh_storage |