Skip to content

Commit

Permalink
Adding some unit tests. More to come
Browse files Browse the repository at this point in the history
  • Loading branch information
bkjones committed Feb 28, 2012
1 parent b9c3ee4 commit 050f7f1
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

__author__ = 'Brian K. Jones'
__email__ = '[email protected]'

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.