Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

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