@@ 86-108 (lines=23) @@ | ||
83 | assert 'Project name: **Fake Project**' in f.read() |
|
84 | ||
85 | ||
86 | @pytest.mark.usefixtures('remove_fake_project_dir') |
|
87 | def test_cli_replay(mocker, cli_runner): |
|
88 | """Test cli invocation display log with `verbose` and `replay` flags.""" |
|
89 | mock_cookiecutter = mocker.patch('cookiecutter.cli.cookiecutter') |
|
90 | ||
91 | template_path = 'tests/fake-repo-pre/' |
|
92 | result = cli_runner(template_path, '--replay', '-v') |
|
93 | ||
94 | assert result.exit_code == 0 |
|
95 | mock_cookiecutter.assert_called_once_with( |
|
96 | template_path, |
|
97 | None, |
|
98 | False, |
|
99 | replay=True, |
|
100 | overwrite_if_exists=False, |
|
101 | skip_if_file_exists=False, |
|
102 | output_dir='.', |
|
103 | config_file=None, |
|
104 | default_config=False, |
|
105 | extra_context=None, |
|
106 | password=None, |
|
107 | directory=None, |
|
108 | accept_hooks=True, |
|
109 | ) |
|
110 | ||
111 | ||
@@ 316-339 (lines=24) @@ | ||
313 | ) |
|
314 | ||
315 | ||
316 | def test_default_user_config_overwrite(mocker, cli_runner, user_config_path): |
|
317 | """Test cli invocation ignores `config-file` if `default-config` passed.""" |
|
318 | mock_cookiecutter = mocker.patch('cookiecutter.cli.cookiecutter') |
|
319 | ||
320 | template_path = 'tests/fake-repo-pre/' |
|
321 | result = cli_runner( |
|
322 | template_path, '--config-file', user_config_path, '--default-config', |
|
323 | ) |
|
324 | ||
325 | assert result.exit_code == 0 |
|
326 | mock_cookiecutter.assert_called_once_with( |
|
327 | template_path, |
|
328 | None, |
|
329 | False, |
|
330 | replay=False, |
|
331 | overwrite_if_exists=False, |
|
332 | skip_if_file_exists=False, |
|
333 | output_dir='.', |
|
334 | config_file=user_config_path, |
|
335 | default_config=True, |
|
336 | extra_context=None, |
|
337 | password=None, |
|
338 | directory=None, |
|
339 | accept_hooks=True, |
|
340 | ) |
|
341 | ||
342 | ||
@@ 343-364 (lines=22) @@ | ||
340 | ) |
|
341 | ||
342 | ||
343 | def test_default_user_config(mocker, cli_runner): |
|
344 | """Test cli invocation accepts `default-config` flag correctly.""" |
|
345 | mock_cookiecutter = mocker.patch('cookiecutter.cli.cookiecutter') |
|
346 | ||
347 | template_path = 'tests/fake-repo-pre/' |
|
348 | result = cli_runner(template_path, '--default-config') |
|
349 | ||
350 | assert result.exit_code == 0 |
|
351 | mock_cookiecutter.assert_called_once_with( |
|
352 | template_path, |
|
353 | None, |
|
354 | False, |
|
355 | replay=False, |
|
356 | overwrite_if_exists=False, |
|
357 | skip_if_file_exists=False, |
|
358 | output_dir='.', |
|
359 | config_file=None, |
|
360 | default_config=True, |
|
361 | extra_context=None, |
|
362 | password=None, |
|
363 | directory=None, |
|
364 | accept_hooks=True, |
|
365 | ) |
|
366 | ||
367 | ||
@@ 291-312 (lines=22) @@ | ||
288 | return str(tmpdir.join('tests/config.yaml')) |
|
289 | ||
290 | ||
291 | def test_user_config(mocker, cli_runner, user_config_path): |
|
292 | """Test cli invocation works with `config-file` option.""" |
|
293 | mock_cookiecutter = mocker.patch('cookiecutter.cli.cookiecutter') |
|
294 | ||
295 | template_path = 'tests/fake-repo-pre/' |
|
296 | result = cli_runner(template_path, '--config-file', user_config_path) |
|
297 | ||
298 | assert result.exit_code == 0 |
|
299 | mock_cookiecutter.assert_called_once_with( |
|
300 | template_path, |
|
301 | None, |
|
302 | False, |
|
303 | replay=False, |
|
304 | overwrite_if_exists=False, |
|
305 | skip_if_file_exists=False, |
|
306 | output_dir='.', |
|
307 | config_file=user_config_path, |
|
308 | default_config=False, |
|
309 | extra_context=None, |
|
310 | password=None, |
|
311 | directory=None, |
|
312 | accept_hooks=True, |
|
313 | ) |
|
314 | ||
315 | ||
@@ 247-268 (lines=22) @@ | ||
244 | return str(tmpdir.mkdir('output')) |
|
245 | ||
246 | ||
247 | def test_cli_output_dir(mocker, cli_runner, output_dir_flag, output_dir): |
|
248 | """Test cli invocation with `output-dir` flag changes output directory.""" |
|
249 | mock_cookiecutter = mocker.patch('cookiecutter.cli.cookiecutter') |
|
250 | ||
251 | template_path = 'tests/fake-repo-pre/' |
|
252 | result = cli_runner(template_path, output_dir_flag, output_dir) |
|
253 | ||
254 | assert result.exit_code == 0 |
|
255 | mock_cookiecutter.assert_called_once_with( |
|
256 | template_path, |
|
257 | None, |
|
258 | False, |
|
259 | replay=False, |
|
260 | overwrite_if_exists=False, |
|
261 | skip_if_file_exists=False, |
|
262 | output_dir=output_dir, |
|
263 | config_file=None, |
|
264 | default_config=False, |
|
265 | extra_context=None, |
|
266 | password=None, |
|
267 | directory=None, |
|
268 | accept_hooks=True, |
|
269 | ) |
|
270 | ||
271 |