Index: tests/conftest.py |
diff --git a/tests/conftest.py b/tests/conftest.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..09b369c4b0e28694b26694e010712eb48f8182ed |
--- /dev/null |
+++ b/tests/conftest.py |
@@ -0,0 +1,64 @@ |
+# This Source Code Form is subject to the terms of the Mozilla Public |
+# License, v. 2.0. If a copy of the MPL was not distributed with this |
+# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
+ |
+import json |
+ |
+import pytest |
+ |
+from buildtools import packager |
+ |
+MESSAGES_EN_US = json.dumps({ |
+ 'name': {'message': 'Adblock Plus'}, |
+ 'name_devbuild': {'message': 'devbuild-marker'}, |
+ 'description': { |
+ 'message': 'Adblock Plus is the most popular ad blocker ever, ' |
+ 'and also supports websites by not blocking ' |
+ 'unobstrusive ads by default (configurable).' |
+ }, |
+}) |
+ |
+ |
+@pytest.fixture(scope='module') |
+def str500chars(): |
+ """Generates a String of 500 chars to simulate data""" |
+ return b''.join(chr(i % 200 + 30) for i in range(500)) |
+ |
+ |
+@pytest.fixture |
+def base_files(tmpdir, str500chars): |
+ """Minimal Files() for testing all packagers.""" |
+ files = packager.Files(['lib'], set()) |
+ for size in ['44', '50', '150']: |
+ files['Assets/logo_{}.png'.format(size)] = str500chars |
+ files['Extension/_locales/en_US/messages.json'] = MESSAGES_EN_US |
+ files['_locales/en_US/messages.json'] = MESSAGES_EN_US |
+ files['Extension/foo.xml'] = str500chars |
+ files['Extension/bar.png'] = str500chars * 200 |
+ files['lib/a.js'] = 'var bar;' |
+ files['lib/b.js'] = 'var foo;' |
+ |
+ lib_dir = tmpdir.mkdir('lib') |
Vasily Kuznetsov
2017/08/11 16:46:00
It would be cleaner to make lib_dir a separate fix
tlucas
2017/08/14 14:23:16
Done.
|
+ |
+ lib_dir.join('a.js').write(files['lib/a.js']) |
+ lib_dir.join('b.js').write(files['lib/b.js']) |
+ return files |
+ |
+ |
+@pytest.fixture |
+def srcdir(tmpdir): |
+ """Source directory for building the package.""" |
+ for size in ['44', '50', '150']: |
+ path = tmpdir.join('chrome', 'icons', 'abp-{}.png'.format(size)) |
+ path.write(size, ensure=True) |
+ |
+ localedir = tmpdir.mkdir('_locales') |
+ en_us_dir = localedir.mkdir('en_US') |
+ trans_dir = localedir.mkdir('en-US') |
+ en_us_dir.join('messages.json').write(MESSAGES_EN_US) |
+ |
+ trans_dir.join('test.properties').write(''.join(( |
+ 'name=Adblock Plus\n', |
+ 'name_devbuild=devbuild-marker\n', |
+ ))) |
+ return tmpdir |