Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

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