diff options
author | pcarrier <pcarrier@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-11-27 20:10:56 +0000 |
---|---|---|
committer | pcarrier <pcarrier@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-11-27 20:10:56 +0000 |
commit | ca1ad543c9b92d73f486fa94e9b11d01936c150b (patch) | |
tree | 942815b0cb3e37a8ffa6688955d455cd00d8ebbc /tests | |
parent | dfed68943468c349b24fc928ff5c4b533c829fbe (diff) | |
download | sos-ca1ad543c9b92d73f486fa94e9b11d01936c150b.tar.gz |
[tests] worker: first bunch of tests
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@1035 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/worker.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/worker.py b/tests/worker.py new file mode 100644 index 00000000..5f7c2641 --- /dev/null +++ b/tests/worker.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import unittest +import pexpect + +class PexpectTest(unittest.TestCase): + + + def setUp(self): + self.worker = pexpect.spawn('python ../worker/worker.py') + # worker should always be very fast to span + self.expect('#0#\r\n') + + def sendlines(self, lines): + for line in lines: + self.worker.sendline(line) + self.worker.expect(line+'\r\n') + + def expect(self, v, timeout = 3): + self.worker.expect(v, timeout) + self.assertEqual(self.worker.before, "") + + def test_exit(self): + self.sendlines(['exit']) + self.expect(pexpect.EOF) + + def test_basic_noop(self): + self.sendlines(['noop']) + self.expect('#1#\r\n') + self.test_exit() + + def test_basic_ping(self): + self.sendlines(['ping']) + self.expect('ALIVE\r\n#1#\r\n') + self.test_exit() + + def test_basic_glob(self): + self.sendlines(['glob', '/*bin']) + self.expect('2\r\n(/bin\r\n/sbin|/sbin\r\n/bin)\r\n') + self.test_exit() + +if __name__ == '__main__': + unittest.main() |