Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # This file is part of the Adblock Plus web scripts, | |
Vasily Kuznetsov
2018/09/24 11:58:47
This file contains the tests specifically for this
Tudor Avram
2018/09/24 16:10:00
Done.
| |
2 # Copyright (C) 2006-present eyeo GmbH | |
3 # | |
4 # Adblock Plus is free software: you can redistribute it and/or modify | |
5 # it under the terms of the GNU General Public License version 3 as | |
6 # published by the Free Software Foundation. | |
7 # | |
8 # Adblock Plus is distributed in the hope that it will be useful, | |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 # GNU General Public License for more details. | |
12 # | |
13 # You should have received a copy of the GNU General Public License | |
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
15 import pytest | |
Vasily Kuznetsov
2018/09/24 11:58:47
The import order should be stdlib, 3-rd party libs
Tudor Avram
2018/09/24 14:04:51
Done.
| |
16 | |
17 import os | |
18 | |
19 | |
20 @pytest.fixture(scope='session') | |
21 def target_dir_with_file(temp_site): | |
Vasily Kuznetsov
2018/09/24 11:58:47
Here and in the following fixture, it seems like y
Tudor Avram
2018/09/24 14:04:51
Done.
| |
22 target_dir = os.path.join(os.path.dirname(temp_site), 'out_file') | |
23 os.makedirs(os.path.join(target_dir, 'en')) | |
24 | |
25 with open(os.path.join(target_dir, 'en', 'foo'), 'w') as f: | |
26 f.write('test\n') | |
27 | |
28 yield target_dir | |
29 | |
30 | |
31 @pytest.fixture(scope='session') | |
32 def target_dir_with_dir(temp_site): | |
33 target_dir = os.path.join(os.path.dirname(temp_site), 'out_dir') | |
34 os.makedirs(os.path.join(target_dir, 'en', 'translate')) | |
35 | |
36 yield target_dir | |
37 | |
38 | |
39 @pytest.mark.script_launch_mode('subprocess') | |
40 def test_generate_dir_instead_of_file(temp_site, target_dir_with_file, | |
41 script_runner): | |
42 cmd = ['python', '-m', 'cms.bin.generate_static_pages', str(temp_site), | |
43 str(target_dir_with_file)] | |
44 | |
45 script_runner.run(*cmd) | |
46 | |
47 print(os.listdir(os.path.join(target_dir_with_file, 'en', 'foo'))) | |
Vasily Kuznetsov
2018/09/24 11:58:47
Do we need this print once the test is passing?
Tudor Avram
2018/09/24 14:04:51
oops, no. Forgot to remove it.
Done.
| |
48 | |
49 assert os.path.isdir(os.path.join(target_dir_with_file, 'en', 'foo')) | |
50 | |
51 | |
52 @pytest.mark.script_launch_mode('subprocess') | |
53 def test_generate_file_instead_of_dir(temp_site, target_dir_with_dir, | |
54 script_runner): | |
55 cmd = ['python', '-m', 'cms.bin.generate_static_pages', str(temp_site), | |
56 str(target_dir_with_dir)] | |
57 | |
58 script_runner.run(*cmd) | |
59 | |
60 assert os.path.isfile(os.path.join(target_dir_with_dir, 'en', 'translate')) | |
OLD | NEW |