TestAction.test_all_actions()   A
last analyzed

Complexity

Conditions 5

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 17
rs 9.2833
c 0
b 0
f 0
cc 5
nop 1
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