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: Adding pytest-cov, adhering to comments Created Aug. 14, 2017, 2:19 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 base_files(tmpdir, str500chars):
30 """Minimal Files() for testing all packagers."""
31 files = packager.Files(set(), 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 return files
39
40
41 @pytest.fixture
42 def srcdir(tmpdir):
43 """Source directory for building the package."""
44 for size in ['44', '50', '150']:
45 path = tmpdir.join('chrome', 'icons', 'abp-{}.png'.format(size))
46 path.write(size, ensure=True)
47
48 localedir = tmpdir.mkdir('_locales')
49 en_us_dir = localedir.mkdir('en_US')
50 trans_dir = localedir.mkdir('en-US')
51 en_us_dir.join('messages.json').write(MESSAGES_EN_US)
52
53 trans_dir.join('test.properties').write(''.join((
54 'name=Adblock Plus\n',
55 'name_devbuild=devbuild-marker\n',
56 )))
57 return tmpdir
OLDNEW

Powered by Google App Engine
This is Rietveld