mirror of
https://github.com/not-kennethreitz/envoy.git
synced 2026-06-05 23:20:19 +00:00
+20
-2
@@ -1,5 +1,6 @@
|
||||
import unittest
|
||||
import envoy
|
||||
import time
|
||||
|
||||
class SimpleTest(unittest.TestCase):
|
||||
|
||||
@@ -18,6 +19,7 @@ class SimpleTest(unittest.TestCase):
|
||||
self.assertEqual(r.std_out, 'y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n')
|
||||
self.assertEqual(r.status_code, 0)
|
||||
|
||||
# THIS TEST FAILS BECAUSE expand_args DOESN'T HANDLE QUOTES PROPERLY
|
||||
def test_quoted_args(self):
|
||||
sentinel = 'quoted_args' * 3
|
||||
r = envoy.run("python -c 'print \"%s\"'" % sentinel)
|
||||
@@ -26,9 +28,25 @@ class SimpleTest(unittest.TestCase):
|
||||
|
||||
class ConnectedCommandTests(unittest.TestCase):
|
||||
|
||||
def test_status_code(self):
|
||||
def test_status_code_none(self):
|
||||
c = envoy.connect("sleep 5")
|
||||
self.assertEqual(c.status_code, None)
|
||||
|
||||
def test_status_code_success(self):
|
||||
c = envoy.connect("sleep 1")
|
||||
time.sleep(2)
|
||||
self.assertEqual(c.status_code, 0)
|
||||
|
||||
def test_status_code_failure(self):
|
||||
c = envoy.connect("sleeep 1")
|
||||
self.assertEqual(c.status_code, 127)
|
||||
|
||||
def test_input(self):
|
||||
test_string = 'asdfQWER'
|
||||
r = envoy.connect("cat | tr [:lower:] [:upper:]")
|
||||
r.send(test_string)
|
||||
self.assertEqual(r.std_out, test_string.upper())
|
||||
self.assertEqual(r.status_code, 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user