summaryrefslogtreecommitdiffhomepage
path: root/ryu/tests/unit/ofproto/test_ofproto.py
blob: 47f1e544d5c894c57543ce230d9564efee8f3170 (plain)
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
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2013 Isaku Yamahata <yamahata at private email ne jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# vim: tabstop=4 shiftwidth=4 softtabstop=4

try:
    # Python 3
    from imp import reload
except ImportError:
    # Python 2
    pass

import unittest
import logging
from nose.tools import eq_


LOG = logging.getLogger('test_ofproto')


class TestOfprotCommon(unittest.TestCase):
    """ Test case for ofproto
    """

    def test_ofp_event(self):
        import ryu.ofproto
        reload(ryu.ofproto)
        import ryu.controller.ofp_event
        reload(ryu.controller.ofp_event)

    def test_ofproto(self):
        # When new version of OFP support is added,
        # this test must be updated.
        import ryu.ofproto
        reload(ryu.ofproto)
        ofp_modules = ryu.ofproto.get_ofp_modules()

        import ryu.ofproto.ofproto_v1_0
        import ryu.ofproto.ofproto_v1_2
        import ryu.ofproto.ofproto_v1_3
        import ryu.ofproto.ofproto_v1_4
        import ryu.ofproto.ofproto_v1_5
        eq_(set(ofp_modules.keys()), set([ryu.ofproto.ofproto_v1_0.OFP_VERSION,
                                          ryu.ofproto.ofproto_v1_2.OFP_VERSION,
                                          ryu.ofproto.ofproto_v1_3.OFP_VERSION,
                                          ryu.ofproto.ofproto_v1_4.OFP_VERSION,
                                          ryu.ofproto.ofproto_v1_5.OFP_VERSION,
                                          ]))
        consts_mods = set([ofp_mod[0] for ofp_mod in ofp_modules.values()])
        eq_(consts_mods, set([ryu.ofproto.ofproto_v1_0,
                              ryu.ofproto.ofproto_v1_2,
                              ryu.ofproto.ofproto_v1_3,
                              ryu.ofproto.ofproto_v1_4,
                              ryu.ofproto.ofproto_v1_5,
                              ]))

        parser_mods = set([ofp_mod[1] for ofp_mod in ofp_modules.values()])
        import ryu.ofproto.ofproto_v1_0_parser
        import ryu.ofproto.ofproto_v1_2_parser
        import ryu.ofproto.ofproto_v1_3_parser
        import ryu.ofproto.ofproto_v1_4_parser
        import ryu.ofproto.ofproto_v1_5_parser
        eq_(parser_mods, set([ryu.ofproto.ofproto_v1_0_parser,
                              ryu.ofproto.ofproto_v1_2_parser,
                              ryu.ofproto.ofproto_v1_3_parser,
                              ryu.ofproto.ofproto_v1_4_parser,
                              ryu.ofproto.ofproto_v1_5_parser,
                              ]))