-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_test.py
More file actions
49 lines (39 loc) · 1.43 KB
/
template_test.py
File metadata and controls
49 lines (39 loc) · 1.43 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Test a simplified template use-case."""
import subprocess
from copy import deepcopy
import pytest
from copier import run_copy
@pytest.fixture(scope="module", params=["Apache-2.0"])
def template_project(request, tmp_path_factory, template_path, simple_answers):
"""Run the template in a temporary location, for further testing."""
path = tmp_path_factory.mktemp(request.param)
modified_answers = deepcopy(simple_answers)
modified_answers.update(license=request.param)
run_copy(
src_path=str(template_path),
dst_path=str(path),
data=modified_answers,
vcs_ref="HEAD", # Use the latest version for the test
)
return path
@pytest.fixture(scope="module")
def pixi_built(template_project):
"""Create a pixi environment for the temporary template project."""
pixi_config = template_project / "pixi.toml"
subprocess.run(
f"pixi install --manifest-path {pixi_config}",
shell=True,
cwd=template_project,
check=True,
)
return template_project
def test_pytest(pixi_built):
"""The template's tests should pass by default."""
assert subprocess.run(
"pixi run test-integration", shell=True, check=True, cwd=pixi_built
)
def test_linting(pixi_built):
"""The generated project should result in perfect snakemake linting."""
assert subprocess.run(
"pixi run snakemake --lint", shell=True, check=True, cwd=pixi_built
)