Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

@@ 1720-1783 (lines=64) @@
1717
        result = EVCDeploy.check_list_traces([evc])
1718
        assert result[evc.id] is True
1719
1720
    @patch("napps.kytos.mef_eline.models.evc.log")
1721
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
1722
    def test_check_list_traces_untagged_cases(self, bulk_sdntraces_mock, _):
1723
        """Test check_list_traces method."""
1724
        evc = self.create_evc_inter_switch("untagged", "untagged")
1725
1726
        for link in evc.primary_links:
1727
            link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan'])
1728
        evc.current_path = evc.primary_links
1729
1730
        trace_a = [
1731
            {
1732
                "dpid": 1,
1733
                "port": 2,
1734
                "time": "t1",
1735
                "type": "starting",
1736
                "vlan": 0
1737
            },
1738
            {
1739
                "dpid": 2,
1740
                "port": 10,
1741
                "time": "t2",
1742
                "type": "intermediary",
1743
                "vlan": 5
1744
            },
1745
            {
1746
                "dpid": 3,
1747
                "port": 12,
1748
                'out': {'port': 3},
1749
                "time": "t3", "type":
1750
                "last",
1751
                "vlan": 6
1752
                },
1753
        ]
1754
        trace_z = [
1755
            {
1756
                "dpid": 3,
1757
                "port": 3,
1758
                "time": "t1",
1759
                "type": "starting",
1760
                "vlan": 0
1761
            },
1762
            {
1763
                "dpid": 2,
1764
                "port": 11,
1765
                "time": "t2",
1766
                "type": "intermediary",
1767
                "vlan": 6
1768
            },
1769
            {
1770
                "dpid": 1,
1771
                "port": 9,
1772
                'out': {'port': 2},
1773
                "time": "t3",
1774
                "type": "last",
1775
                "vlan": 5
1776
            },
1777
        ]
1778
1779
        bulk_sdntraces_mock.return_value = {
1780
                                                "result": [trace_a, trace_z]
1781
                                            }
1782
        result = EVCDeploy.check_list_traces([evc])
1783
        assert result[evc.id] is True
1784
1785
    @patch("napps.kytos.mef_eline.models.evc.log")
1786
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
@@ 1655-1718 (lines=64) @@
1652
        result = EVCDeploy.check_list_traces([evc])
1653
        assert result[evc.id] is False
1654
1655
    @patch("napps.kytos.mef_eline.models.evc.log")
1656
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
1657
    def test_check_list_traces_any_cases(self, run_bulk_sdntraces_mock, _):
1658
        """Test check_list_traces method."""
1659
        evc = self.create_evc_inter_switch("any", "any")
1660
1661
        for link in evc.primary_links:
1662
            link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan'])
1663
        evc.current_path = evc.primary_links
1664
1665
        trace_a = [
1666
            {
1667
                "dpid": 1,
1668
                "port": 2,
1669
                "time": "t1",
1670
                "type": "starting",
1671
                "vlan": 1
1672
            },
1673
            {
1674
                "dpid": 2,
1675
                "port": 10,
1676
                "time": "t2",
1677
                "type": "intermediary",
1678
                "vlan": 5
1679
            },
1680
            {
1681
                "dpid": 3,
1682
                "port": 12,
1683
                'out': {'port': 3, 'vlan': 1},
1684
                "time": "t3",
1685
                "type": "last",
1686
                "vlan": 6
1687
            },
1688
        ]
1689
        trace_z = [
1690
            {
1691
                "dpid": 3,
1692
                "port": 3,
1693
                "time": "t1",
1694
                "type": "starting",
1695
                "vlan": 1
1696
            },
1697
            {
1698
                "dpid": 2,
1699
                "port": 11,
1700
                "time": "t2",
1701
                "type": "intermediary",
1702
                "vlan": 6
1703
            },
1704
            {
1705
                "dpid": 1,
1706
                "port": 9,
1707
                'out': {'port': 2, 'vlan': 1},
1708
                "time": "t3",
1709
                "type": "last",
1710
                "vlan": 5
1711
            },
1712
        ]
1713
1714
        run_bulk_sdntraces_mock.return_value = {
1715
                                                "result": [trace_a, trace_z]
1716
                                            }
1717
        result = EVCDeploy.check_list_traces([evc])
1718
        assert result[evc.id] is True
1719
1720
    @patch("napps.kytos.mef_eline.models.evc.log")
1721
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")