Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """Tests for high-level Flow of OpenFlow 1.0 and 1.3.""" |
||
2 | import unittest |
||
3 | |||
4 | from kytos.core.switch import Switch |
||
5 | |||
6 | from napps.kytos.of_core.v0x01.flow import Flow as Flow01 |
||
7 | from napps.kytos.of_core.v0x04.flow import Flow as Flow04 |
||
8 | |||
9 | |||
10 | class TestFlow(unittest.TestCase): |
||
11 | """Test OF flow abstraction.""" |
||
12 | |||
13 | def test_flow_mod(self): |
||
14 | """Convert a dict to flow and vice-versa.""" |
||
15 | switch = Switch('dpid') |
||
16 | expected = { |
||
17 | 'id': '1ce5d08a46496fcb856cb603a5bfa00f', |
||
18 | 'switch': switch.id, |
||
19 | 'table_id': 1, |
||
20 | 'match': { |
||
21 | 'dl_src': '11:22:33:44:55:66' |
||
22 | }, |
||
23 | 'priority': 2, |
||
24 | 'idle_timeout': 3, |
||
25 | 'hard_timeout': 4, |
||
26 | 'cookie': 5, |
||
27 | 'actions': [ |
||
28 | {'action_type': 'set_vlan', |
||
29 | 'vlan_id': 6}], |
||
30 | 'stats': {}} |
||
31 | for flow_class in Flow01, Flow04: |
||
32 | with self.subTest(flow_class=flow_class): |
||
33 | flow = flow_class.from_dict(expected, switch) |
||
34 | actual = flow.as_dict() |
||
35 | self.assertDictEqual(expected, actual) |
||
36 |