diff --git a/swh/deposit/tests/api/conftest.py b/swh/deposit/tests/api/conftest.py --- a/swh/deposit/tests/api/conftest.py +++ b/swh/deposit/tests/api/conftest.py @@ -7,8 +7,6 @@ import pytest from django.urls import reverse -from os import path, listdir -from typing import Mapping from swh.deposit.config import ( DEPOSIT_STATUS_DEPOSITED, COL_IRI, DEPOSIT_STATUS_VERIFIED @@ -19,28 +17,6 @@ from swh.deposit.api.private.deposit_check import SWHChecksDeposit -@pytest.fixture -def atom_dataset(datadir) -> Mapping[str, bytes]: - """Compute the paths to atom files. - - Returns: - Dict of atom name per content (bytes) - - """ - atom_path = path.join(datadir, 'atom') - data = {} - for filename in listdir(atom_path): - filepath = path.join(atom_path, filename) - with open(filepath, 'rb') as f: - raw_content = f.read() - - # Keep the filename without extension - atom_name = filename.split('.')[0] - data[atom_name] = raw_content - - return data - - @pytest.fixture def ready_deposit_ok(partial_deposit_with_metadata): """Returns a deposit ready for checks (it will pass the checks). diff --git a/swh/deposit/tests/api/data/atom b/swh/deposit/tests/api/data/atom new file mode 120000 --- /dev/null +++ b/swh/deposit/tests/api/data/atom @@ -0,0 +1 @@ +../../data/atom \ No newline at end of file diff --git a/swh/deposit/tests/cli/data/atom b/swh/deposit/tests/cli/data/atom new file mode 120000 --- /dev/null +++ b/swh/deposit/tests/cli/data/atom @@ -0,0 +1 @@ +../../data/atom \ No newline at end of file diff --git a/swh/deposit/tests/conftest.py b/swh/deposit/tests/conftest.py --- a/swh/deposit/tests/conftest.py +++ b/swh/deposit/tests/conftest.py @@ -163,6 +163,28 @@ return archive +@pytest.fixture +def atom_dataset(datadir) -> Mapping[str, bytes]: + """Compute the paths to atom files. + + Returns: + Dict of atom name per content (bytes) + + """ + atom_path = os.path.join(datadir, 'atom') + data = {} + for filename in os.listdir(atom_path): + filepath = os.path.join(atom_path, filename) + with open(filepath, 'rb') as f: + raw_content = f.read() + + # Keep the filename without extension + atom_name = filename.split('.')[0] + data[atom_name] = raw_content + + return data + + def create_deposit( authenticated_client, collection_name: str, sample_archive, external_id: str, deposit_status=DEPOSIT_STATUS_DEPOSITED): diff --git a/swh/deposit/tests/api/data/atom/codemeta-sample.xml b/swh/deposit/tests/data/atom/codemeta-sample.xml rename from swh/deposit/tests/api/data/atom/codemeta-sample.xml rename to swh/deposit/tests/data/atom/codemeta-sample.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data-badly-formatted.xml b/swh/deposit/tests/data/atom/entry-data-badly-formatted.xml rename from swh/deposit/tests/api/data/atom/entry-data-badly-formatted.xml rename to swh/deposit/tests/data/atom/entry-data-badly-formatted.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data-deposit-binary.xml b/swh/deposit/tests/data/atom/entry-data-deposit-binary.xml rename from swh/deposit/tests/api/data/atom/entry-data-deposit-binary.xml rename to swh/deposit/tests/data/atom/entry-data-deposit-binary.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data-empty-body.xml b/swh/deposit/tests/data/atom/entry-data-empty-body.xml rename from swh/deposit/tests/api/data/atom/entry-data-empty-body.xml rename to swh/deposit/tests/data/atom/entry-data-empty-body.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data-ko.xml b/swh/deposit/tests/data/atom/entry-data-ko.xml rename from swh/deposit/tests/api/data/atom/entry-data-ko.xml rename to swh/deposit/tests/data/atom/entry-data-ko.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data-minimal.xml b/swh/deposit/tests/data/atom/entry-data-minimal.xml rename from swh/deposit/tests/api/data/atom/entry-data-minimal.xml rename to swh/deposit/tests/data/atom/entry-data-minimal.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data-parsing-error-prone.xml b/swh/deposit/tests/data/atom/entry-data-parsing-error-prone.xml rename from swh/deposit/tests/api/data/atom/entry-data-parsing-error-prone.xml rename to swh/deposit/tests/data/atom/entry-data-parsing-error-prone.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data0.xml b/swh/deposit/tests/data/atom/entry-data0.xml rename from swh/deposit/tests/api/data/atom/entry-data0.xml rename to swh/deposit/tests/data/atom/entry-data0.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data1.xml b/swh/deposit/tests/data/atom/entry-data1.xml rename from swh/deposit/tests/api/data/atom/entry-data1.xml rename to swh/deposit/tests/data/atom/entry-data1.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data2.xml b/swh/deposit/tests/data/atom/entry-data2.xml rename from swh/deposit/tests/api/data/atom/entry-data2.xml rename to swh/deposit/tests/data/atom/entry-data2.xml diff --git a/swh/deposit/tests/api/data/atom/entry-data3.xml b/swh/deposit/tests/data/atom/entry-data3.xml rename from swh/deposit/tests/api/data/atom/entry-data3.xml rename to swh/deposit/tests/data/atom/entry-data3.xml diff --git a/swh/deposit/tests/api/data/atom/entry-update-in-place.xml b/swh/deposit/tests/data/atom/entry-update-in-place.xml rename from swh/deposit/tests/api/data/atom/entry-update-in-place.xml rename to swh/deposit/tests/data/atom/entry-update-in-place.xml diff --git a/swh/deposit/tests/api/data/atom/error-with-decimal.xml b/swh/deposit/tests/data/atom/error-with-decimal.xml rename from swh/deposit/tests/api/data/atom/error-with-decimal.xml rename to swh/deposit/tests/data/atom/error-with-decimal.xml diff --git a/swh/deposit/tests/api/data/atom/metadata.xml b/swh/deposit/tests/data/atom/metadata.xml rename from swh/deposit/tests/api/data/atom/metadata.xml rename to swh/deposit/tests/data/atom/metadata.xml diff --git a/swh/deposit/tests/api/data/atom/tei-sample.xml b/swh/deposit/tests/data/atom/tei-sample.xml rename from swh/deposit/tests/api/data/atom/tei-sample.xml rename to swh/deposit/tests/data/atom/tei-sample.xml