Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

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