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

Unified Diff: sitescripts/extensions/test/conftest.py

Issue 29361729: Issue 4574 - Adds Tests to createNightlies platform specific revisions (Closed)
Patch Set: Created Nov. 4, 2016, 2:37 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sitescripts/extensions/test/conftest.py
===================================================================
--- a/sitescripts/extensions/test/conftest.py
+++ b/sitescripts/extensions/test/conftest.py
@@ -40,57 +40,67 @@
@pytest.fixture(scope='session')
def data_dir(tests_dir):
return tests_dir.join('data')
# Fixtures using the built in tmpdir fixture must be function scoped which
# causes about a 30% slow down. It would be faster to use tmpdir_factory
# which is session scoped but for no it is not important.
-@pytest.fixture()
-def keys_dir(tmpdir, tests_dir):
- keys_dir = tmpdir.mkdir('keys')
+@pytest.fixture(scope='session')
+def keys_dir(tmpdir_factory, tests_dir):
Jon Sonesen 2016/11/04 15:11:55 Went ahead and optimized this to be session scoped
Vasily Kuznetsov 2016/11/07 14:53:21 :thumbsup:
+ keys_dir = tmpdir_factory.mktemp('keys')
key_filename = 'adblockplussafari.pem'
tests_dir.join(key_filename).copy(keys_dir.join(key_filename))
return keys_dir
def call_hg(cwd, *params):
return subprocess.check_call(['hg'] + list(params), cwd=str(cwd))
-@pytest.fixture()
-def hg_dir(tmpdir, data_dir):
+@pytest.fixture(scope='session')
+def hg_dir(tmpdir_factory, data_dir):
"""Directory that contains the repository mocks."""
- hg_dir = tmpdir.mkdir('hg')
+ hg_dir = tmpdir_factory.mktemp('hg')
# Mock plugin repositories.
for repo, config in REPOS.items():
filename, tag = config
repo_dir = hg_dir.mkdir(repo)
call_hg(repo_dir, 'init')
data_dir.join(filename).copy(repo_dir.join(filename))
call_hg(repo_dir, 'add', filename)
call_hg(repo_dir, 'commit', '-m', '1')
call_hg(repo_dir, 'tag', tag)
+ call_hg(hg_dir.join('adblockplusnightly'), 'bookmark', 'master')
call_hg(hg_dir.join('adblockplusnightly'), 'bookmark', 'safari')
+ command = ['touch', str(hg_dir.join('adblockplusnightly', 'foo'))]
+ subprocess.check_output(command)
+ call_hg(hg_dir.join('adblockplusnightly'), 'add', 'foo')
+ call_hg(hg_dir.join('adblockplusnightly'), 'commit', '-m', 'foo')
Jon Sonesen 2016/11/04 15:11:55 This could all be moved into a separate fixture wh
Vasily Kuznetsov 2016/11/07 14:53:21 I'm thinking that it might actually be better to s
Jon Sonesen 2016/11/08 17:29:45 Great, I will do this.
# Mock the downloads repository.
downloads_list = data_dir.join('downloads.list').read().splitlines()
downloads_dir = hg_dir.mkdir('downloads')
call_hg(downloads_dir, 'init')
for item in downloads_list:
downloads_dir.join(item).write('')
call_hg(downloads_dir, 'add', *downloads_list)
call_hg(downloads_dir, 'commit', '-m', 'ok')
return hg_dir
+@pytest.fixture(scope='session')
+def nightly_dir(hg_dir):
+ return hg_dir.join('adblockplusnightly')
+
+
@pytest.fixture()
def config_ini(tests_dir, tmpdir, hg_dir, keys_dir):
"""Sitescripts configuration."""
template = tests_dir.join('sitescripts.ini.template').read()
conf = template.format(hg_dir=hg_dir, out_dir=tmpdir, keys_dir=keys_dir)
config_ini = tmpdir.join('sitescripts.ini')
config_ini.write(conf)
return config_ini

Powered by Google App Engine
This is Rietveld