]> git-server-git.apps.pok.os.sepia.ceph.com Git - remoto.git/commitdiff
create tests for the import_module method
authorAlfredo Deza <alfredo@deza.pe>
Tue, 21 Apr 2015 17:55:28 +0000 (13:55 -0400)
committerAlfredo Deza <alfredo@deza.pe>
Tue, 21 Apr 2015 17:55:28 +0000 (13:55 -0400)
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
remoto/tests/fake_module.py [new file with mode: 0644]
remoto/tests/test_connection.py

diff --git a/remoto/tests/fake_module.py b/remoto/tests/fake_module.py
new file mode 100644 (file)
index 0000000..0252def
--- /dev/null
@@ -0,0 +1,7 @@
+"""
+this is just a stub module to use to test the `import_module` functionality in
+remoto
+"""
+
+def function(conn):
+    return True
index 67fd05d54f9d3c7eb2aa8c1b8d025aeb097099c2..6996f00c82110d5b496454259ffbdfa3141c7edb 100644 (file)
@@ -1,6 +1,7 @@
 from mock import Mock
 from py.test import raises
 from remoto import connection
+import fake_module
 
 
 class FakeSocket(object):
@@ -29,13 +30,27 @@ class TestNeedsSsh(object):
         assert connection.needs_ssh('foo.example.org', socket) is False
 
 
-
 class FakeGateway(object):
 
     def remote_exec(self, module):
         pass
 
 
+class TestRemoteModule(object):
+
+    def setup(self):
+        self.conn = connection.Connection('localhost', sudo=True, eager=False)
+        self.conn.gateway = FakeGateway()
+
+    def test_importing_it_sets_it_as_remote_module(self):
+        self.conn.import_module(fake_module)
+        assert fake_module == self.conn.remote_module.module
+
+    def test_importing_it_returns_the_module_too(self):
+        remote_foo = self.conn.import_module(fake_module)
+        assert remote_foo.module == fake_module
+
+
 class TestModuleExecuteArgs(object):
 
     def setup(self):