Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/conftest.py
Show All 17 Lines | |||||
from rest_framework import status | from rest_framework import status | ||||
from rest_framework.test import APIClient | from rest_framework.test import APIClient | ||||
from typing import Mapping | from typing import Mapping | ||||
from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
from swh.model.identifiers import DIRECTORY, swhid, REVISION, SNAPSHOT | from swh.model.identifiers import DIRECTORY, swhid, REVISION, SNAPSHOT | ||||
from swh.deposit.config import setup_django_for | from swh.deposit.config import setup_django_for | ||||
from swh.deposit.parsers import parse_xml | from swh.deposit.parsers import parse_xml | ||||
from swh.deposit.config import SWHDefaultConfig | from swh.deposit.config import APIConfig | ||||
from swh.deposit.config import ( | from swh.deposit.config import ( | ||||
COL_IRI, | COL_IRI, | ||||
EDIT_SE_IRI, | EDIT_SE_IRI, | ||||
DEPOSIT_STATUS_DEPOSITED, | DEPOSIT_STATUS_DEPOSITED, | ||||
DEPOSIT_STATUS_REJECTED, | DEPOSIT_STATUS_REJECTED, | ||||
DEPOSIT_STATUS_PARTIAL, | DEPOSIT_STATUS_PARTIAL, | ||||
DEPOSIT_STATUS_LOAD_SUCCESS, | DEPOSIT_STATUS_LOAD_SUCCESS, | ||||
DEPOSIT_STATUS_VERIFIED, | DEPOSIT_STATUS_VERIFIED, | ||||
Show All 36 Lines | |||||
@pytest.fixture() | @pytest.fixture() | ||||
def deposit_config(): | def deposit_config(): | ||||
return TEST_CONFIG | return TEST_CONFIG | ||||
@pytest.fixture(autouse=True) | @pytest.fixture(autouse=True) | ||||
def deposit_autoconfig(monkeypatch, deposit_config, swh_scheduler_config): | def deposit_autoconfig(monkeypatch, deposit_config, swh_scheduler_config): | ||||
"""Enforce config for deposit classes inherited from SWHDefaultConfig.""" | """Enforce config for deposit classes inherited from APIConfig.""" | ||||
def mock_parse_config(*args, **kw): | def mock_parse_config(*args, **kw): | ||||
config = deposit_config.copy() | config = deposit_config.copy() | ||||
config["scheduler"] = { | config["scheduler"] = { | ||||
"cls": "local", | "cls": "local", | ||||
"args": swh_scheduler_config, | "args": swh_scheduler_config, | ||||
} | } | ||||
return config | return config | ||||
monkeypatch.setattr(SWHDefaultConfig, "parse_config_file", mock_parse_config) | monkeypatch.setattr(APIConfig, "parse_config_file", mock_parse_config) | ||||
scheduler = get_scheduler("local", swh_scheduler_config) | scheduler = get_scheduler("local", swh_scheduler_config) | ||||
task_type = { | task_type = { | ||||
"type": "load-deposit", | "type": "load-deposit", | ||||
"backend_name": "swh.loader.packages.deposit.tasks.LoadDeposit", | "backend_name": "swh.loader.packages.deposit.tasks.LoadDeposit", | ||||
"description": "why does this have not-null constraint?", | "description": "why does this have not-null constraint?", | ||||
} | } | ||||
scheduler.create_task_type(task_type) | scheduler.create_task_type(task_type) | ||||
▲ Show 20 Lines • Show All 330 Lines • Show Last 20 Lines |