From: Alfredo Deza Date: Tue, 9 Sep 2014 19:03:13 +0000 (-0400) Subject: tests for the new helper in process.py X-Git-Tag: 0.0.21~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c138e6613e256199dace318599e761bd9252d71;p=remoto.git tests for the new helper in process.py --- diff --git a/remoto/tests/test_process.py b/remoto/tests/test_process.py index 1eff8c3..3f53344 100644 --- a/remoto/tests/test_process.py +++ b/remoto/tests/test_process.py @@ -1,3 +1,24 @@ -# Having imports inlined in the function makes it really complicated to test -# while controlling the environment. Figure out a way to deal with inlined imports -# so testing evolves nicely. +from mock import Mock +from remoto import process + + +class TestExtendPath(object): + + def setup(self): + self.path = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin' + + def test_no_environment_sets_path(self): + fake_conn = Mock() + fake_conn.gateway.remote_exec.return_value = fake_conn + fake_conn.receive.return_value = {} + result = process.extend_path(fake_conn, {}) + assert result['env']['PATH'] == self.path + + def test_custom_path_does_not_get_overridden(self): + fake_conn = Mock() + fake_conn.gateway.remote_exec.return_value = fake_conn + fake_conn.receive.return_value = {'PATH': '/home/alfredo/bin'} + result = process.extend_path(fake_conn, {}) + new_path = result['env']['PATH'] + assert new_path.endswith(self.path) + assert '/home/alfredo/bin' in new_path