You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/20 20:22:04 UTC
git commit: [#6256] use TMPDIR instead of /tmp everywhere
Updated Branches:
refs/heads/db/6256 [created] 3c3ddcb1d
[#6256] use TMPDIR instead of /tmp everywhere
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3c3ddcb1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3c3ddcb1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3c3ddcb1
Branch: refs/heads/db/6256
Commit: 3c3ddcb1d5ae1ab5f1d15ec51e26e0f3a74394a9
Parents: 0d1c69e
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon May 20 14:21:58 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon May 20 14:21:58 2013 -0400
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 3 +
ForgeGit/forgegit/tests/model/test_repository.py | 66 ++++++++-------
ForgeSVN/forgesvn/model/svn.py | 2 +-
ForgeSVN/forgesvn/tests/model/test_repository.py | 33 ++++----
.../forgesvn/tests/model/test_svnimplementation.py | 9 +-
ForgeSVN/forgesvn/tests/test_tasks.py | 6 +-
ForgeWiki/forgewiki/tests/test_wiki2markdown.py | 25 +++---
7 files changed, 78 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index b030d6f..43493ae 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -27,6 +27,7 @@ import json
import datetime
from urllib import urlencode
from subprocess import Popen, PIPE
+import os
import activitystream
import pkg_resources
@@ -209,6 +210,8 @@ class Globals(object):
statslisteners.append(ep())
self.statsUpdater = PostEvent(statslisteners)
+ self.tmpdir = os.getenv('TMPDIR', '/tmp')
+
@LazyProperty
def spam_checker(self):
"""Return a SpamFilter implementation.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 795e4e3..1e472b3 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -137,7 +137,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
def test_init(self):
repo = GM.Repository(
name='testgit.git',
- fs_path='/tmp/',
+ fs_path=g.tmpdir+'/',
url_path = '/test/',
tool = 'git',
status = 'creating')
@@ -150,7 +150,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
def test_fork(self):
repo = GM.Repository(
name='testgit.git',
- fs_path='/tmp/',
+ fs_path=g.tmpdir + '/',
url_path = '/test/',
tool = 'git',
status = 'creating')
@@ -161,16 +161,16 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
shutil.rmtree(dirname)
repo.init()
repo._impl.clone_from(repo_path)
- assert not os.path.exists('/tmp/testgit.git/hooks/update')
- assert not os.path.exists('/tmp/testgit.git/hooks/post-receive-user')
- assert os.path.exists('/tmp/testgit.git/hooks/post-receive')
- assert os.stat('/tmp/testgit.git/hooks/post-receive')[0] & stat.S_IXUSR
+ assert not os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/update'))
+ assert not os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive-user'))
+ assert os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))
+ assert os.stat(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))[0] & stat.S_IXUSR
@mock.patch('forgegit.model.git_repo.g.post_event')
def test_clone(self, post_event):
repo = GM.Repository(
name='testgit.git',
- fs_path='/tmp/',
+ fs_path=g.tmpdir + '/',
url_path = '/test/',
tool = 'git',
status = 'creating')
@@ -182,11 +182,11 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
repo.init()
repo._impl.clone_from(repo_path)
assert len(repo.log())
- assert not os.path.exists('/tmp/testgit.git/hooks/update')
- assert not os.path.exists('/tmp/testgit.git/hooks/post-receive-user')
- assert os.path.exists('/tmp/testgit.git/hooks/post-receive')
- assert os.stat('/tmp/testgit.git/hooks/post-receive')[0] & stat.S_IXUSR
- with open('/tmp/testgit.git/hooks/post-receive') as f: c = f.read()
+ assert not os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/update'))
+ assert not os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive-user'))
+ assert os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))
+ assert os.stat(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))[0] & stat.S_IXUSR
+ with open(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive')) as f: c = f.read()
self.assertIn('curl -s http://localhost//auth/refresh_repo/p/test/src-git/\n', c)
self.assertIn('exec $DIR/post-receive-user\n', c)
shutil.rmtree(dirname)
@@ -197,7 +197,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
with h.push_config(tg.config, **{'scm.git.hotcopy': 'True'}):
repo = GM.Repository(
name='testgit.git',
- fs_path='/tmp/',
+ fs_path=g.tmpdir+'/',
url_path = '/test/',
tool = 'git',
status = 'creating')
@@ -211,11 +211,11 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
repo._impl.clone_from(repo_path)
assert not clone_from.called
assert len(repo.log())
- assert os.path.exists('/tmp/testgit.git/hooks/update')
- assert os.path.exists('/tmp/testgit.git/hooks/post-receive-user')
- assert os.path.exists('/tmp/testgit.git/hooks/post-receive')
- assert os.stat('/tmp/testgit.git/hooks/post-receive')[0] & stat.S_IXUSR
- with open('/tmp/testgit.git/hooks/post-receive') as f: c = f.read()
+ assert os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/update'))
+ assert os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive-user'))
+ assert os.path.exists(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))
+ assert os.stat(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))[0] & stat.S_IXUSR
+ with open(os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive')) as f: c = f.read()
self.assertIn('curl -s http://localhost//auth/refresh_repo/p/test/src-git/\n', c)
self.assertIn('exec $DIR/post-receive-user\n', c)
shutil.rmtree(dirname)
@@ -259,12 +259,13 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
self.assertEqual(new_tree.other_ids, orig_tree.other_ids)
def test_tarball(self):
- if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip"):
- os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip")
- assert_equal(self.repo.tarball_path, '/tmp/tarball/git/t/te/test/testgit.git')
+ tmpdir = tg.config['scm.repos.tarball.root']
+ if os.path.isfile(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.zip")):
+ os.remove(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.zip"))
+ assert_equal(self.repo.tarball_path, os.path.join(tmpdir, 'git/t/te/test/testgit.git'))
assert_equal(self.repo.tarball_url('HEAD'), 'file:///git/t/te/test/testgit.git/test-src-git-HEAD.zip')
self.repo.tarball('HEAD')
- assert os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip")
+ assert os.path.isfile(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.zip"))
def test_all_commit_ids(self):
cids = list(self.repo.all_commit_ids())
@@ -293,20 +294,21 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
'name': u'README'}])
def test_tarball_status(self):
- if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip"):
- os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip")
- if os.path.isfile("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp"):
- os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")
- if os.path.isdir("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD/"):
- os.removedirs("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD/")
+ tmpdir = tg.config['scm.repos.tarball.root']
+ if os.path.isfile(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.zip")):
+ os.remove(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.zip"))
+ if os.path.isfile(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.tmp")):
+ os.remove(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.tmp"))
+ if os.path.isdir(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD/")):
+ os.removedirs(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD/"))
self.repo.tarball('HEAD')
assert_equal(self.repo.get_tarball_status('HEAD'), 'ready')
- os.rename("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.zip",
- "/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")
+ os.rename(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.zip"),
+ os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.tmp"))
assert_equal(self.repo.get_tarball_status('HEAD'), 'busy')
- os.remove("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD.tmp")
+ os.remove(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD.tmp"))
assert_equal(self.repo.get_tarball_status('HEAD'), None)
- os.makedirs("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD")
+ os.makedirs(os.path.join(tmpdir, "git/t/te/test/testgit.git/test-src-git-HEAD"))
assert_equal(self.repo.get_tarball_status('HEAD'), None)
def test_is_empty(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index bc4da97..2189a7f 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -204,7 +204,7 @@ class SVNImplementation(M.RepositoryImplementation):
# make first commit with dir structure
if default_dirs:
tmp_working_dir = tempfile.mkdtemp(prefix='allura-svn-r1-',
- dir=tg.config.get('scm.svn.tmpdir', '/tmp'))
+ dir=tg.config.get('scm.svn.tmpdir', g.tmpdir))
log.info('tmp dir = %s', tmp_working_dir)
self._repo._impl._svn.checkout('file://'+fullname, tmp_working_dir)
os.mkdir(tmp_working_dir+'/trunk')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index fa4feb0..288a1b9 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -24,7 +24,7 @@ from datetime import datetime
from zipfile import ZipFile
from collections import defaultdict
-from pylons import tmpl_context as c
+from pylons import tmpl_context as c, app_globals as g
import mock
from nose.tools import assert_equal
import tg
@@ -127,7 +127,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
def test_init(self):
repo = SM.Repository(
name='testsvn',
- fs_path='/tmp/',
+ fs_path=g.tmpdir+'/',
url_path = '/test/',
tool = 'svn',
status = 'creating')
@@ -140,7 +140,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
def test_fork(self):
repo = SM.Repository(
name='testsvn',
- fs_path='/tmp/',
+ fs_path=g.tmpdir+'/',
url_path = '/test/',
tool = 'svn',
status = 'creating')
@@ -151,10 +151,11 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
shutil.rmtree(dirname)
repo.init()
repo._impl.clone_from('file://' + repo_path)
- assert not os.path.exists('/tmp/testsvn/hooks/pre-revprop-change')
- assert os.path.exists('/tmp/testsvn/hooks/post-commit')
- assert os.access('/tmp/testsvn/hooks/post-commit', os.X_OK)
- with open('/tmp/testsvn/hooks/post-commit') as f: c = f.read()
+ assert not os.path.exists(os.path.join(g.tmpdir, 'testsvn/hooks/pre-revprop-change'))
+ assert os.path.exists(os.path.join(g.tmpdir, 'testsvn/hooks/post-commit'))
+ assert os.access(os.path.join(g.tmpdir, 'testsvn/hooks/post-commit'), os.X_OK)
+ with open(os.path.join(g.tmpdir, 'testsvn/hooks/post-commit')) as f:
+ c = f.read()
self.assertIn('curl -s http://localhost//auth/refresh_repo/p/test/src/\n', c)
self.assertIn('exec $DIR/post-commit-user "$@"\n', c)
@@ -186,7 +187,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
def test_clone(self, post_event):
repo = SM.Repository(
name='testsvn',
- fs_path='/tmp/',
+ fs_path=g.tmpdir+'/',
url_path = '/test/',
tool = 'svn',
status = 'creating')
@@ -197,10 +198,11 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
shutil.rmtree(dirname)
repo.init()
repo._impl.clone_from('file://' + repo_path)
- assert not os.path.exists('/tmp/testsvn/hooks/pre-revprop-change')
- assert os.path.exists('/tmp/testsvn/hooks/post-commit')
- assert os.access('/tmp/testsvn/hooks/post-commit', os.X_OK)
- with open('/tmp/testsvn/hooks/post-commit') as f: c = f.read()
+ assert not os.path.exists(os.path.join(g.tmpdir, 'testsvn/hooks/pre-revprop-change'))
+ assert os.path.exists(os.path.join(g.tmpdir, 'testsvn/hooks/post-commit'))
+ assert os.access(os.path.join(g.tmpdir, 'testsvn/hooks/post-commit'), os.X_OK)
+ with open(os.path.join(g.tmpdir, 'testsvn/hooks/post-commit')) as f:
+ c = f.read()
self.assertIn('curl -s http://localhost//auth/refresh_repo/p/test/src/\n', c)
self.assertIn('exec $DIR/post-commit-user "$@"\n', c)
@@ -291,11 +293,12 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
@onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
def test_tarball(self):
- assert_equal(self.repo.tarball_path, '/tmp/tarball/svn/t/te/test/testsvn')
+ tmpdir = tg.config['scm.repos.tarball.root']
+ assert_equal(self.repo.tarball_path, os.path.join(tmpdir, 'svn/t/te/test/testsvn'))
assert_equal(self.repo.tarball_url('1'), 'file:///svn/t/te/test/testsvn/test-src-1.zip')
self.repo.tarball('1')
- assert os.path.isfile("/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip")
- tarball_zip = ZipFile('/tmp/tarball/svn/t/te/test/testsvn/test-src-1.zip', 'r')
+ assert os.path.isfile(os.path.join(tmpdir, "svn/t/te/test/testsvn/test-src-1.zip"))
+ tarball_zip = ZipFile(os.path.join(tmpdir, 'svn/t/te/test/testsvn/test-src-1.zip'), 'r')
assert_equal(tarball_zip.namelist(), ['test-src-1/', 'test-src-1/README'])
def test_is_empty(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
index 5a4b484..9b78c0c 100644
--- a/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
+++ b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
@@ -18,6 +18,7 @@
from mock import Mock, MagicMock, patch
import pysvn
from nose.tools import assert_equal
+from pylons import app_globals as g
from allura.model.repo import Commit
from forgesvn.model.svn import Repository, SVNImplementation
@@ -36,7 +37,7 @@ class TestSVNImplementation(object):
@patch('allura.model.repo.Tree.upsert')
@patch('allura.model.repo.Tree.query.get')
def _test_compute_tree_new(self, path, tree_get, tree_upsert, treesdoc_partial, lcd_partial):
- repo = Mock(fs_path='/tmp/')
+ repo = Mock(fs_path=g.tmpdir+'/')
repo.name = 'code'
impl = SVNImplementation(repo)
impl._svn.info2 = Mock()
@@ -48,7 +49,7 @@ class TestSVNImplementation(object):
tree_id = impl.compute_tree_new(commit, path)
- assert_equal(impl._svn.info2.call_args[0][0], 'file:///tmp/code/trunk/foo')
+ assert_equal(impl._svn.info2.call_args[0][0], 'file://'+g.tmpdir+'/code/trunk/foo')
treesdoc_partial.assert_called()
lcd_partial.assert_called()
@@ -60,7 +61,7 @@ class TestSVNImplementation(object):
self._test_last_commit_ids('trunk/foo')
def _test_last_commit_ids(self, path):
- repo = Mock(fs_path='/tmp/')
+ repo = Mock(fs_path=g.tmpdir+'/')
repo.name = 'code'
repo._id = '5057636b9c1040636b81e4b1'
impl = SVNImplementation(repo)
@@ -72,4 +73,4 @@ class TestSVNImplementation(object):
entries = impl.last_commit_ids(commit, [path])
assert_equal(entries, {path.strip('/'): '5057636b9c1040636b81e4b1:1'})
- assert_equal(impl._svn.info2.call_args[0][0], 'file:///tmp/code/trunk')
+ assert_equal(impl._svn.info2.call_args[0][0], 'file://'+g.tmpdir+'/code/trunk')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/ForgeSVN/forgesvn/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/test_tasks.py b/ForgeSVN/forgesvn/tests/test_tasks.py
index 36e7912..d3d30d7 100644
--- a/ForgeSVN/forgesvn/tests/test_tasks.py
+++ b/ForgeSVN/forgesvn/tests/test_tasks.py
@@ -22,7 +22,7 @@ import unittest
import tg
import mock
-from pylons import tmpl_context as c
+from pylons import tmpl_context as c, app_globals as g
from ming.orm import ThreadLocalORMSession
from paste.deploy.converters import asbool
@@ -42,7 +42,7 @@ class TestRepoTasks(unittest.TestCase):
if asbool(tg.config.get('smtp.mock')):
self.smtp_mock = mock.patch('allura.lib.mail_util.smtplib.SMTP')
self.smtp_mock.start()
-
+
def tearDown(self):
if asbool(tg.config.get('smtp.mock')):
self.smtp_mock.stop()
@@ -75,4 +75,4 @@ class TestRepoTasks(unittest.TestCase):
def test_uninstall(self):
with mock.patch.object(shutil, 'rmtree') as f:
repo_tasks.uninstall()
- f.assert_called_with('/tmp/svn/p/test/src', ignore_errors=True)
+ f.assert_called_with(g.tmpdir+'/svn/p/test/src', ignore_errors=True)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c3ddcb1/ForgeWiki/forgewiki/tests/test_wiki2markdown.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_wiki2markdown.py b/ForgeWiki/forgewiki/tests/test_wiki2markdown.py
index 7442ff2..ff5c662 100644
--- a/ForgeWiki/forgewiki/tests/test_wiki2markdown.py
+++ b/ForgeWiki/forgewiki/tests/test_wiki2markdown.py
@@ -15,10 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-import mock
+import os
import json
from datetime import datetime
+
+import mock
from IPython.testing.decorators import module_not_available, skipif
+from pylons import app_globals as g
from forgewiki.scripts.wiki2markdown.extractors import MySQLExtractor
from forgewiki.scripts.wiki2markdown.loaders import MediawikiLoader
@@ -35,7 +38,7 @@ class TestMySQLExtractor(object):
def setUp(self):
setup_basic_test()
self.options = mock.Mock()
- self.options.dump_dir = '/tmp/w2m_test'
+ self.options.dump_dir = os.path.join(g.tmpdir, 'w2m_test')
# monkey-patch MySQLExtractor for test
def pages(self):
@@ -85,7 +88,7 @@ class TestMySQLExtractor(object):
self.extractor.extract_pages()
# rev 1 of page 1
- with open('/tmp/w2m_test/pages/1/history/1.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/1/history/1.json'), 'r') as f:
page = json.load(f)
res_page = {
'timestamp': 1,
@@ -97,7 +100,7 @@ class TestMySQLExtractor(object):
assert page == res_page
# rev 2 of page 1
- with open('/tmp/w2m_test/pages/1/history/2.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/1/history/2.json'), 'r') as f:
page = json.load(f)
res_page = {
'timestamp': 2,
@@ -109,7 +112,7 @@ class TestMySQLExtractor(object):
assert page == res_page
# rev 1 of page 2
- with open('/tmp/w2m_test/pages/2/history/1.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/2/history/1.json'), 'r') as f:
page = json.load(f)
res_page = {
'timestamp': 1,
@@ -121,7 +124,7 @@ class TestMySQLExtractor(object):
assert page == res_page
# rev 2 of page 2
- with open('/tmp/w2m_test/pages/2/history/2.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/2/history/2.json'), 'r') as f:
page = json.load(f)
res_page = {
'timestamp': 2,
@@ -133,7 +136,7 @@ class TestMySQLExtractor(object):
assert page == res_page
# rev 1 of page 3
- with open('/tmp/w2m_test/pages/3/history/1.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/3/history/1.json'), 'r') as f:
page = json.load(f)
res_page = {
'timestamp': 1,
@@ -145,7 +148,7 @@ class TestMySQLExtractor(object):
assert page == res_page
# rev 2 of page 3
- with open('/tmp/w2m_test/pages/3/history/2.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/3/history/2.json'), 'r') as f:
page = json.load(f)
res_page = {
'timestamp': 2,
@@ -166,21 +169,21 @@ class TestMySQLExtractor(object):
for page in pages:
self.extractor.extract_talk(page)
- with open('/tmp/w2m_test/pages/1/discussion.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/1/discussion.json'), 'r') as f:
page = json.load(f)
assert page == {
'text': 'Talk for page Test 1.',
'username': 'test-user',
'timestamp': 1}
- with open('/tmp/w2m_test/pages/2/discussion.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/2/discussion.json'), 'r') as f:
page = json.load(f)
assert page == {
'text': 'Talk for page Test 2.',
'timestamp': 1,
'username': 'test-user'}
- with open('/tmp/w2m_test/pages/3/discussion.json', 'r') as f:
+ with open(os.path.join(self.options.dump_dir, 'pages/3/discussion.json'), 'r') as f:
page = json.load(f)
assert page == {
'text': 'Talk for page Test 3.',