]> git-server-git.apps.pok.os.sepia.ceph.com Git - remoto.git/commitdiff
tests for the new helper in process.py
authorAlfredo Deza <alfredo@deza.pe>
Tue, 9 Sep 2014 19:03:13 +0000 (15:03 -0400)
committerAlfredo Deza <alfredo@deza.pe>
Tue, 9 Sep 2014 19:03:13 +0000 (15:03 -0400)
remoto/tests/test_process.py

index 1eff8c3676fb28c702c4504a2cdfbc76418a66df..3f5334495bae7a5e34b5180ff0db0a954d6cc6d4 100644 (file)
@@ -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