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

Delta Between Two Patch Sets: tests/test_page_outputs.py

Issue 29753617: Issue 6545 - get_pages_metadata now returns all pages (Closed)
Left Patch Set: Address PS1 comments Created April 27, 2018, 8:44 p.m.
Right Patch Set: Rebase, changes comments to add citation to explain weird logic chain Created May 6, 2018, 10:59 p.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/expected_output/en/sitemap@static+master ('k') | no next file » | 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 runpy 3 import runpy
4 import pytest 4 import pytest
5 import urllib2 5 import urllib2
6 6
7 from .conftest import ROOTPATH 7 from .conftest import ROOTPATH
8 from .utils import get_dir_contents, run_test_server 8 from .utils import get_dir_contents, run_test_server
9 9
10 10
11 def get_expected_outputs(test_type): 11 def get_expected_outputs(test_type):
12 expected_out_path = os.path.join(ROOTPATH, 'tests', 'expected_output') 12 expected_out_path = os.path.join(ROOTPATH, 'tests', 'expected_output')
13 outputs = get_dir_contents(expected_out_path) 13 outputs = get_dir_contents(expected_out_path)
14 for filename in list(outputs): 14 for filename in list(outputs):
15 # Move test-type-specific expected outputs (e.g. "xyz@static" -> "xyz") 15 # Move test-type-specific expected outputs (e.g. "xyz@static" -> "xyz")
16 # and remove the expected outputs that don't apply for this test type. 16 # There are cases where we need to test outputs which differ depending
17 # on how they are generated; either statically or dynamically
17 if filename.endswith('@' + test_type): 18 if filename.endswith('@' + test_type):
18 realname = filename.split('@')[0] 19 realname = filename.split('@')[0]
19 outputs[realname] = outputs[filename] 20 outputs[realname] = outputs[filename]
21 # Move bookmark specific output (e.g. "xyx@static+master -> xyz+master)
22 # There are cases where we need to test outputs which differ depending
23 # on the bookmark which they are generated from:
24 # https://issues.adblockplus.org/ticket/6605
20 if '+' in filename: 25 if '+' in filename:
21 realname = ''.join(filename.split('@' + test_type)) 26 realname = ''.join(filename.split('@' + test_type))
22 outputs[realname] = outputs[filename] 27 outputs[realname] = outputs[filename]
28 # Remove the expected outputs that don't apply for this test type.
23 if '@' in filename: 29 if '@' in filename:
24 del outputs[filename] 30 del outputs[filename]
25 return outputs.items() 31 return outputs.items()
26 32
27 33
28 static_expected_outputs = get_expected_outputs('static') 34 static_expected_outputs = get_expected_outputs('static')
29 dynamic_expected_outputs = get_expected_outputs('dynamic') 35 dynamic_expected_outputs = get_expected_outputs('dynamic')
30 36
31 37
32 @pytest.fixture(scope='session', params=['master', None]) 38 @pytest.fixture(scope='session', params=['master', None])
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 def test_dynamic(dynamic_server, filename, expected_output): 77 def test_dynamic(dynamic_server, filename, expected_output):
72 response = urllib2.urlopen(dynamic_server + filename) 78 response = urllib2.urlopen(dynamic_server + filename)
73 assert expected_output == response.read().strip() 79 assert expected_output == response.read().strip()
74 80
75 81
76 def test_revision_arg(revision, output_pages): 82 def test_revision_arg(revision, output_pages):
77 if revision is None: 83 if revision is None:
78 assert 'en/bar' in output_pages 84 assert 'en/bar' in output_pages
79 else: 85 else:
80 assert 'en/bar' not in output_pages 86 assert 'en/bar' not in output_pages
LEFTRIGHT

Powered by Google App Engine
This is Rietveld