|
5 | 5 | def test_version() -> None: |
6 | 6 | assert m.__version__ |
7 | 7 |
|
8 | | -@pytest.fixture |
9 | | -def custom_template(tmpdir): |
| 8 | +def test_bake_project(cookies: Cookies): |
10 | 9 | """ |
11 | | - Generating a project using the template into a tempdir |
| 10 | + Testing the template generation with default values |
12 | 11 | """ |
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" |
20 | 17 |
|
21 | 18 |
|
22 | | -def test_bake_custom_project(cookies: Cookies, custom_template): |
| 19 | +def test_bake_custom_project(cookies: Cookies): |
23 | 20 | """ |
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 |
25 | 22 | """ |
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 | + |
27 | 34 | assert result.exit_code == 0, f"Exited with code {result.exit_code}, expected 0" |
28 | 35 | assert result.exception is None, result.exception |
29 | 36 | assert result.project_path.name == "pybamm_cookie" |
|
0 commit comments