Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

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