| @@ 1790-1853 (lines=64) @@ | ||
| 1787 | result = EVCDeploy.check_list_traces([evc]) |
|
| 1788 | assert result[evc.id] is True |
|
| 1789 | ||
| 1790 | @patch("napps.kytos.mef_eline.models.evc.log") |
|
| 1791 | @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces") |
|
| 1792 | def test_check_list_traces_untagged_cases(self, bulk_sdntraces_mock, _): |
|
| 1793 | """Test check_list_traces method.""" |
|
| 1794 | evc = self.create_evc_inter_switch("untagged", "untagged") |
|
| 1795 | ||
| 1796 | for link in evc.primary_links: |
|
| 1797 | link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan']) |
|
| 1798 | evc.current_path = evc.primary_links |
|
| 1799 | ||
| 1800 | trace_a = [ |
|
| 1801 | { |
|
| 1802 | "dpid": 1, |
|
| 1803 | "port": 2, |
|
| 1804 | "time": "t1", |
|
| 1805 | "type": "starting", |
|
| 1806 | "vlan": 0 |
|
| 1807 | }, |
|
| 1808 | { |
|
| 1809 | "dpid": 2, |
|
| 1810 | "port": 10, |
|
| 1811 | "time": "t2", |
|
| 1812 | "type": "intermediary", |
|
| 1813 | "vlan": 5 |
|
| 1814 | }, |
|
| 1815 | { |
|
| 1816 | "dpid": 3, |
|
| 1817 | "port": 12, |
|
| 1818 | 'out': {'port': 3}, |
|
| 1819 | "time": "t3", "type": |
|
| 1820 | "last", |
|
| 1821 | "vlan": 6 |
|
| 1822 | }, |
|
| 1823 | ] |
|
| 1824 | trace_z = [ |
|
| 1825 | { |
|
| 1826 | "dpid": 3, |
|
| 1827 | "port": 3, |
|
| 1828 | "time": "t1", |
|
| 1829 | "type": "starting", |
|
| 1830 | "vlan": 0 |
|
| 1831 | }, |
|
| 1832 | { |
|
| 1833 | "dpid": 2, |
|
| 1834 | "port": 11, |
|
| 1835 | "time": "t2", |
|
| 1836 | "type": "intermediary", |
|
| 1837 | "vlan": 6 |
|
| 1838 | }, |
|
| 1839 | { |
|
| 1840 | "dpid": 1, |
|
| 1841 | "port": 9, |
|
| 1842 | 'out': {'port': 2}, |
|
| 1843 | "time": "t3", |
|
| 1844 | "type": "last", |
|
| 1845 | "vlan": 5 |
|
| 1846 | }, |
|
| 1847 | ] |
|
| 1848 | ||
| 1849 | bulk_sdntraces_mock.return_value = { |
|
| 1850 | "result": [trace_a, trace_z] |
|
| 1851 | } |
|
| 1852 | result = EVCDeploy.check_list_traces([evc]) |
|
| 1853 | assert result[evc.id] is True |
|
| 1854 | ||
| 1855 | @patch("napps.kytos.mef_eline.models.evc.log") |
|
| 1856 | @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces") |
|
| @@ 1725-1788 (lines=64) @@ | ||
| 1722 | result = EVCDeploy.check_list_traces([evc]) |
|
| 1723 | assert result[evc.id] is False |
|
| 1724 | ||
| 1725 | @patch("napps.kytos.mef_eline.models.evc.log") |
|
| 1726 | @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces") |
|
| 1727 | def test_check_list_traces_any_cases(self, run_bulk_sdntraces_mock, _): |
|
| 1728 | """Test check_list_traces method.""" |
|
| 1729 | evc = self.create_evc_inter_switch("any", "any") |
|
| 1730 | ||
| 1731 | for link in evc.primary_links: |
|
| 1732 | link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan']) |
|
| 1733 | evc.current_path = evc.primary_links |
|
| 1734 | ||
| 1735 | trace_a = [ |
|
| 1736 | { |
|
| 1737 | "dpid": 1, |
|
| 1738 | "port": 2, |
|
| 1739 | "time": "t1", |
|
| 1740 | "type": "starting", |
|
| 1741 | "vlan": 1 |
|
| 1742 | }, |
|
| 1743 | { |
|
| 1744 | "dpid": 2, |
|
| 1745 | "port": 10, |
|
| 1746 | "time": "t2", |
|
| 1747 | "type": "intermediary", |
|
| 1748 | "vlan": 5 |
|
| 1749 | }, |
|
| 1750 | { |
|
| 1751 | "dpid": 3, |
|
| 1752 | "port": 12, |
|
| 1753 | 'out': {'port': 3, 'vlan': 1}, |
|
| 1754 | "time": "t3", |
|
| 1755 | "type": "last", |
|
| 1756 | "vlan": 6 |
|
| 1757 | }, |
|
| 1758 | ] |
|
| 1759 | trace_z = [ |
|
| 1760 | { |
|
| 1761 | "dpid": 3, |
|
| 1762 | "port": 3, |
|
| 1763 | "time": "t1", |
|
| 1764 | "type": "starting", |
|
| 1765 | "vlan": 1 |
|
| 1766 | }, |
|
| 1767 | { |
|
| 1768 | "dpid": 2, |
|
| 1769 | "port": 11, |
|
| 1770 | "time": "t2", |
|
| 1771 | "type": "intermediary", |
|
| 1772 | "vlan": 6 |
|
| 1773 | }, |
|
| 1774 | { |
|
| 1775 | "dpid": 1, |
|
| 1776 | "port": 9, |
|
| 1777 | 'out': {'port': 2, 'vlan': 1}, |
|
| 1778 | "time": "t3", |
|
| 1779 | "type": "last", |
|
| 1780 | "vlan": 5 |
|
| 1781 | }, |
|
| 1782 | ] |
|
| 1783 | ||
| 1784 | run_bulk_sdntraces_mock.return_value = { |
|
| 1785 | "result": [trace_a, trace_z] |
|
| 1786 | } |
|
| 1787 | result = EVCDeploy.check_list_traces([evc]) |
|
| 1788 | assert result[evc.id] is True |
|
| 1789 | ||
| 1790 | @patch("napps.kytos.mef_eline.models.evc.log") |
|
| 1791 | @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces") |
|