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

Side by Side Diff: tests/test_dynamic_server.py

Issue 29933596: Issue 5333 - Allow cms to generate relative pages (Closed) Base URL: https://hg.adblockplus.org/cms/
Patch Set: Address comments on PS1, rearrange test files Created Nov. 6, 2018, 3:28 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 import pytest 1 import pytest
2 import urllib2 2 import urllib2
3 import os 3 import os
4 4
5 from tests.test_page_outputs import dynamic_expected_outputs 5 from tests.test_page_outputs import dynamic_expected_outputs
6 from tests.utils import run_test_server, exception_test 6 from tests.utils import run_test_server, exception_test
7 7
8 8
9 @pytest.fixture(scope='function') 9 @pytest.fixture(scope='function')
10 def dynamic_server_werkzeug(temp_site): 10 def dynamic_server_werkzeug(temp_site):
(...skipping 14 matching lines...) Expand all
25 new_env['PYTHONPATH'] = os.pathsep.join([str(tmpdir), 25 new_env['PYTHONPATH'] = os.pathsep.join([str(tmpdir),
26 os.getenv('PYTHONPATH', '')]) 26 os.getenv('PYTHONPATH', '')])
27 27
28 with run_test_server(str(temp_site), new_env) as ts: 28 with run_test_server(str(temp_site), new_env) as ts:
29 yield ts 29 yield ts
30 30
31 31
32 @pytest.mark.slowtest 32 @pytest.mark.slowtest
33 def test_dynamic_werkzeug_good_page(dynamic_server_werkzeug): 33 def test_dynamic_werkzeug_good_page(dynamic_server_werkzeug):
34 filename, expected_output = dynamic_expected_outputs[0] 34 filename, expected_output = dynamic_expected_outputs[0]
35 filename = os.path.join(os.path.split(os.path.split(filename)[0])[0],
36 os.path.split(filename)[1])
35 response = urllib2.urlopen(dynamic_server_werkzeug + filename) 37 response = urllib2.urlopen(dynamic_server_werkzeug + filename)
36 38
37 assert expected_output in response.read().strip() 39 assert expected_output in response.read().strip()
38 40
39 41
40 @pytest.mark.slowtest 42 @pytest.mark.slowtest
41 def test_dynamic_werkzeug_not_found(dynamic_server_werkzeug): 43 def test_dynamic_werkzeug_not_found(dynamic_server_werkzeug):
42 filename = 'en/no-page-here' 44 filename = 'en/no-page-here'
43 exp_msg = 'Not Found' 45 exp_msg = 'Not Found'
44 46
45 exception_test(urllib2.urlopen, urllib2.HTTPError, exp_msg, 47 exception_test(urllib2.urlopen, urllib2.HTTPError, exp_msg,
46 dynamic_server_werkzeug + filename) 48 dynamic_server_werkzeug + filename)
47 49
48 50
49 @pytest.mark.slowtest 51 @pytest.mark.slowtest
50 def test_dynamic_builtins_good_page(dynamic_server_builtins): 52 def test_dynamic_builtins_good_page(dynamic_server_builtins):
51 filename, expected_output = dynamic_expected_outputs[0] 53 filename, expected_output = dynamic_expected_outputs[0]
54 filename = os.path.join(os.path.split(os.path.split(filename)[0])[0],
55 os.path.split(filename)[1])
52 response = urllib2.urlopen(dynamic_server_builtins + filename) 56 response = urllib2.urlopen(dynamic_server_builtins + filename)
53 57
54 assert expected_output in response.read().strip() 58 assert expected_output in response.read().strip()
55 59
56 60
57 @pytest.mark.slowtest 61 @pytest.mark.slowtest
58 def test_dynamic_builtins_not_found(dynamic_server_builtins): 62 def test_dynamic_builtins_not_found(dynamic_server_builtins):
59 filename = 'en/no-page-here' 63 filename = 'en/no-page-here'
60 exp_msg = 'Not Found' 64 exp_msg = 'Not Found'
61 65
62 exception_test(urllib2.urlopen, urllib2.HTTPError, exp_msg, 66 exception_test(urllib2.urlopen, urllib2.HTTPError, exp_msg,
63 dynamic_server_builtins + filename) 67 dynamic_server_builtins + filename)
OLDNEW

Powered by Google App Engine
This is Rietveld