Merge pull request #50 from TedSinger/patch-1

Update test_envoy.py
This commit is contained in:
Kenneth Reitz
2012-11-15 17:55:21 -08:00
+20 -2
View File
@@ -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()