Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_schedule.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 | ||||
import copy | |||||
import datetime | import datetime | ||||
from io import BytesIO | from io import BytesIO | ||||
from typing import Dict | |||||
from django.urls import reverse | from django.urls import reverse | ||||
import pytest | import pytest | ||||
from rest_framework import status | from rest_framework import status | ||||
from swh.deposit.config import ( | from swh.deposit.config import ( | ||||
COL_IRI, | COL_IRI, | ||||
DEPOSIT_STATUS_DEPOSITED, | DEPOSIT_STATUS_DEPOSITED, | ||||
) | ) | ||||
from swh.deposit.parsers import parse_xml | from swh.deposit.parsers import parse_xml | ||||
from ..conftest import TEST_CONFIG | |||||
TEST_CONFIG_WITH_CHECKS: Dict[str, object] = { | |||||
**TEST_CONFIG, | |||||
"checks": True, | |||||
} | |||||
@pytest.fixture() | @pytest.fixture() | ||||
def deposit_config(): | def deposit_config(deposit_config): | ||||
"""Overrides the `deposit_config` fixture define in swh/deposit/tests/conftest.py | """Overrides the `deposit_config` fixture define in swh/deposit/tests/conftest.py | ||||
to re-enable the checks.""" | to re-enable the checks.""" | ||||
return TEST_CONFIG_WITH_CHECKS | config_d = copy.deepcopy(deposit_config) | ||||
config_d["checks"] = True | |||||
return config_d | |||||
def now() -> datetime.datetime: | def now() -> datetime.datetime: | ||||
return datetime.datetime.now(tz=datetime.timezone.utc) | return datetime.datetime.now(tz=datetime.timezone.utc) | ||||
def test_add_deposit_schedules_check( | def test_add_deposit_schedules_check( | ||||
authenticated_client, deposit_collection, sample_archive, swh_scheduler | authenticated_client, deposit_collection, sample_archive, swh_scheduler | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |