|
@@ 604-641 (lines=38) @@
|
| 601 |
|
self.assertEqual(chose_vlans_mock.call_count, 1) |
| 602 |
|
log_mock.info.assert_called_once_with(f"{evc} was deployed.") |
| 603 |
|
|
| 604 |
|
@patch('napps.kytos.mef_eline.models.log') |
| 605 |
|
@patch('napps.kytos.mef_eline.models.EVC.choose_vlans') |
| 606 |
|
@patch('napps.kytos.mef_eline.models.EVC.install_nni_flows') |
| 607 |
|
@patch('napps.kytos.mef_eline.models.EVC.install_uni_flows') |
| 608 |
|
@patch('napps.kytos.mef_eline.models.EVC.activate') |
| 609 |
|
@patch('napps.kytos.mef_eline.models.EVC.should_deploy') |
| 610 |
|
def test_deploy_fail(self, *args): |
| 611 |
|
"""Test if all methods is ignored when the should_deploy is false.""" |
| 612 |
|
(should_deploy_mock, activate_mock, install_uni_flows_mock, |
| 613 |
|
install_nni_flows, chose_vlans_mock, log_mock) = args |
| 614 |
|
|
| 615 |
|
should_deploy_mock.return_value = False |
| 616 |
|
uni_a = get_uni_mocked(interface_port=2, tag_value=82, |
| 617 |
|
switch_id="switch_uni_a", is_valid=True) |
| 618 |
|
uni_z = get_uni_mocked(interface_port=3, tag_value=83, |
| 619 |
|
switch_id="switch_uni_z", is_valid=True) |
| 620 |
|
|
| 621 |
|
attributes = { |
| 622 |
|
"name": "custom_name", |
| 623 |
|
"uni_a": uni_a, |
| 624 |
|
"uni_z": uni_z, |
| 625 |
|
"primary_links": [ |
| 626 |
|
get_link_mocked(endpoint_a_port=9, endpoint_b_port=10, |
| 627 |
|
metadata={"s_vlan": 5}), |
| 628 |
|
get_link_mocked(endpoint_a_port=11, endpoint_b_port=12, |
| 629 |
|
metadata={"s_vlan": 6}) |
| 630 |
|
] |
| 631 |
|
} |
| 632 |
|
|
| 633 |
|
evc = EVC(**attributes) |
| 634 |
|
evc.deploy() |
| 635 |
|
|
| 636 |
|
self.assertEqual(should_deploy_mock.call_count, 1) |
| 637 |
|
self.assertEqual(activate_mock.call_count, 0) |
| 638 |
|
self.assertEqual(install_uni_flows_mock.call_count, 0) |
| 639 |
|
self.assertEqual(install_nni_flows.call_count, 0) |
| 640 |
|
self.assertEqual(chose_vlans_mock.call_count, 0) |
| 641 |
|
self.assertEqual(log_mock.info.call_count, 0) |
| 642 |
|
|
|
@@ 565-602 (lines=38) @@
|
| 562 |
|
switch = evc.primary_links[0].endpoint_b.switch |
| 563 |
|
send_flow_mods_mock.assert_called_once_with(switch, expected_flow_mods) |
| 564 |
|
|
| 565 |
|
@patch('napps.kytos.mef_eline.models.log') |
| 566 |
|
@patch('napps.kytos.mef_eline.models.EVC.choose_vlans') |
| 567 |
|
@patch('napps.kytos.mef_eline.models.EVC.install_nni_flows') |
| 568 |
|
@patch('napps.kytos.mef_eline.models.EVC.install_uni_flows') |
| 569 |
|
@patch('napps.kytos.mef_eline.models.EVC.activate') |
| 570 |
|
@patch('napps.kytos.mef_eline.models.EVC.should_deploy') |
| 571 |
|
def test_deploy_successfully(self, *args): |
| 572 |
|
"""Test if all methods to deploy are called.""" |
| 573 |
|
(should_deploy_mock, activate_mock, install_uni_flows_mock, |
| 574 |
|
install_nni_flows, chose_vlans_mock, log_mock) = args |
| 575 |
|
|
| 576 |
|
should_deploy_mock.return_value = True |
| 577 |
|
uni_a = get_uni_mocked(interface_port=2, tag_value=82, |
| 578 |
|
switch_id="switch_uni_a", is_valid=True) |
| 579 |
|
uni_z = get_uni_mocked(interface_port=3, tag_value=83, |
| 580 |
|
switch_id="switch_uni_z", is_valid=True) |
| 581 |
|
|
| 582 |
|
attributes = { |
| 583 |
|
"name": "custom_name", |
| 584 |
|
"uni_a": uni_a, |
| 585 |
|
"uni_z": uni_z, |
| 586 |
|
"primary_links": [ |
| 587 |
|
get_link_mocked(endpoint_a_port=9, endpoint_b_port=10, |
| 588 |
|
metadata={"s_vlan": 5}), |
| 589 |
|
get_link_mocked(endpoint_a_port=11, endpoint_b_port=12, |
| 590 |
|
metadata={"s_vlan": 6}) |
| 591 |
|
] |
| 592 |
|
} |
| 593 |
|
|
| 594 |
|
evc = EVC(**attributes) |
| 595 |
|
evc.deploy() |
| 596 |
|
|
| 597 |
|
self.assertEqual(should_deploy_mock.call_count, 1) |
| 598 |
|
self.assertEqual(activate_mock.call_count, 1) |
| 599 |
|
self.assertEqual(install_uni_flows_mock.call_count, 1) |
| 600 |
|
self.assertEqual(install_nni_flows.call_count, 1) |
| 601 |
|
self.assertEqual(chose_vlans_mock.call_count, 1) |
| 602 |
|
log_mock.info.assert_called_once_with(f"{evc} was deployed.") |
| 603 |
|
|
| 604 |
|
@patch('napps.kytos.mef_eline.models.log') |
| 605 |
|
@patch('napps.kytos.mef_eline.models.EVC.choose_vlans') |