| Total Complexity | 3 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Test Match abstraction for v0x01 and v0x04.""" |
||
| 2 | import unittest |
||
| 3 | |||
| 4 | from napps.kytos.of_core.v0x01.flow import Match as Match01 |
||
| 5 | from napps.kytos.of_core.v0x04.flow import Match as Match04 |
||
| 6 | |||
| 7 | |||
| 8 | class TestMatch(unittest.TestCase): |
||
| 9 | """Tests for the Match class.""" |
||
| 10 | |||
| 11 | def test_all_fields(self): |
||
| 12 | """Test all match fields from and to dict.""" |
||
| 13 | expected = { |
||
| 14 | 'in_port': 1, |
||
| 15 | 'dl_src': '11:22:33:44:55:66', |
||
| 16 | 'dl_dst': 'aa:bb:cc:dd:ee:ff', |
||
| 17 | 'dl_vlan': 2, |
||
| 18 | 'dl_vlan_pcp': 3, |
||
| 19 | 'dl_type': 4, |
||
| 20 | 'nw_proto': 5, |
||
| 21 | 'nw_src': '1.2.3.4/32', |
||
| 22 | 'nw_dst': '5.6.7.0/24', |
||
| 23 | 'tp_src': 6, |
||
| 24 | 'tp_dst': 7} |
||
| 25 | for match_class in Match01, Match04: |
||
| 26 | with self.subTest(match_class=match_class): |
||
| 27 | match = match_class.from_dict(expected) |
||
| 28 | actual = match.as_dict() |
||
| 29 | self.assertDictEqual(expected, actual) |
||
| 30 |