-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
41 lines (29 loc) · 1.04 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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())