diff --git a/VEfile b/VEfile index 8c31b63..136e887 100644 --- a/VEfile +++ b/VEfile @@ -1,3 +1,6 @@ +requirements: + - subwrap + --- profile: development diff --git a/VEfile.lock b/VEfile.lock index de3b41f..0478938 100644 --- a/VEfile.lock +++ b/VEfile.lock @@ -1,3 +1,4 @@ +subwrap (subwrap==0.0.1) nose (nose==1.1.2) testkit (testkit==0.1.1) fudge (fudge==1.0.3) diff --git a/overlay4u/overlay.py b/overlay4u/overlay.py index 78a28af..6c70f8f 100644 --- a/overlay4u/overlay.py +++ b/overlay4u/overlay.py @@ -1,4 +1,4 @@ -import subprocess +import subwrap from .mountutils import MountTable class AlreadyMounted(Exception): @@ -22,15 +22,12 @@ def mount(cls, mount_point, lower_dir, upper_dir, mount_table=None): # Build mount options options = "rw,lowerdir=%s,upperdir=%s" % (lower_dir, upper_dir) # Run the actual mount - process = subprocess.Popen(['mount', '-t', 'overlayfs', '-o', options, + process = subwrap.run(['mount', '-t', 'overlayfs', '-o', options, 'overlayfs', mount_point]) - # Wait for the mount to complete - process.wait() return cls(mount_point, lower_dir, upper_dir) def unmount(self): - process = subprocess.Popen(['umount', self.mount_point]) - process.wait() + process = subwrap.run(['umount', self.mount_point]) def __init__(self, mount_point, lower_dir, upper_dir): self.mount_point = mount_point diff --git a/setup.py b/setup.py index 185659c..744ed74 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ from setuptools import setup, find_packages -import sys, os VERSION = '0.0.1-dev' @@ -18,7 +17,9 @@ packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=False, - install_requires=[], + install_requires=[ + 'subwrap', + ], entry_points={}, classifiers=[ 'License :: OSI Approved :: MIT License', diff --git a/tests/test_mountutils.py b/tests/test_mountutils.py index 0d6ba75..7603115 100644 --- a/tests/test_mountutils.py +++ b/tests/test_mountutils.py @@ -13,7 +13,6 @@ TEST_MOUNT_LIST_ENTRY3 = '/dev3/.dir on /dir3/.dir type fstype2 (opt1=val,opt2,opt3=val)' TEST_MOUNT_LIST_ENTRY4 = '/dev4/dir-with-dash on /dir4/dir-with-dash type fstype2 (opt1=val,opt2,opt3=val)' - def test_generated_match_entry_line(): tests = [ (TEST_MOUNT_LIST_ENTRY1, ( diff --git a/tests/test_overlay4u.py b/tests/test_overlay4u.py index 248539d..b8fa14b 100644 --- a/tests/test_overlay4u.py +++ b/tests/test_overlay4u.py @@ -3,13 +3,12 @@ import overlay4u from overlay4u.overlay import AlreadyMounted -@fudge.patch('subprocess.Popen') -def test_fake_mount(fake_popen): +@fudge.patch('subwrap.run') +def test_fake_mount(fake_run): from overlay4u.overlay import OverlayFS - # Setup Popen expectation - fake_process = fake_popen.expects_call().returns_fake() - fake_process.expects('wait') + # Setup subwrap.run + fake_run.expects_call() # Setup fake mount table fake_mount_table = fudge.Fake('mount_table') @@ -23,34 +22,34 @@ def test_fake_mount(fake_popen): assert overlay.lower_dir == 'lower' assert overlay.upper_dir == 'upper' -@fudge.patch('subprocess.Popen', 'overlay4u.overlay.MountTable') -def test_fake_mount_with_fake_table(fake_popen, fake_table_class): - fake_popen.is_a_stub() +@fudge.patch('subwrap.run', 'overlay4u.overlay.MountTable') +def test_fake_mount_with_fake_table(fake_run, fake_table_class): + fake_run.expects_call() fake_table = fake_table_class.expects('load').returns_fake() fake_table.expects('is_mounted').returns(False) overlay = overlay4u.mount('mount_point', 'lower', 'upper') @raises(AlreadyMounted) -@fudge.patch('subprocess.Popen') -def test_fake_mount_twice(fake_popen): +@fudge.patch('subwrap.run') +def test_fake_mount_twice(fake_run): # Setup fake mount table checker fake_mount_table = fudge.Fake('mount_table') (fake_mount_table.expects('is_mounted').with_args('mount_point') .returns(True)) - # Make a stub for popen. just in case it gets through - fake_popen.is_a_stub() + # Make a stub for subwrap.run. just in case it gets through + fake_run.expects_call() # Use dependency injection to change mount verification technique overlay = overlay4u.mount('mount_point', 'lower', 'upper', mount_table=fake_mount_table) -@fudge.patch('subprocess.Popen', 'overlay4u.overlay.MountTable') -def test_fake_unmount(fake_popen, fake_table_class): +@fudge.patch('subwrap.run', 'overlay4u.overlay.MountTable') +def test_fake_unmount(fake_run, fake_table_class): # Tests that unmount method exists. # FIXME we need to make this a bit better - fake_popen.is_a_stub() + fake_run.expects_call() fake_table = fake_table_class.expects('load').returns_fake() fake_table.expects('is_mounted').returns(False)