Tim Savage  committed b1b4014 Draft

Added tests for package/debian, updated test._utils to help with result object tests.

  • Participants
  • Parent commits d3a887b
  • Branches default

Comments (0)

Files changed (4)

File denim/package/

 # -*- encoding:utf8 -*-
-from fabric.api import sudo
 from denim import utils
     :param name: name of the package to install.
-    sudo('apt-get install "%s"' % name)
+    utils.run_as('apt-get install "%s"' % name, use_sudo=True)

File tests/

 from denim.utils import set_api_wrapper, api_wrapper
+class Result(object):
+    def __init__(self, succeeded=True):
+        self.succeeded = succeeded
 class TestApiWrapper(object):
     An easily replaceable wrapper around api commands to allow for easy
         self.commands = []
     def sudo(self, command, **kwargs):
-        return self.commands.append(('sudo', command, kwargs))
+        self.commands.append(('sudo', command, kwargs))
+        return Result()
     def run(self, command, **kwargs):
-        return self.commands.append(('run', command, kwargs))
+        self.commands.append(('run', command, kwargs))
+        return Result()
     def local(self, command, **kwargs):
-        return self.commands.append(('local', command, kwargs))
+        self.commands.append(('local', command, kwargs))
+        return Result()
         self.assertCommand((_scope, command, kwargs), self.api.commands[0])
     def assertSudo(self, command, **kwargs):
-        self.assertSingeCommand(command, _scope='sudo', **kwargs)
+        return self.assertSingeCommand(command, _scope='sudo', **kwargs)
     def assertRun(self, command, **kwargs):
-        self.assertSingeCommand(command, _scope='run', **kwargs)
+        return self.assertSingeCommand(command, _scope='run', **kwargs)
     def assertLocal(self, command, **kwargs):
-        self.assertSingeCommand(command, _scope='local', **kwargs)
+        return self.assertSingeCommand(command, _scope='local', **kwargs)

File tests/package/

Empty file added.

File tests/package/

+from denim.constants import RootUser
+from tests._utils import ApiTestCase
+from denim.package import debian
+class TestPackageDebian(ApiTestCase):
+    def test_is_installed_command(self):
+        debian.is_installed('python')
+        self.assertRun('dpkg --status "python" | grep Status')
+    def test_install(self):
+        debian.install('python')
+        self.assertSudo('apt-get install "python"', user=RootUser)