Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

@@ 1626-1689 (lines=64) @@
1623
        result = EVCDeploy.check_list_traces([evc])
1624
        assert result[evc.id] is True
1625
1626
    @patch("napps.kytos.mef_eline.models.evc.log")
1627
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
1628
    def test_check_list_traces_untagged_cases(self, bulk_sdntraces_mock, _):
1629
        """Test check_list_traces method."""
1630
        evc = self.create_evc_inter_switch("untagged", "untagged")
1631
1632
        for link in evc.primary_links:
1633
            link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan'])
1634
        evc.current_path = evc.primary_links
1635
1636
        trace_a = [
1637
            {
1638
                "dpid": 1,
1639
                "port": 2,
1640
                "time": "t1",
1641
                "type": "starting",
1642
                "vlan": 0
1643
            },
1644
            {
1645
                "dpid": 2,
1646
                "port": 10,
1647
                "time": "t2",
1648
                "type": "intermediary",
1649
                "vlan": 5
1650
            },
1651
            {
1652
                "dpid": 3,
1653
                "port": 12,
1654
                'out': {'port': 3},
1655
                "time": "t3", "type":
1656
                "last",
1657
                "vlan": 6
1658
                },
1659
        ]
1660
        trace_z = [
1661
            {
1662
                "dpid": 3,
1663
                "port": 3,
1664
                "time": "t1",
1665
                "type": "starting",
1666
                "vlan": 0
1667
            },
1668
            {
1669
                "dpid": 2,
1670
                "port": 11,
1671
                "time": "t2",
1672
                "type": "intermediary",
1673
                "vlan": 6
1674
            },
1675
            {
1676
                "dpid": 1,
1677
                "port": 9,
1678
                'out': {'port': 2},
1679
                "time": "t3",
1680
                "type": "last",
1681
                "vlan": 5
1682
            },
1683
        ]
1684
1685
        bulk_sdntraces_mock.return_value = {
1686
                                                "result": [trace_a, trace_z]
1687
                                            }
1688
        result = EVCDeploy.check_list_traces([evc])
1689
        assert result[evc.id] is True
1690
1691
    @patch("napps.kytos.mef_eline.models.evc.log")
1692
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
@@ 1561-1624 (lines=64) @@
1558
        result = EVCDeploy.check_list_traces([evc])
1559
        assert result[evc.id] is False
1560
1561
    @patch("napps.kytos.mef_eline.models.evc.log")
1562
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
1563
    def test_check_list_traces_any_cases(self, run_bulk_sdntraces_mock, _):
1564
        """Test check_list_traces method."""
1565
        evc = self.create_evc_inter_switch("any", "any")
1566
1567
        for link in evc.primary_links:
1568
            link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan'])
1569
        evc.current_path = evc.primary_links
1570
1571
        trace_a = [
1572
            {
1573
                "dpid": 1,
1574
                "port": 2,
1575
                "time": "t1",
1576
                "type": "starting",
1577
                "vlan": 1
1578
            },
1579
            {
1580
                "dpid": 2,
1581
                "port": 10,
1582
                "time": "t2",
1583
                "type": "intermediary",
1584
                "vlan": 5
1585
            },
1586
            {
1587
                "dpid": 3,
1588
                "port": 12,
1589
                'out': {'port': 3, 'vlan': 1},
1590
                "time": "t3",
1591
                "type": "last",
1592
                "vlan": 6
1593
            },
1594
        ]
1595
        trace_z = [
1596
            {
1597
                "dpid": 3,
1598
                "port": 3,
1599
                "time": "t1",
1600
                "type": "starting",
1601
                "vlan": 1
1602
            },
1603
            {
1604
                "dpid": 2,
1605
                "port": 11,
1606
                "time": "t2",
1607
                "type": "intermediary",
1608
                "vlan": 6
1609
            },
1610
            {
1611
                "dpid": 1,
1612
                "port": 9,
1613
                'out': {'port': 2, 'vlan': 1},
1614
                "time": "t3",
1615
                "type": "last",
1616
                "vlan": 5
1617
            },
1618
        ]
1619
1620
        run_bulk_sdntraces_mock.return_value = {
1621
                                                "result": [trace_a, trace_z]
1622
                                            }
1623
        result = EVCDeploy.check_list_traces([evc])
1624
        assert result[evc.id] is True
1625
1626
    @patch("napps.kytos.mef_eline.models.evc.log")
1627
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")