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

Delta Between Two Patch Sets: tests/test_page_outputs.py

Issue 29400555: Issue 4992 - Adds optional revision arg to generate_static_pages (Closed) Base URL: https://hg.adblockplus.org/cms
Left Patch Set: removes duplication in fixtures and addresses arg message changes Created April 3, 2017, 2:40 p.m.
Right Patch Set: fixed redundant sys.argv definition Created April 4, 2017, 6:59 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « tests/conftest.py ('k') | tests/test_site/templates/default.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import os 1 import os
2 import sys 2 import sys
3 import time 3 import time
4 import runpy 4 import runpy
5 import signal 5 import signal
6 import pytest 6 import pytest
7 import urllib2 7 import urllib2
8 import subprocess 8 import subprocess
9 from conftest import ROOTPATH 9 from conftest import ROOTPATH
10 10
(...skipping 15 matching lines...) Expand all
26 26
27 27
28 @pytest.fixture(scope='session', params=['master', None]) 28 @pytest.fixture(scope='session', params=['master', None])
29 def revision(request): 29 def revision(request):
30 return request.param 30 return request.param
31 31
32 32
33 @pytest.fixture(scope='session') 33 @pytest.fixture(scope='session')
34 def static_output(revision, request, temp_site): 34 def static_output(revision, request, temp_site):
35 static_out_path = os.path.join(temp_site, 'static_out') 35 static_out_path = os.path.join(temp_site, 'static_out')
36 if revision is None: 36 sys.argv = ['filler', temp_site, static_out_path]
Vasily Kuznetsov 2017/04/03 15:15:52 We don't really need to repeat the standard args t
Jon Sonesen 2017/04/04 07:01:23 Done.
37 sys.argv = ['filler', temp_site, static_out_path] 37 if revision is not None:
38 else: 38 sys.argv += ['--rev', revision]
39 sys.argv = ['filler', temp_site, static_out_path, '--rev', 'master']
Vasily Kuznetsov 2017/04/03 15:15:52 The last item of the list should be `revision` but
Jon Sonesen 2017/04/04 07:01:23 Done.
40 39
41 runpy.run_module('cms.bin.generate_static_pages', run_name='__main__') 40 runpy.run_module('cms.bin.generate_static_pages', run_name='__main__')
42 return static_out_path 41 return static_out_path
43 42
44 43
45 @pytest.yield_fixture() 44 @pytest.yield_fixture()
46 def dynamic_server(temp_site): 45 def dynamic_server(temp_site):
47 args = ['python', 'runserver.py', temp_site] 46 args = ['python', 'runserver.py', temp_site]
48 # Werkzeug is a dependency of flask which we are using for the mock api 47 # Werkzeug is a dependency of flask which we are using for the mock api
49 # however there is an issue with Werkzeug that prevents it from properly 48 # however there is an issue with Werkzeug that prevents it from properly
(...skipping 19 matching lines...) Expand all
69 def test_dynamic(dynamic_server, filename, expected_output): 68 def test_dynamic(dynamic_server, filename, expected_output):
70 response = urllib2.urlopen(dynamic_server + filename) 69 response = urllib2.urlopen(dynamic_server + filename)
71 assert response.read() == expected_output 70 assert response.read() == expected_output
72 71
73 72
74 def test_revision_arg(revision, output_pages): 73 def test_revision_arg(revision, output_pages):
75 if revision is None: 74 if revision is None:
76 assert 'bar' in output_pages 75 assert 'bar' in output_pages
77 else: 76 else:
78 assert 'bar' not in output_pages 77 assert 'bar' not in output_pages
LEFTRIGHT

Powered by Google App Engine
This is Rietveld