| @@ 1652-1697 (lines=46) @@ | ||
| 1649 | mock_notify_topology_update.assert_called_once() |
|
| 1650 | assert mock_notify_interface_status.call_count == 2 |
|
| 1651 | ||
| 1652 | @patch('napps.kytos.topology.main.Main.notify_interface_status') |
|
| 1653 | @patch('napps.kytos.topology.main.Main.notify_topology_update') |
|
| 1654 | @patch('napps.kytos.topology.main.Main.notify_link_status_change') |
|
| 1655 | def test_interruption_end( |
|
| 1656 | self, |
|
| 1657 | mock_notify_link_status_change, |
|
| 1658 | mock_notify_topology_update, |
|
| 1659 | mock_notify_interface_status, |
|
| 1660 | ): |
|
| 1661 | """Tests processing of received interruption end events.""" |
|
| 1662 | link_a = MagicMock() |
|
| 1663 | link_b = MagicMock() |
|
| 1664 | link_c = MagicMock() |
|
| 1665 | self.napp.controller.links = { |
|
| 1666 | 'link_a': link_a, |
|
| 1667 | 'link_b': link_b, |
|
| 1668 | 'link_c': link_c, |
|
| 1669 | } |
|
| 1670 | mock_get_interface = MagicMock(side_effect=[Mock(), Mock()]) |
|
| 1671 | self.napp.controller.get_interface_by_id = mock_get_interface |
|
| 1672 | event = KytosEvent( |
|
| 1673 | "topology.interruption.start", |
|
| 1674 | { |
|
| 1675 | 'type': 'test_interruption', |
|
| 1676 | 'switches': [ |
|
| 1677 | ], |
|
| 1678 | 'interfaces': [ |
|
| 1679 | 'intf_a', |
|
| 1680 | 'intf_b', |
|
| 1681 | ], |
|
| 1682 | 'links': [ |
|
| 1683 | 'link_a', |
|
| 1684 | 'link_c', |
|
| 1685 | ], |
|
| 1686 | } |
|
| 1687 | ) |
|
| 1688 | self.napp.handle_interruption_end(event) |
|
| 1689 | mock_notify_link_status_change.assert_has_calls( |
|
| 1690 | [ |
|
| 1691 | call(link_a, 'test_interruption'), |
|
| 1692 | call(link_c, 'test_interruption'), |
|
| 1693 | ] |
|
| 1694 | ) |
|
| 1695 | assert mock_notify_link_status_change.call_count == 2 |
|
| 1696 | mock_notify_topology_update.assert_called_once() |
|
| 1697 | assert mock_notify_interface_status.call_count == 2 |
|
| 1698 | ||
| 1699 | async def test_set_tag_range(self): |
|
| 1700 | """Test set_tag_range""" |
|
| @@ 1605-1650 (lines=46) @@ | ||
| 1602 | self.napp.notify_switch_links_status(mock_switch, "link enabled") |
|
| 1603 | assert self.napp.controller.buffers.app.put.call_count == 1 |
|
| 1604 | ||
| 1605 | @patch('napps.kytos.topology.main.Main.notify_interface_status') |
|
| 1606 | @patch('napps.kytos.topology.main.Main.notify_topology_update') |
|
| 1607 | @patch('napps.kytos.topology.main.Main.notify_link_status_change') |
|
| 1608 | def test_interruption_start( |
|
| 1609 | self, |
|
| 1610 | mock_notify_link_status_change, |
|
| 1611 | mock_notify_topology_update, |
|
| 1612 | mock_notify_interface_status, |
|
| 1613 | ): |
|
| 1614 | """Tests processing of received interruption start events.""" |
|
| 1615 | link_a = MagicMock() |
|
| 1616 | link_b = MagicMock() |
|
| 1617 | link_c = MagicMock() |
|
| 1618 | self.napp.controller.links = { |
|
| 1619 | 'link_a': link_a, |
|
| 1620 | 'link_b': link_b, |
|
| 1621 | 'link_c': link_c, |
|
| 1622 | } |
|
| 1623 | mock_get_interface = MagicMock(side_effect=[Mock(), Mock()]) |
|
| 1624 | self.napp.controller.get_interface_by_id = mock_get_interface |
|
| 1625 | event = KytosEvent( |
|
| 1626 | "topology.interruption.start", |
|
| 1627 | { |
|
| 1628 | 'type': 'test_interruption', |
|
| 1629 | 'switches': [ |
|
| 1630 | ], |
|
| 1631 | 'interfaces': [ |
|
| 1632 | 'intf_a', |
|
| 1633 | 'intf_b', |
|
| 1634 | ], |
|
| 1635 | 'links': [ |
|
| 1636 | 'link_a', |
|
| 1637 | 'link_c', |
|
| 1638 | ], |
|
| 1639 | } |
|
| 1640 | ) |
|
| 1641 | self.napp.handle_interruption_start(event) |
|
| 1642 | mock_notify_link_status_change.assert_has_calls( |
|
| 1643 | [ |
|
| 1644 | call(link_a, 'test_interruption'), |
|
| 1645 | call(link_c, 'test_interruption'), |
|
| 1646 | ] |
|
| 1647 | ) |
|
| 1648 | assert mock_notify_link_status_change.call_count == 2 |
|
| 1649 | mock_notify_topology_update.assert_called_once() |
|
| 1650 | assert mock_notify_interface_status.call_count == 2 |
|
| 1651 | ||
| 1652 | @patch('napps.kytos.topology.main.Main.notify_interface_status') |
|
| 1653 | @patch('napps.kytos.topology.main.Main.notify_topology_update') |
|