test_bgpspeaker: Add unit tests for L2VPN Flow Spec

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Satoshi Fujimoto 2017-05-09 16:09:55 +09:00 committed by FUJITA Tomonori
parent d37a311829
commit 2bcb040dcb
1 changed files with 66 additions and 0 deletions

View File

@ -1020,3 +1020,69 @@ class Test_BGPSpeaker(unittest.TestCase):
# Check
mock_call.assert_called_with(
'flowspec.del_local', **expected_kwargs)
@mock.patch(
'ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__',
mock.MagicMock(return_value=None))
@mock.patch('ryu.services.protocols.bgp.bgpspeaker.call')
def test_flowspec_prefix_add_l2vpn(self, mock_call):
# Prepare test data
flowspec_family = bgpspeaker.FLOWSPEC_FAMILY_L2VPN
route_dist = '65001:100'
rules = {
'dst_mac': '12:34:56:78:9a:bc',
}
actions = {
'traffic_marking': {
'dscp': 24,
}
}
expected_kwargs = {
'flowspec_family': flowspec_family,
'route_dist': route_dist,
'rules': rules,
'actions': actions,
}
# Test
speaker = bgpspeaker.BGPSpeaker(65000, '10.0.0.1')
speaker.flowspec_prefix_add(
flowspec_family=flowspec_family,
route_dist=route_dist,
rules=rules,
actions=actions)
# Check
mock_call.assert_called_with(
'flowspec.add_local', **expected_kwargs)
@mock.patch(
'ryu.services.protocols.bgp.bgpspeaker.BGPSpeaker.__init__',
mock.MagicMock(return_value=None))
@mock.patch('ryu.services.protocols.bgp.bgpspeaker.call')
def test_flowspec_prefix_del_l2vpn(self, mock_call):
# Prepare test data
flowspec_family = bgpspeaker.FLOWSPEC_FAMILY_L2VPN
route_dist = '65001:100'
rules = {
'dst_mac': '12:34:56:78:9a:bc',
}
expected_kwargs = {
'flowspec_family': flowspec_family,
'route_dist': route_dist,
'rules': rules,
}
# Test
speaker = bgpspeaker.BGPSpeaker(65000, '10.0.0.1')
speaker.flowspec_prefix_del(
flowspec_family=flowspec_family,
route_dist=route_dist,
rules=rules)
# Check
mock_call.assert_called_with(
'flowspec.del_local', **expected_kwargs)