Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/tests/conftest.py
# Copyright (C) 2016-2020 The Software Heritage developers | # Copyright (C) 2016-2021 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 | |||||
import pytest | import pytest | ||||
from swh.scheduler.model import ListedOrigin, Lister | from swh.scheduler.model import ListedOrigin, Lister | ||||
from swh.scheduler.tests.common import LISTERS | from swh.scheduler.tests.common import LISTERS | ||||
# make sure we are not fooled by CELERY_ config environment vars | # make sure we are not fooled by CELERY_ config environment vars | ||||
for var in [x for x in os.environ.keys() if x.startswith("CELERY")]: | for var in [x for x in os.environ.keys() if x.startswith("CELERY")]: | ||||
Show All 38 Lines | return { | ||||
for j, visit_type in enumerate(visit_types) | for j, visit_type in enumerate(visit_types) | ||||
} | } | ||||
@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 | |||||
def storage(swh_storage): | |||||
"""An instance of in-memory storage that gets injected | |||||
into the CLI functions.""" | |||||
with patch("swh.storage.get_storage") as get_storage_mock: | |||||
get_storage_mock.return_value = swh_storage | |||||
yield swh_storage |