Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

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