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

Side by Side Diff: tests/conftest.py

Issue 29501558: Issue 5383 - Add tests for the Chrome and Firefox packagers (Closed)
Patch Set: Created Aug. 4, 2017, 3:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 import json
6
7 import pytest
8
9 from buildtools import packager
10
11 MESSAGES_EN_US = json.dumps({
12 'name': {'message': 'Adblock Plus'},
13 'name_devbuild': {'message': 'devbuild-marker'},
14 'description': {
15 'message': 'Adblock Plus is the most popular ad blocker ever, '
16 'and also supports websites by not blocking '
17 'unobstrusive ads by default (configurable).'
18 },
19 })
20
21
22 @pytest.fixture(scope='module')
23 def str500chars():
24 """Generates a String of 500 chars to simulate data"""
25 return b''.join(chr(i % 200 + 30) for i in range(500))
26
27
28 @pytest.fixture
29 def files(tmpdir, str500chars):
Vasily Kuznetsov 2017/08/10 19:48:27 This name doesn't really tell me much. The docstri
tlucas 2017/08/11 12:17:08 Done.
30 """Minimal Files() for testing all packagers."""
31 files = packager.Files(['lib'], set())
32 for size in ['44', '50', '150']:
33 files['Assets/logo_{}.png'.format(size)] = str500chars
34 files['Extension/_locales/en_US/messages.json'] = MESSAGES_EN_US
35 files['_locales/en_US/messages.json'] = MESSAGES_EN_US
36 files['Extension/foo.xml'] = str500chars
37 files['Extension/bar.png'] = str500chars * 200
38 files['lib/a.js'] = 'var bar;'
39 files['lib/b.js'] = 'var foo;'
40
41 lib_dir = tmpdir.mkdir('lib')
42
43 lib_dir.join('a.js').write(files['lib/a.js'])
44 lib_dir.join('b.js').write(files['lib/b.js'])
45 return files
46
47
48 @pytest.fixture
49 def srcdir(tmpdir):
50 """Source directory for building the package."""
51 for size in ['44', '50', '150']:
52 path = tmpdir.join('chrome', 'icons', 'abp-{}.png'.format(size))
53 path.write(size, ensure=True)
54
55 localedir = tmpdir.mkdir('_locales')
56 en_us_dir = localedir.mkdir('en_US')
57 trans_dir = localedir.mkdir('en-US')
58 en_us_dir.join('messages.json').write(MESSAGES_EN_US)
59
60 trans_dir.join('test.properties').write(''.join((
61 'name=Adblock Plus\n',
62 'name_devbuild=devbuild-marker\n',
63 )))
64 return tmpdir
OLDNEW

Powered by Google App Engine
This is Rietveld