1 | """Tests around detection whether cookiecutter templates are cached locally.""" |
||
2 | import os |
||
3 | from pathlib import Path |
||
4 | |||
5 | import pytest |
||
6 | |||
7 | from cookiecutter import repository |
||
8 | |||
9 | |||
10 | @pytest.fixture |
||
11 | def template(): |
||
12 | """Fixture. Return simple string as template name.""" |
||
13 | return 'cookiecutter-pytest-plugin' |
||
14 | |||
15 | |||
16 | @pytest.fixture |
||
17 | def cloned_cookiecutter_path(user_config_data, template): |
||
18 | """Fixture. Create fake project directory in special user folder.""" |
||
19 | cookiecutters_dir = user_config_data['cookiecutters_dir'] |
||
20 | |||
21 | cloned_template_path = os.path.join(cookiecutters_dir, template) |
||
22 | os.mkdir(cloned_template_path) |
||
23 | |||
24 | Path(cloned_template_path, "cookiecutter.json").touch() # creates file |
||
25 | |||
26 | return cloned_template_path |
||
27 | |||
28 | |||
29 | View Code Duplication | def test_should_find_existing_cookiecutter( |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
30 | template, user_config_data, cloned_cookiecutter_path |
||
31 | ): |
||
32 | """ |
||
33 | Should find folder created by `cloned_cookiecutter_path` and return it. |
||
34 | |||
35 | This folder is considered like previously cloned project directory. |
||
36 | """ |
||
37 | project_dir, cleanup = repository.determine_repo_dir( |
||
38 | template=template, |
||
39 | abbreviations={}, |
||
40 | clone_to_dir=user_config_data['cookiecutters_dir'], |
||
41 | checkout=None, |
||
42 | no_input=True, |
||
43 | ) |
||
44 | |||
45 | assert cloned_cookiecutter_path == project_dir |
||
46 | assert not cleanup |
||
47 |