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

Delta Between Two Patch Sets: sitescripts/extensions/test/test_updateManifests.py

Issue 29358368: Issue 4540 - Add Platform Specific Branch Support to createNightlies.py (Closed)
Left Patch Set: adds fixture to generate place holder nightlies file, removes nightlies file from repo Created Oct. 25, 2016, 10:29 a.m.
Right Patch Set: Created Oct. 26, 2016, 5:53 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 | « sitescripts/extensions/test/test_createNightlies.py ('k') | sitescripts/extensions/utils.py » ('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 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 Eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 """Tests for update manifest generation script.""" 16 """Tests for update manifest generation script."""
17 17
18 import os
18 import json 19 import json
19 import os 20 import pytest
20 import subprocess 21 import subprocess
21 import xml.etree.ElementTree as ET 22 import xml.etree.ElementTree as ET
22 23
23 24
24 def rdf2data(rdf): 25 def rdf2data(rdf):
25 """Convert RDF to a more comparable data strcuture.""" 26 """Convert RDF to a more comparable data strcuture."""
26 # We need this to address the RDF item ordering discrepancies. 27 # We need this to address the RDF item ordering discrepancies.
27 def et2data(node): 28 def et2data(node):
28 return { 29 return {
29 'tag': node.tag, 30 'tag': node.tag,
30 'text': node.text, 31 'text': node.text,
31 'attrib': node.attrib, 32 'attrib': node.attrib,
32 'subs': sorted(et2data(sub) for sub in node) 33 'subs': sorted(et2data(sub) for sub in node)
33 } 34 }
34 return et2data(ET.fromstring(rdf)) 35 return et2data(ET.fromstring(rdf))
36
37
38 @pytest.fixture(scope='session')
39 def oracle(tests_dir):
40 """Function that returns expected content of generated files."""
41 def expected_value_of(what):
42 return tests_dir.join('oracle').join(what).read().strip()
43 return expected_value_of
35 44
36 45
37 def test_update_manifests(config_ini, hg_dir, tmpdir, oracle): 46 def test_update_manifests(config_ini, hg_dir, tmpdir, oracle):
38 env = dict(os.environ) 47 env = dict(os.environ)
39 env['SITESCRIPTS_CONFIG'] = str(config_ini) 48 env['SITESCRIPTS_CONFIG'] = str(config_ini)
40 cmd = ['python', '-m', 'sitescripts.extensions.bin.updateUpdateManifests'] 49 cmd = ['python', '-m', 'sitescripts.extensions.bin.updateUpdateManifests']
41 subprocess.check_call(cmd, env=env) 50 subprocess.check_call(cmd, env=env)
42 for filename in ['androidupdates.json', 'androidupdates.xml', 51 for filename in ['androidupdates.json', 'androidupdates.xml',
43 'ieupdate.json', 'update.rdf', 'updates.plist']: 52 'ieupdate.json', 'update.rdf', 'updates.plist']:
44 got = tmpdir.join(filename).read().strip() 53 got = tmpdir.join(filename).read().strip()
45 expect = oracle(filename) 54 expect = oracle(filename)
46 if filename.endswith('.json'): 55 if filename.endswith('.json'):
47 got = json.loads(got) 56 got = json.loads(got)
48 expect = json.loads(expect) 57 expect = json.loads(expect)
49 elif filename.endswith('.rdf'): 58 elif filename.endswith('.rdf'):
50 got = rdf2data(got) 59 got = rdf2data(got)
51 expect = rdf2data(expect) 60 expect = rdf2data(expect)
52 assert got == expect 61 assert got == expect
LEFTRIGHT

Powered by Google App Engine
This is Rietveld