backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / tests / unit / ofproto / test_ofproto.py
1 # Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2013 Isaku Yamahata <yamahata at private email ne jp>
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # vim: tabstop=4 shiftwidth=4 softtabstop=4
18
19 try:
20     # Python 3
21     from imp import reload
22 except ImportError:
23     # Python 2
24     pass
25
26 import unittest
27 import logging
28 from nose.tools import eq_
29
30
31 LOG = logging.getLogger('test_ofproto')
32
33
34 class TestOfprotCommon(unittest.TestCase):
35     """ Test case for ofproto
36     """
37
38     def test_ofp_event(self):
39         import ryu.ofproto
40         reload(ryu.ofproto)
41         import ryu.controller.ofp_event
42         reload(ryu.controller.ofp_event)
43
44     def test_ofproto(self):
45         # When new version of OFP support is added,
46         # this test must be updated.
47         import ryu.ofproto
48         reload(ryu.ofproto)
49         ofp_modules = ryu.ofproto.get_ofp_modules()
50
51         import ryu.ofproto.ofproto_v1_0
52         import ryu.ofproto.ofproto_v1_2
53         import ryu.ofproto.ofproto_v1_3
54         import ryu.ofproto.ofproto_v1_4
55         import ryu.ofproto.ofproto_v1_5
56         eq_(set(ofp_modules.keys()), set([ryu.ofproto.ofproto_v1_0.OFP_VERSION,
57                                           ryu.ofproto.ofproto_v1_2.OFP_VERSION,
58                                           ryu.ofproto.ofproto_v1_3.OFP_VERSION,
59                                           ryu.ofproto.ofproto_v1_4.OFP_VERSION,
60                                           ryu.ofproto.ofproto_v1_5.OFP_VERSION,
61                                           ]))
62         consts_mods = set([ofp_mod[0] for ofp_mod in ofp_modules.values()])
63         eq_(consts_mods, set([ryu.ofproto.ofproto_v1_0,
64                               ryu.ofproto.ofproto_v1_2,
65                               ryu.ofproto.ofproto_v1_3,
66                               ryu.ofproto.ofproto_v1_4,
67                               ryu.ofproto.ofproto_v1_5,
68                               ]))
69
70         parser_mods = set([ofp_mod[1] for ofp_mod in ofp_modules.values()])
71         import ryu.ofproto.ofproto_v1_0_parser
72         import ryu.ofproto.ofproto_v1_2_parser
73         import ryu.ofproto.ofproto_v1_3_parser
74         import ryu.ofproto.ofproto_v1_4_parser
75         import ryu.ofproto.ofproto_v1_5_parser
76         eq_(parser_mods, set([ryu.ofproto.ofproto_v1_0_parser,
77                               ryu.ofproto.ofproto_v1_2_parser,
78                               ryu.ofproto.ofproto_v1_3_parser,
79                               ryu.ofproto.ofproto_v1_4_parser,
80                               ryu.ofproto.ofproto_v1_5_parser,
81                               ]))