Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/conftest.py
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | def sample_archive(tmp_path): | ||||
""" | """ | ||||
tmp_path = str(tmp_path) # pytest version limitation in previous version | tmp_path = str(tmp_path) # pytest version limitation in previous version | ||||
archive = create_arborescence_archive( | archive = create_arborescence_archive( | ||||
tmp_path, 'archive1', 'file1', b'some content in file') | tmp_path, 'archive1', 'file1', b'some content in file') | ||||
return archive | 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( | def create_deposit( | ||||
authenticated_client, collection_name: str, sample_archive, | authenticated_client, collection_name: str, sample_archive, | ||||
external_id: str, deposit_status=DEPOSIT_STATUS_DEPOSITED): | external_id: str, deposit_status=DEPOSIT_STATUS_DEPOSITED): | ||||
"""Create a skeleton shell deposit | """Create a skeleton shell deposit | ||||
""" | """ | ||||
url = reverse(COL_IRI, args=[collection_name]) | url = reverse(COL_IRI, args=[collection_name]) | ||||
# when | # when | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |