Permalink
Browse files

Adding some unit tests. More to come

  • Loading branch information...
1 parent b9c3ee4 commit 050f7f1b73c12f1980c32bec192c1d59c4167b19 @bkjones committed Feb 28, 2012
Showing with 41 additions and 0 deletions.
  1. +41 −0 test.py
View
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+__author__ = 'Brian K. Jones'
+__email__ = 'bkjones@gmail.com'
+
+import unittest2 as unittest
+from mock import Mock, patch, patch_object
+from cmd import Cmd
+from StringIO import StringIO
+from bunnyq import Bunny
+
+class TestBunny(unittest.TestCase):
+ def setUp(self):
+ Bunny.request = Mock()
+ Bunny.do_connect = Mock(return_value=True)
+ self.b = Bunny('foo', 9090, 'guest', 'guest')
+
+ def test_instance(self):
+ host = 'foo.bar'
+ port = 9090
+ user = 'guest'
+ password = 'guest'
+ b = Bunny(host, port, user, password)
+ self.assertIsInstance(b, Bunny)
+ self.assertIsInstance(b, Cmd)
+
+ def test_list_vhost(self):
+ self.b.request.return_value = [{'name': 'v1', 'foo': 'bar'},
+ {'name': 'v2', 'baz': 'quux'}]
+ sout = StringIO()
+ expected_out = "v1\nv2\n"
+ with patch('sys.stdout', new=sout) as out:
+ self.b.do_list_vhosts(None)
+ self.assertEqual(expected_out, out.getvalue())
+
+
+
+
+
+
+

0 comments on commit 050f7f1

Please sign in to comment.