/
test_fc_id.py
92 lines (78 loc) · 2.62 KB
/
test_fc_id.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#
# Copyright (c) 2013,2014 Juniper Networks, Inc. All rights reserved.
#
import gevent
import os
import sys
import socket
import errno
import uuid
import logging
import coverage
import cgitb
cgitb.enable(format='text')
import testtools
from testtools.matchers import Equals, MismatchError, Not, Contains
from testtools import content, content_type, ExpectedException
import unittest
import re
import json
import copy
import inspect
import pycassa
import kombu
import requests
from vnc_api.vnc_api import *
import vnc_api.gen.vnc_api_test_gen
from vnc_api.gen.resource_test import *
import cfgm_common
sys.path.append('../common/tests')
from test_utils import *
import test_common
import test_case
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class TestForwardingClassId(test_case.ApiServerTestCase):
def __init__(self, *args, **kwargs):
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)
super(TestForwardingClassId, self).__init__(*args, **kwargs)
def test_requested_fc_id(self):
fc1 = ForwardingClass(name = "fc1",
forwarding_class_id = 1)
fc1_id = self._vnc_lib.forwarding_class_create(fc1)
logger.debug('Created Forwarding class with ID 1')
test_fc = ForwardingClass(name = "test_fc",
forwarding_class_id = 1)
try:
self._vnc_lib.forwarding_class_create(test_fc)
self.assertTrue(False, 'Forwarding class updated'
'with duplicate ID... Test failed!!')
logger.debug(' Test failed! got id 1')
except:
logger.debug(' Test passed for FC id 1')
fc2 = ForwardingClass(name = "fc2",
forwarding_class_id = 2)
fc2_id = self._vnc_lib.forwarding_class_create(fc2)
logger.debug('Created Forwarding class with ID 2')
fc1.forwarding_class_id = 2
try:
self._vnc_lib.forwarding_class_update(fc1);
self.assertTrue(False, 'Forwarding class updated'
'with duplicate ID... Test failed!!')
except:
logger.debug(' Test passed for FC id 2')
gevent.sleep(0.1)
#cleanup
logger.debug('Cleaning up FC test case')
self._vnc_lib.forwarding_class_delete(id=fc1_id)
self._vnc_lib.forwarding_class_delete(id=fc2_id)
logger.debug('Cleaned up FC test case')
#end
#end class TestForwardingClass
if __name__ == '__main__':
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)
unittest.main()