-
Notifications
You must be signed in to change notification settings - Fork 16
/
conftest.py
31 lines (25 loc) · 1 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import shutil
from pathlib import Path
from typing import Generator
import pytest
import requests
_imc_test_data_steinbock_url = (
"https://github.com/BodenmillerGroup/TestData"
"/releases/download/v1.0.7/210308_ImcTestData_steinbock.tar.gz"
)
_imc_test_data_steinbock_dir = "datasets/210308_ImcTestData/steinbock"
def _download_and_extract_asset(tmp_dir_path: Path, asset_url: str):
asset_file_path = tmp_dir_path / "asset.tar.gz"
response = requests.get(asset_url, stream=True)
if response.status_code == 200:
with asset_file_path.open(mode="wb") as f:
f.write(response.raw.read())
shutil.unpack_archive(asset_file_path, tmp_dir_path)
@pytest.fixture(scope="session")
def imc_test_data_steinbock_path(
tmp_path_factory,
) -> Generator[Path, None, None]:
tmp_dir_path = tmp_path_factory.mktemp("raw")
_download_and_extract_asset(tmp_dir_path, _imc_test_data_steinbock_url)
yield tmp_dir_path / Path(_imc_test_data_steinbock_dir)
shutil.rmtree(tmp_dir_path)