|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
from cookiecutter.main import cookiecutter |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
def test_replay_dump_template_name( |
|
6
|
|
|
monkeypatch, mocker, user_config_data, user_config_file): |
|
7
|
|
|
"""Check that replay_dump is called with a valid template_name that is |
|
8
|
|
|
not a relative path. |
|
9
|
|
|
|
|
10
|
|
|
Otherwise files such as ``..json`` are created, which are not just cryptic |
|
11
|
|
|
but also later mistaken for replay files of other templates if invoked with |
|
12
|
|
|
'.' and '--replay'. |
|
13
|
|
|
|
|
14
|
|
|
Change the current working directory temporarily to 'tests/fake-repo-tmpl' |
|
15
|
|
|
for this test and call cookiecutter with '.' for the target template. |
|
16
|
|
|
""" |
|
17
|
|
|
monkeypatch.chdir('tests/fake-repo-tmpl') |
|
18
|
|
|
|
|
19
|
|
|
mock_replay_dump = mocker.patch('cookiecutter.main.dump') |
|
20
|
|
|
mocker.patch('cookiecutter.main.generate_files') |
|
21
|
|
|
|
|
22
|
|
|
cookiecutter( |
|
23
|
|
|
'.', |
|
24
|
|
|
no_input=True, |
|
25
|
|
|
replay=False, |
|
26
|
|
|
config_file=user_config_file, |
|
27
|
|
|
) |
|
28
|
|
|
|
|
29
|
|
|
mock_replay_dump.assert_called_once_with( |
|
30
|
|
|
user_config_data['replay_dir'], |
|
31
|
|
|
'fake-repo-tmpl', |
|
32
|
|
|
mocker.ANY, |
|
33
|
|
|
) |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
def test_replay_load_template_name( |
|
37
|
|
|
monkeypatch, mocker, user_config_data, user_config_file): |
|
38
|
|
|
"""Check that replay_load is called with a valid template_name that is |
|
39
|
|
|
not a relative path. |
|
40
|
|
|
|
|
41
|
|
|
Change the current working directory temporarily to 'tests/fake-repo-tmpl' |
|
42
|
|
|
for this test and call cookiecutter with '.' for the target template. |
|
43
|
|
|
""" |
|
44
|
|
|
monkeypatch.chdir('tests/fake-repo-tmpl') |
|
45
|
|
|
|
|
46
|
|
|
mock_replay_load = mocker.patch('cookiecutter.main.load') |
|
47
|
|
|
mocker.patch('cookiecutter.main.generate_files') |
|
48
|
|
|
|
|
49
|
|
|
cookiecutter( |
|
50
|
|
|
'.', |
|
51
|
|
|
replay=True, |
|
52
|
|
|
config_file=user_config_file, |
|
53
|
|
|
) |
|
54
|
|
|
|
|
55
|
|
|
mock_replay_load.assert_called_once_with( |
|
56
|
|
|
user_config_data['replay_dir'], |
|
57
|
|
|
'fake-repo-tmpl', |
|
58
|
|
|
) |
|
59
|
|
|
|