summaryrefslogtreecommitdiff
path: root/morphlib/stagingarea_tests.py
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2013-02-20 14:49:43 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-02-28 11:35:20 +0000
commit5498cd4c3a503562530ea56529c952680d7d79c3 (patch)
tree948b45170b21414e3682d53491468375784ba2e0 /morphlib/stagingarea_tests.py
parent163d7e1dd8c84b93ddbb03b27f1a602cd660a402 (diff)
downloadmorph-5498cd4c3a503562530ea56529c952680d7d79c3.tar.gz
Hardlink files into the staging-area
Instead of repeatedly unpacking tarballs into a succession of staging- areas, it will unpack each tarball only once, then hardlink all the files into the staging-area instead.
Diffstat (limited to 'morphlib/stagingarea_tests.py')
-rw-r--r--morphlib/stagingarea_tests.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/morphlib/stagingarea_tests.py b/morphlib/stagingarea_tests.py
index 3230b9e3..313226d2 100644
--- a/morphlib/stagingarea_tests.py
+++ b/morphlib/stagingarea_tests.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Codethink Limited
+# Copyright (C) 2012,2013 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,6 +14,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import cliapp
import os
import shutil
import tarfile
@@ -31,14 +32,33 @@ class FakeSource(object):
}
+class FakeApplication(object):
+
+ def __init__(self, cachedir, tempdir):
+ self.settings = {
+ 'cachedir': cachedir,
+ 'tempdir': tempdir,
+ }
+
+ def runcmd(self, *args, **kwargs):
+ return cliapp.runcmd(*args, **kwargs)
+
+ def runcmd_unchecked(self, *args, **kwargs):
+ return cliapp.runcmd_unchecked(*args, **kwargs)
+
+
class StagingAreaTests(unittest.TestCase):
def setUp(self):
self.tempdir = tempfile.mkdtemp()
+ self.cachedir = os.path.join(self.tempdir, 'cachedir')
+ os.mkdir(self.cachedir)
+ os.mkdir(os.path.join(self.cachedir, 'artifacts'))
self.staging = os.path.join(self.tempdir, 'staging')
self.created_dirs = []
- self.sa = morphlib.stagingarea.StagingArea(object(), self.staging,
- self.staging)
+ self.sa = morphlib.stagingarea.StagingArea(
+ FakeApplication(self.cachedir, self.tempdir),
+ self.staging, self.staging)
def tearDown(self):
shutil.rmtree(self.tempdir)