| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 os |
| 6 import pytest | 6 import pytest |
| 7 | 7 |
| 8 import xml.etree.ElementTree as ET | 8 import xml.etree.ElementTree as ET |
| 9 | 9 |
| 10 from buildtools.tests.tools import run_webext_build | 10 from buildtools.tests.tools import (ZipContent, run_webext_build, locale_files, |
|
Vasily Kuznetsov
2017/09/11 12:50:06
You can combine all the imports from `buildtools.t
tlucas
2017/09/12 11:32:10
Acknowledged.
tlucas
2017/09/13 13:43:24
Done.
| |
| 11 from buildtools.tests.tools import locale_files | 11 copy_metadata, assert_manifest_content, |
| 12 from buildtools.tests.tools import copy_metadata | 12 assert_all_locales_present) |
| 13 from buildtools.tests.tools import ZipContent | |
| 14 from buildtools.tests.tools import assert_manifest_content | |
| 15 from buildtools.tests.tools import assert_all_locales_present | |
| 16 from buildtools.tests.conftest import ALL_LANGUAGES | 13 from buildtools.tests.conftest import ALL_LANGUAGES |
| 17 from buildtools import packager | 14 from buildtools import packager, packagerEdge |
| 18 from buildtools import packagerEdge | |
| 19 | 15 |
| 20 | 16 |
| 21 @pytest.fixture | 17 @pytest.fixture |
| 22 def locale_files_edge(tmpdir): | 18 def locale_files_edge(tmpdir): |
| 23 return locale_files(ALL_LANGUAGES, '_locales', tmpdir) | 19 return locale_files(ALL_LANGUAGES, '_locales', tmpdir) |
| 24 | 20 |
| 25 | 21 |
| 26 @pytest.fixture | 22 @pytest.fixture |
| 27 def edge_metadata(tmpdir): | 23 def edge_metadata(tmpdir): |
| 28 filename = 'metadata.edge' | 24 filename = 'metadata.edge' |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 'xml': 'application/xml' | 106 'xml': 'application/xml' |
| 111 } | 107 } |
| 112 assert ctm_dict['overrides'] == { | 108 assert ctm_dict['overrides'] == { |
| 113 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml', | 109 '/AppxBlockMap.xml': 'application/vnd.ms-appx.blockmap+xml', |
| 114 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml' | 110 '/AppxManifest.xml': 'application/vnd.ms-appx.manifest+xml' |
| 115 } | 111 } |
| 116 | 112 |
| 117 | 113 |
| 118 @pytest.mark.usefixtures('locale_files_edge', 'js_extensions') | 114 @pytest.mark.usefixtures('locale_files_edge', 'js_extensions') |
| 119 @pytest.mark.parametrize('build_release', ['release', 'build']) | 115 @pytest.mark.parametrize('build_release', ['release', 'build']) |
| 120 def test_build_edge(build_release, tmpdir, srcdir, edge_metadata): | 116 @pytest.mark.parametrize('buildnum', [None, '1337']) |
| 121 from buildtools import packagerEdge | 117 def test_build_edge(build_release, tmpdir, srcdir, edge_metadata, buildnum): |
| 122 release = build_release == 'release' | 118 release = build_release == 'release' |
| 123 | 119 |
| 124 run_webext_build('edge', build_release, srcdir, packagerEdge) | 120 run_webext_build('edge', build_release, srcdir, packagerEdge, |
| 121 buildnum=buildnum) | |
| 125 | 122 |
| 126 if release: | 123 if release: |
| 127 out_file = 'adblockplusedge-1.2.3.appx' | 124 out_file = 'adblockplusedge-1.2.3.appx' |
| 128 else: | 125 else: |
| 129 out_file = 'adblockplusedge-1.2.3.0.appx' | 126 out_file = 'adblockplusedge-1.2.3.{}.appx'.format( |
| 127 buildnum or '0' | |
| 128 ) | |
| 130 | 129 |
| 131 with ZipContent(out_file) as package: | 130 with ZipContent(out_file) as package: |
| 132 filenames = set(package.namelist()) | 131 filenames = set(package.namelist()) |
| 133 | 132 |
| 134 assert_all_locales_present(package, 'Extension/_locales') | 133 assert_all_locales_present(package, 'Extension/_locales') |
| 135 | 134 |
| 136 assert 'AppxManifest.xml' in filenames | 135 assert 'AppxManifest.xml' in filenames |
| 137 assert 'AppxBlockMap.xml' in filenames | 136 assert 'AppxBlockMap.xml' in filenames |
| 138 assert '[Content_Types].xml' in filenames | 137 assert '[Content_Types].xml' in filenames |
| 139 | 138 |
| 140 assert 'Extension/ext/foo.js' in filenames | 139 assert 'Extension/ext/foo.js' in filenames |
| 141 assert 'Extension/bar.js' in filenames | 140 assert 'Extension/bar.js' in filenames |
| 142 | 141 |
| 143 assert package.read('Assets/logo_44.png') == '44' | 142 assert package.read('Assets/logo_44.png') == '44' |
| 144 assert package.read('Extension/icons/abp-44.png') == '44' | 143 assert package.read('Extension/icons/abp-44.png') == '44' |
| 145 | 144 |
| 146 if release: | 145 filename = 'manifest_edge_{}_{}.xml'.format(release, buildnum) |
| 147 filename = 'manifest_edge_True.xml' | |
| 148 else: | |
| 149 filename = 'manifest_edge_False.xml' | |
| 150 | 146 |
| 151 expected = os.path.join( | 147 expected = os.path.join( |
| 152 os.path.dirname(__file__), | 148 os.path.dirname(__file__), |
| 153 'expecteddata', | 149 'expecteddata', |
| 154 filename, | 150 filename, |
| 155 ) | 151 ) |
| 156 assert_manifest_content(package.read('AppxManifest.xml'), expected) | 152 assert_manifest_content(package.read('AppxManifest.xml'), expected) |
| LEFT | RIGHT |