Mercurial > repos > rhpvorderman > shm_csr
diff tests/test_shm_csr.py @ 6:ea9d5fc4c001 draft default tip
"planemo upload commit 9ada186a78831ca2618ec817a23a77de6adf1a5d"
| author | rhpvorderman |
|---|---|
| date | Wed, 22 Dec 2021 11:29:16 +0000 |
| parents | 495a521cf9f2 |
| children |
line wrap: on
line diff
--- a/tests/test_shm_csr.py Tue Nov 16 11:16:06 2021 +0000 +++ b/tests/test_shm_csr.py Wed Dec 22 11:29:16 2021 +0000 @@ -24,19 +24,27 @@ import sys import tempfile from pathlib import Path +from xml.etree import ElementTree +from xml.etree.ElementTree import Element import pytest -GIT_ROOT = str(Path(__file__).parent.parent.absolute()) +GIT_ROOT = Path(__file__).parent.parent.absolute() TEST_DIR = Path(__file__).parent TEST_DATA_DIR = TEST_DIR / "data" VALIDATION_DATA_DIR = TEST_DIR / "validation_data" CONTROL_NWK377_PB_IGHC_MID1_40nt_2 = TEST_DATA_DIR / "CONTROL_NWK377_PB_IGHC_MID1_40nt_2.txz" +def get_container(): + tool = ElementTree.parse(GIT_ROOT / "shm_csr.xml").getroot() + requirements: Element = tool.find("requirements") + container = requirements.find("container") + return container.text + + @pytest.fixture(scope="module") def shm_csr_result(): - docker_container = "quay.io/rhpvorderman/mulled-v2-f7d31c9d7424063a492fc0e5ecbf89bc757c0107:2b50bdd4d8c1fefc6ec24b0753fad0dcecec843b-0" temp_dir = Path(tempfile.mkdtemp()) tool_dir = temp_dir / "shm_csr" shutil.copytree(GIT_ROOT, tool_dir) @@ -86,15 +94,22 @@ fast ] docker_cmd = ["docker", "run", "-v", f"{temp_dir}:{temp_dir}", + "--rm", # Remove container after running "-v", f"{input}:{input}", "-w", str(working_dir), - docker_container] + cmd + # Run as current user which allows deletion of files. + # It also mitigates some security considerations + "-u", f"{os.getuid()}:{os.getgid()}", + # Run with default seccomp profile to mitigate mitigation slowdown + # http://mamememo.blogspot.com/2020/05/cpu-intensive-rubypython-code-runs.html + # This knocks down test runtime from 8 to 6 minutes. + "--security-opt", "seccomp=unconfined", + get_container()] + cmd with open(temp_dir / "stderr", "wt") as stderr_file: with open(temp_dir / "stdout", "wt") as stdout_file: subprocess.run(docker_cmd, cwd=working_dir, stdout=stdout_file, stderr=stderr_file, check=True) yield Path(out_files_path) - #shutil.rmtree(temp_dir) def test_check_output(shm_csr_result): @@ -103,13 +118,17 @@ @pytest.mark.parametrize("filename", os.listdir(VALIDATION_DATA_DIR)) def test_results_match_validation(shm_csr_result, filename): - if filename == "shm_overview.txt": - # TODO: Fix errors in shm_overview. - return with open(Path(shm_csr_result, filename)) as result_h: with open(Path(VALIDATION_DATA_DIR, filename)) as validate_h: for line in result_h: - assert line == validate_h.readline() + # Skip two faulty lines in shm_overview. + # TODO: Fix the issue. + validation_line = validate_h.readline() + if filename == "shm_overview.txt": + if (line.startswith("RGYW (%)") or + line.startswith("WRCY (%)")): + continue + assert line == validation_line def test_nt_overview(shm_csr_result):
