Code Duplication    Length = 64-64 lines in 2 locations

tests/unit/models/test_evc_deploy.py 2 locations

@@ 1627-1690 (lines=64) @@
1624
        result = EVCDeploy.check_list_traces([evc])
1625
        assert result[evc.id] is True
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_untagged_cases(self, bulk_sdntraces_mock, _):
1630
        """Test check_list_traces method."""
1631
        evc = self.create_evc_inter_switch("untagged", "untagged")
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": 0
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},
1656
                "time": "t3", "type":
1657
                "last",
1658
                "vlan": 6
1659
                },
1660
        ]
1661
        trace_z = [
1662
            {
1663
                "dpid": 3,
1664
                "port": 3,
1665
                "time": "t1",
1666
                "type": "starting",
1667
                "vlan": 0
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},
1680
                "time": "t3",
1681
                "type": "last",
1682
                "vlan": 5
1683
            },
1684
        ]
1685
1686
        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")
@@ 1562-1625 (lines=64) @@
1559
        result = EVCDeploy.check_list_traces([evc])
1560
        assert result[evc.id] is False
1561
1562
    @patch("napps.kytos.mef_eline.models.evc.log")
1563
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")
1564
    def test_check_list_traces_any_cases(self, run_bulk_sdntraces_mock, _):
1565
        """Test check_list_traces method."""
1566
        evc = self.create_evc_inter_switch("any", "any")
1567
1568
        for link in evc.primary_links:
1569
            link.metadata['s_vlan'] = MagicMock(value=link.metadata['s_vlan'])
1570
        evc.current_path = evc.primary_links
1571
1572
        trace_a = [
1573
            {
1574
                "dpid": 1,
1575
                "port": 2,
1576
                "time": "t1",
1577
                "type": "starting",
1578
                "vlan": 1
1579
            },
1580
            {
1581
                "dpid": 2,
1582
                "port": 10,
1583
                "time": "t2",
1584
                "type": "intermediary",
1585
                "vlan": 5
1586
            },
1587
            {
1588
                "dpid": 3,
1589
                "port": 12,
1590
                'out': {'port': 3, 'vlan': 1},
1591
                "time": "t3",
1592
                "type": "last",
1593
                "vlan": 6
1594
            },
1595
        ]
1596
        trace_z = [
1597
            {
1598
                "dpid": 3,
1599
                "port": 3,
1600
                "time": "t1",
1601
                "type": "starting",
1602
                "vlan": 1
1603
            },
1604
            {
1605
                "dpid": 2,
1606
                "port": 11,
1607
                "time": "t2",
1608
                "type": "intermediary",
1609
                "vlan": 6
1610
            },
1611
            {
1612
                "dpid": 1,
1613
                "port": 9,
1614
                'out': {'port': 2, 'vlan': 1},
1615
                "time": "t3",
1616
                "type": "last",
1617
                "vlan": 5
1618
            },
1619
        ]
1620
1621
        run_bulk_sdntraces_mock.return_value = {
1622
                                                "result": [trace_a, trace_z]
1623
                                            }
1624
        result = EVCDeploy.check_list_traces([evc])
1625
        assert result[evc.id] is True
1626
1627
    @patch("napps.kytos.mef_eline.models.evc.log")
1628
    @patch("napps.kytos.mef_eline.models.evc.EVCDeploy.run_bulk_sdntraces")