OLD | NEW |
1 import os | 1 import os |
2 import sys | 2 import sys |
3 import runpy | 3 import runpy |
4 | 4 |
5 import mock | 5 import mock |
6 import pytest | 6 import pytest |
7 import urllib2 | 7 import urllib2 |
8 | 8 |
9 from .conftest import ROOTPATH | 9 from .conftest import ROOTPATH |
10 from .utils import get_dir_contents, run_test_server | 10 from .utils import get_dir_contents, run_test_server |
(...skipping 13 matching lines...) Expand all Loading... |
24 # Remove the expected outputs that don't apply for this test type. | 24 # Remove the expected outputs that don't apply for this test type. |
25 if '@' in filename: | 25 if '@' in filename: |
26 del outputs[filename] | 26 del outputs[filename] |
27 return outputs.items() | 27 return outputs.items() |
28 | 28 |
29 | 29 |
30 static_expected_outputs = get_expected_outputs('static') | 30 static_expected_outputs = get_expected_outputs('static') |
31 dynamic_expected_outputs = get_expected_outputs('dynamic') | 31 dynamic_expected_outputs = get_expected_outputs('dynamic') |
32 | 32 |
33 | 33 |
34 @mock.patch('cms.sources.FileSource.version', 1) | |
35 @pytest.fixture(scope='session') | 34 @pytest.fixture(scope='session') |
36 def static_output(request, temp_site): | 35 def static_output(request, temp_site): |
37 static_out_path = os.path.join(temp_site, 'static_out') | 36 static_out_path = os.path.join(temp_site, 'static_out') |
38 sys.argv = ['filler', temp_site, static_out_path] | 37 sys.argv = ['filler', temp_site, static_out_path] |
39 | 38 with mock.patch('cms.sources.FileSource.version', 1): |
40 runpy.run_module('cms.bin.generate_static_pages', run_name='__main__') | 39 runpy.run_module('cms.bin.generate_static_pages', run_name='__main__') |
41 return static_out_path | 40 return static_out_path |
42 | 41 |
43 | 42 |
44 @pytest.fixture(scope='module') | 43 @pytest.fixture(scope='module') |
45 def dynamic_server(temp_site): | 44 def dynamic_server(temp_site): |
46 with run_test_server(temp_site) as ts: | 45 with run_test_server(temp_site) as ts: |
47 yield ts | 46 yield ts |
48 | 47 |
49 | 48 |
50 @pytest.fixture(scope='session') | 49 @pytest.fixture(scope='session') |
(...skipping 11 matching lines...) Expand all Loading... |
62 | 61 |
63 @pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs) | 62 @pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs) |
64 def test_dynamic(dynamic_server, filename, expected_output): | 63 def test_dynamic(dynamic_server, filename, expected_output): |
65 response = urllib2.urlopen(dynamic_server + filename) | 64 response = urllib2.urlopen(dynamic_server + filename) |
66 assert expected_output == response.read().strip() | 65 assert expected_output == response.read().strip() |
67 | 66 |
68 | 67 |
69 def test_cache(output_pages): | 68 def test_cache(output_pages): |
70 source = FileSource(os.path.join('test_site')) | 69 source = FileSource(os.path.join('test_site')) |
71 assert source.get_cache_dir() == os.path.join('test_site', 'cache') | 70 assert source.get_cache_dir() == os.path.join('test_site', 'cache') |
OLD | NEW |