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

Delta Between Two Patch Sets: tests/test_packagerEdge.py

Issue 29501558: Issue 5383 - Add tests for the Chrome and Firefox packagers (Closed)
Left Patch Set: Simplifying parameters Created Sept. 21, 2017, 11:27 a.m.
Right Patch Set: Addressing Vasily's comments Created Oct. 22, 2017, 11:11 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/metadata.gecko ('k') | tests/test_packagerWebExt.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 Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import os 5 import xml.etree.ElementTree as ET
6
6 import pytest 7 import pytest
7 8
8 import xml.etree.ElementTree as ET
9
10 from buildtools.tests.tools import (ZipContent, run_webext_build, locale_files,
11 copy_metadata, assert_manifest_content,
12 assert_all_locales_present)
13 from buildtools.tests.conftest import ALL_LANGUAGES
14 from buildtools import packager, packagerEdge 9 from buildtools import packager, packagerEdge
15
16
17 @pytest.fixture
18 def locale_files_edge(tmpdir):
19 return locale_files(ALL_LANGUAGES, '_locales', tmpdir)
20
21
22 @pytest.fixture
23 def edge_metadata(tmpdir):
24 filename = 'metadata.edge'
25 copy_metadata(filename, tmpdir)
26
27 return packager.readMetadata(str(tmpdir), 'edge')
28 10
29 11
30 @pytest.fixture 12 @pytest.fixture
31 def files(): 13 def files():
32 """Minimal Files() for testing blockmap.""" 14 """Minimal Files() for testing blockmap."""
33 str500 = b''.join(chr(i % 200 + 30) for i in range(500)) 15 str500 = b''.join(chr(i % 200 + 30) for i in range(500))
34 files = packager.Files(set(), set()) 16 files = packager.Files(set(), set())
35 files['Extension/foo.xml'] = str500 17 files['Extension/foo.xml'] = str500
36 files['Extension/bar.png'] = str500 * 200 18 files['Extension/bar.png'] = str500 * 200
37 return files 19 return files
38
39
40 @pytest.fixture
41 def js_extensions(srcdir):
42 srcdir.mkdir('ext').join('foo.js').write('var foo;')
43 srcdir.join('bar.js').write('var bar;')
44 20
45 21
46 def blockmap2dict(xml_data): 22 def blockmap2dict(xml_data):
47 """Convert AppxBlockMap.xml to a dict of dicts easier to inspect.""" 23 """Convert AppxBlockMap.xml to a dict of dicts easier to inspect."""
48 return { 24 return {
49 file.get('Name'): { 25 file.get('Name'): {
50 'size': file.get('Size'), 26 'size': file.get('Size'),
51 'lfhsize': file.get('LfhSize'), 27 'lfhsize': file.get('LfhSize'),
52 'blocks': [b.get('Hash') for b in file] 28 'blocks': [b.get('Hash') for b in file]
53 } 29 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 'js': 'application/javascript', 78 'js': 'application/javascript',
103 'json': 'application/json', 79 'json': 'application/json',
104 'otf': 'application/octet-stream', 80 'otf': 'application/octet-stream',
105 'png': 'image/png', 81 'png': 'image/png',
106 'xml': 'application/xml' 82 'xml': 'application/xml'
107 } 83 }
108 assert ctm_dict['overrides'] == { 84 assert ctm_dict['overrides'] == {
109 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml', 85 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml',
110 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml' 86 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml'
111 } 87 }
112
113
114 @pytest.mark.usefixtures('locale_files_edge', 'js_extensions')
115 @pytest.mark.parametrize('dev_build_release,buildnum', [
116 pytest.param('devenv', None, marks=pytest.mark.xfail),
117 ('release', None),
118 ('build', '1337'),
119 ])
120 def test_build_edge(dev_build_release, tmpdir, srcdir, edge_metadata,
121 buildnum):
122 release = dev_build_release == 'release'
123
124 run_webext_build('edge', dev_build_release, srcdir, buildnum=buildnum)
125
126 if release:
127 out_file = 'adblockplusedge-1.2.3.appx'
128 else:
129 out_file = 'adblockplusedge-1.2.3.{}.appx'.format(buildnum)
130
131 with ZipContent(out_file) as package:
132 filenames = set(package.namelist())
133
134 assert_all_locales_present(package, 'Extension/_locales')
135
136 assert 'AppxManifest.xml' in filenames
137 assert 'AppxBlockMap.xml' in filenames
138 assert '[Content_Types].xml' in filenames
139
140 assert 'Extension/ext/foo.js' in filenames
141 assert 'Extension/bar.js' in filenames
142
143 assert package.read('Assets/logo_44.png') == '44'
144 assert package.read('Extension/icons/abp-44.png') == '44'
145
146 filename = '{{}}_edge_{}_{}.{{}}'.format(release, buildnum)
Sebastian Noack 2017/09/21 19:09:04 The buildnum is redundant here. The filenames are
Sebastian Noack 2017/09/22 01:56:05 Also it is inconsistent with "edge" and "gecko-web
tlucas 2017/09/22 09:02:18 Done.
147
148 for folder, name, ext in [('', 'AppxManifest', 'xml'),
149 ('Extension', 'manifest', 'json')]:
150 expected = os.path.join(
151 os.path.dirname(__file__),
152 'expecteddata',
153 filename.format(name, ext),
154 )
155
156 assert_manifest_content(
157 package.read(os.path.join(folder, '{}.{}'.format(name, ext))),
158 expected,
159 )
LEFTRIGHT

Powered by Google App Engine
This is Rietveld