Signed-off-by: Satoshi Fujimoto <[email protected]>
---
 .../unit/services/protocols/bgp/utils/test_bgp.py  | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py 
b/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py
index 25ecd05..121239f 100644
--- a/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py
+++ b/ryu/tests/unit/services/protocols/bgp/utils/test_bgp.py
@@ -28,6 +28,7 @@ from ryu.lib.packet.bgp import (
 
 from ryu.services.protocols.bgp.core import BgpCoreError
 from ryu.services.protocols.bgp.utils.bgp import create_v4flowspec_actions
+from ryu.services.protocols.bgp.utils.bgp import create_v6flowspec_actions
 
 
 LOG = logging.getLogger(__name__)
@@ -83,3 +84,49 @@ class Test_Utils_BGP(unittest.TestCase):
         }
         expected_communities = []
         self._test_create_v4flowspec_actions(actions, expected_communities)
+
+    def _test_create_v6flowspec_actions(self, actions, expected_communities):
+        communities = create_v6flowspec_actions(actions)
+        expected_communities.sort(key=lambda x: x.subtype)
+        communities.sort(key=lambda x: x.subtype)
+        eq_(str(expected_communities), str(communities))
+
+    def test_create_v6flowspec_actions_all_actions(self):
+        actions = {
+            'traffic_rate': {
+                'as_number': 0,
+                'rate_info': 100.0,
+            },
+            'traffic_action': {
+                'action': 3,
+            },
+            'redirect': {
+                'as_number': 10,
+                'local_administrator': 10,
+            },
+            'traffic_marking': {
+                'dscp': 24,
+            }
+        }
+        expected_communities = [
+            BGPFlowSpecTrafficRateCommunity(as_number=0, rate_info=100.0),
+            BGPFlowSpecTrafficActionCommunity(action=3),
+            BGPFlowSpecRedirectCommunity(as_number=10, local_administrator=10),
+            BGPFlowSpecTrafficMarkingCommunity(dscp=24),
+        ]
+        self._test_create_v6flowspec_actions(actions, expected_communities)
+
+    def test_create_v6flowspec_actions_without_actions(self):
+        actions = None
+        expected_communities = []
+        self._test_create_v6flowspec_actions(actions, expected_communities)
+
+    @raises(ValueError)
+    def test_create_v6flowspec_actions_not_exist_actions(self):
+        actions = {
+            'traffic_test': {
+                'test': 10,
+            },
+        }
+        expected_communities = []
+        self._test_create_v6flowspec_actions(actions, expected_communities)
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to