| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Test Action abstraction for v0x01 and v0x04.""" |
||
| 2 | import unittest |
||
| 3 | |||
| 4 | from napps.kytos.of_core.v0x01.flow import Action as Action01 |
||
| 5 | from napps.kytos.of_core.v0x04.flow import Action as Action04 |
||
| 6 | |||
| 7 | |||
| 8 | class TestAction(unittest.TestCase): |
||
| 9 | """Tests for the Action class.""" |
||
| 10 | |||
| 11 | def test_all_actions(self): |
||
| 12 | """Test all action fields from and to dict.""" |
||
| 13 | action_dicts = [ |
||
| 14 | { |
||
| 15 | 'action_type': 'output', |
||
| 16 | 'port': 1}, |
||
| 17 | { |
||
| 18 | 'action_type': 'set_vlan', |
||
| 19 | 'vlan_id': 2}, |
||
| 20 | ] |
||
| 21 | for action_class in Action01, Action04: |
||
| 22 | with self.subTest(action_class=action_class): |
||
| 23 | for expected in action_dicts: |
||
| 24 | with self.subTest(expected=expected): |
||
| 25 | action = action_class.from_dict(expected) |
||
| 26 | actual = action.as_dict() |
||
| 27 | self.assertDictEqual(expected, actual) |
||
| 28 |