aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--machammer/functions.py6
-rwxr-xr-xtests.py9
2 files changed, 13 insertions, 2 deletions
diff --git a/machammer/functions.py b/machammer/functions.py
index 01e49bb..fa4fc63 100644
--- a/machammer/functions.py
+++ b/machammer/functions.py
@@ -145,7 +145,6 @@ def is_laptop():
def is_desktop():
return not is_laptop()
-
def mount_image(path, mp=None, *args):
"""Mount disk image and return path to mountpoint."""
logging.debug('Mounting image %s' % path)
@@ -160,6 +159,7 @@ def mount_image(path, mp=None, *args):
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE)
+
# work around EULA prompt
out, err = p.communicate(input=b'Q\nY\n')
logging.debug('mount_image got %s' % out)
@@ -172,7 +172,7 @@ def mount_image(path, mp=None, *args):
def mount_and_install(dmg, pkg):
"""Mounts the DMG and installs the PKG."""
- with mount_image(dmg) as p:
+ with mount(dmg) as p:
install_pkg(os.path.join(p, pkg))
@@ -241,7 +241,9 @@ def mount(what, where=None):
raise Exception('Invalid path: %s' % what)
where = mount_image(what, where)
+
yield where
+
eject(where)
diff --git a/tests.py b/tests.py
index e860cfc..95288b7 100755
--- a/tests.py
+++ b/tests.py
@@ -144,6 +144,15 @@ class AppsTestCase(TestCase):
self.assertTrue(len(results) > 10)
+class InstallerTestCase(TestCase):
+ def setUp(self):
+ self.pkg = os.getenv('MH_PKG')
+ self.image = os.getenv('MH_IMAGE')
+
+ def test_mount_and_install(self):
+ functions.mount_and_install(self.image, self.pkg)
+
+
class MountTestCase(TestCase):
def setUp(self):
self.mp = None