Skip to content

Commit 2f51084

Browse files
committed
modified test cases for bake()
1 parent db04463 commit 2f51084

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

tests/test_project_generation.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@
55
def test_version() -> None:
66
assert m.__version__
77

8-
@pytest.fixture
9-
def custom_template(tmpdir):
8+
def test_bake_project(cookies: Cookies):
109
"""
11-
Generating a project using the template into a tempdir
10+
Testing the template generation with default values
1211
"""
13-
template = tmpdir.ensure("cookiecutter-template", dir=True)
14-
template.join("cookiecutter.json").write('{"project_name": "pybamm_cookie"}')
15-
16-
repo_dir = template.ensure("{{cookiecutter.project_name}}", dir=True)
17-
repo_dir.join("README.rst").write("{{cookiecutter.project_name}}")
18-
19-
return template
12+
result = cookies.bake()
13+
assert result.exit_code == 0, f"Exited with code {result.exit_code}, expected 0"
14+
assert result.exception is None, result.exception
15+
assert result.project_path.name == "pybamm-example-project"
16+
assert result.project_path.is_dir(), f"Project directory {result.project_path} not found"
2017

2118

22-
def test_bake_custom_project(cookies: Cookies, custom_template):
19+
def test_bake_custom_project(cookies: Cookies):
2320
"""
24-
Testing if the projects exists in the tempdir
21+
Testing the template generation with custom template and checking if the projects exists in the tmp_path
2522
"""
26-
result = cookies.bake(template=str(custom_template))
23+
result = cookies.bake(extra_context={
24+
"author_full_name": "pybamm_user",
25+
"author_email": "[email protected]",
26+
"project_name": "pybamm_cookie",
27+
"project_slug": "example",
28+
"project_short_description": "This is an example pybamm cookiecutter template",
29+
"project_url": "pybamm.org",
30+
"project_version": "0.1.0",
31+
"documentation_engine": "sphinx(rst)",
32+
})
33+
2734
assert result.exit_code == 0, f"Exited with code {result.exit_code}, expected 0"
2835
assert result.exception is None, result.exception
2936
assert result.project_path.name == "pybamm_cookie"

0 commit comments

Comments
 (0)