From: Alfredo Deza Date: Tue, 21 Apr 2015 17:55:28 +0000 (-0400) Subject: create tests for the import_module method X-Git-Tag: 0.0.26~6^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=95b90c400ea09550da63c4f36ed8a2e865dab013;p=remoto.git create tests for the import_module method Signed-off-by: Alfredo Deza --- diff --git a/remoto/tests/fake_module.py b/remoto/tests/fake_module.py new file mode 100644 index 0000000..0252def --- /dev/null +++ b/remoto/tests/fake_module.py @@ -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 diff --git a/remoto/tests/test_connection.py b/remoto/tests/test_connection.py index 67fd05d..6996f00 100644 --- a/remoto/tests/test_connection.py +++ b/remoto/tests/test_connection.py @@ -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):