Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: tests/test_page_outputs.py

Issue 29933596: Issue 5333 - Allow cms to generate relative pages (Closed) Base URL: https://hg.adblockplus.org/cms/
Patch Set: Allow cms to generate relative pages Created Nov. 2, 2018, 2:59 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tests/rel_path.html ('K') | « tests/rel_path.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_page_outputs.py
===================================================================
--- a/tests/test_page_outputs.py
+++ b/tests/test_page_outputs.py
@@ -29,6 +29,7 @@
static_expected_outputs = get_expected_outputs('static')
dynamic_expected_outputs = get_expected_outputs('dynamic')
+relative_expected_outputs = get_expected_outputs('relative')
@pytest.fixture(scope='session')
@@ -41,10 +42,24 @@
@pytest.fixture(scope='session')
+def static_output_relative(request, temp_site):
Vasily Kuznetsov 2018/11/02 10:45:35 This code repetition is not that great. The differ
rhowell 2018/11/06 03:34:41 Yeah, good idea. This seems much cleaner (and more
+ static_out_path = os.path.join(temp_site, 'static_out_relative')
+ sys.argv = ['filler', temp_site, static_out_path, '--relative']
+ with mock.patch('cms.sources.FileSource.version', 1):
+ runpy.run_module('cms.bin.generate_static_pages', run_name='__main__')
+ return static_out_path
+
+
+@pytest.fixture(scope='session')
def output_pages(static_output):
return get_dir_contents(static_output)
+@pytest.fixture(scope='session')
+def output_pages_relative(static_output_relative):
+ return get_dir_contents(static_output_relative)
+
+
@pytest.mark.parametrize('filename,expected_output', static_expected_outputs)
def test_static(output_pages, filename, expected_output):
if expected_output.startswith('## MISSING'):
@@ -53,6 +68,14 @@
assert expected_output == output_pages[filename]
+@pytest.mark.parametrize('filename,expected_output', relative_expected_outputs)
Vasily Kuznetsov 2018/11/02 10:45:35 This function is also basically a clone of `test_s
rhowell 2018/11/06 03:34:42 Acknowledged.
+def test_static_relative(output_pages_relative, filename, expected_output):
+ if expected_output.startswith('## MISSING'):
+ assert filename not in output_pages_relative
+ else:
+ assert expected_output == output_pages_relative[filename]
+
+
def test_cache(output_pages):
source = FileSource(os.path.join('test_site'))
assert source.get_cache_dir() == os.path.join('test_site', 'cache')
« tests/rel_path.html ('K') | « tests/rel_path.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld