-
Notifications
You must be signed in to change notification settings - Fork 4
/
ovsdb_test.py
39 lines (32 loc) · 1.17 KB
/
ovsdb_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
35
36
37
38
39
import ovsdb
import unittest
import socket
class TestFunctions(unittest.TestCase):
def setUp(self):
OVSDB_IP = '127.0.0.1'
OVSDB_PORT = 6632
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((OVSDB_IP, OVSDB_PORT))
def test_list_dbs(self):
self.sock.send(ovsdb.list_dbs())
db_list = ovsdb.gather_reply(self.sock)
db_name = db_list['result'][0]
self.assertEqual(db_name, 'Open_vSwitch')
def test_monitor(self):
columns = {"Bridge":{"columns":["name"]}}
self.sock.send(ovsdb.monitor(columns))
result = ovsdb.gather_reply(self.sock)
self.assertEqual(result['error'], None)
self.assertEqual(result['id'], 0)
self.assertTrue("Bridge" in result['result'])
def test_list_br(self):
self.sock.send(ovsdb.list_bridges())
bridge_list = ovsdb.gather_reply(self.sock)
bridges = bridge_list['result']['Bridge']
#print bridges
print bridges.values()
self.assertTrue("br0" in bridges.values())
def test_choice(self):
self.assertTrue(True)
if __name__ == '__main__':
unittest.main()