コード例 #1
0
    def test_selective_attribute(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = \
            {'':InterfaceOutput.ShowInterfacesDetail}

        intf.maker.outputs[ShowEthernetTags] = \
            {'':InterfaceOutput.ShowEthernetTags}

        intf.maker.outputs[ShowIpv4VrfAllInterface] = \
            {'':InterfaceOutput.ShowIpv4VrfAllInterface}

        intf.maker.outputs[ShowIpv6VrfAllInterface] = \
            {'':InterfaceOutput.ShowIpv6VrfAllInterface}

        intf.maker.outputs[ShowVrfAllDetail] = \
            {'':InterfaceOutput.ShowVrfAllDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccounting}

        # Learn the feature
        intf.learn()

        # Check specific attribute values
        # info - type
        self.assertEqual(intf.info['MgmtEth0/0/CPU0/0']['type'],
                         'Management Ethernet')
コード例 #2
0
    def test_incomplete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = \
            {'':InterfaceOutput.ShowInterfacesDetail}

        intf.maker.outputs[ShowEthernetTags] = \
            {'':InterfaceOutput.ShowEthernetTags}

        intf.maker.outputs[ShowIpv4VrfAllInterface] = {'': ''}

        intf.maker.outputs[ShowIpv6VrfAllInterface] = \
            {'':InterfaceOutput.ShowIpv6VrfAllInterface}

        intf.maker.outputs[ShowVrfAllDetail] = \
            {'':InterfaceOutput.ShowVrfAllDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccounting}

        # Learn the feature
        intf.learn()

        # Delete missing specific attribute values
        expect_dict = deepcopy(InterfaceOutput.InterfaceOpsOutput_info)
        del (expect_dict['GigabitEthernet0/0/0/0']['ipv4'])

        # Verify Ops was created successfully
        self.assertEqual(intf.info, expect_dict)
コード例 #3
0
    def test_complete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = \
            {'':InterfaceOutput.ShowInterfacesDetail}

        intf.maker.outputs[ShowEthernetTags] = \
            {'':InterfaceOutput.ShowEthernetTags}

        intf.maker.outputs[ShowIpv4VrfAllInterface] = \
            {'':InterfaceOutput.ShowIpv4VrfAllInterface}

        intf.maker.outputs[ShowIpv6VrfAllInterface] = \
            {'':InterfaceOutput.ShowIpv6VrfAllInterface}

        intf.maker.outputs[ShowVrfAllDetail] = \
            {'':InterfaceOutput.ShowVrfAllDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccounting}

        # Learn the feature
        intf.learn()

        # Verify Ops was created successfully
        self.assertEqual(intf.info, InterfaceOutput.InterfaceOpsOutput_info)
コード例 #4
0
    def test_empty_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = {"{'interface':''}": ''}
        intf.maker.outputs[ShowIpv4VrfAllInterface] = {
            "{'vrf':None,'interface':''}": ''
        }
        intf.maker.outputs[ShowIpv6VrfAllInterface] = {
            "{'vrf':None,'interface':''}": ''
        }
        intf.maker.outputs[ShowVrfAllDetail] = {"{'vrf':''}": ''}
        intf.maker.outputs[ShowEthernetTags] = {"{'interface':''}": ''}
        intf.maker.outputs[ShowInterfacesAccounting] = {"{'interface':''}": ''}
        outputs['show ipv4 vrf all interface'] = ''
        outputs['show ipv6 vrf all interface'] = ''
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn()

        # Check no attribute not found
        # info - vrf
        with self.assertRaises(AttributeError):
            vrf = (intf.info['MgmtEth0/0/CPU0/0']['type'])

        outputs[
            'show ipv4 vrf all interface'] = InterfaceOutput.ShowIpv4VrfAllInterface_all
        outputs[
            'show ipv6 vrf all interface'] = InterfaceOutput.ShowIpv6VrfAllInterface_all
コード例 #5
0
    def test_incomplete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = \
            {"{'interface':''}": InterfaceOutput.ShowInterfacesDetail}

        intf.maker.outputs[ShowEthernetTags] = \
            {"{'interface':''}": InterfaceOutput.ShowEthernetTags}

        intf.maker.outputs[ShowVrfAllDetail] = \
            {"{'vrf':''}": InterfaceOutput.ShowVrfAllDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {"{'interface':''}": InterfaceOutput.ShowInterfacesAccounting}
        outputs['show ipv4 vrf all interface'] = ''
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn()

        # Delete missing specific attribute values
        expect_dict = deepcopy(InterfaceOutput.InterfaceOpsOutput_info)
        del (expect_dict['GigabitEthernet0/0/0/0']['ipv4'])
        del (expect_dict['GigabitEthernet0/0/0/1']['ipv4'])
        # Verify Ops was created successfully
        self.assertEqual(intf.info, expect_dict)
        outputs[
            'show ipv4 vrf all interface'] = InterfaceOutput.ShowIpv4VrfAllInterface_all
コード例 #6
0
    def test_empty_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = {'': ''}
        intf.maker.outputs[ShowIpv4VrfAllInterface] = {'': ''}
        intf.maker.outputs[ShowIpv6VrfAllInterface] = {'': ''}
        intf.maker.outputs[ShowVrfAllDetail] = {'': ''}
        intf.maker.outputs[ShowEthernetTags] = {'': ''}

        # Learn the feature
        intf.learn()

        # Check no attribute not found
        # info - vrf
        with self.assertRaises(AttributeError):
            vrf = (intf.info['MgmtEth0/0/CPU0/0']['type'])
コード例 #7
0
    def test_complete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfacesDetail] = \
            {"{'interface':''}": InterfaceOutput.ShowInterfacesDetail}

        intf.maker.outputs[ShowEthernetTags] = \
            {"{'interface':''}": InterfaceOutput.ShowEthernetTags}

        intf.maker.outputs[ShowVrfAllDetail] = \
            {"{'vrf':''}": InterfaceOutput.ShowVrfAllDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {"{'interface':''}": InterfaceOutput.ShowInterfacesAccounting}
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn()

        # Verify Ops was created successfully
        self.assertDictEqual(intf.info,
                             InterfaceOutput.InterfaceOpsOutput_info)
コード例 #8
0
    def test_custom_output(self):
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowIpv4VrfAllInterface] = \
            {"{'vrf':''}": InterfaceOutput.ShowIpv4VrfAllInterface}

        intf.maker.outputs[ShowIpv6VrfAllInterface] = \
            {"{'vrf':''}": InterfaceOutput.ShowIpv6VrfAllInterface}

        intf.maker.outputs[ShowVrfAllDetail] = \
            {"{'vrf':''}": InterfaceOutput.ShowVrfAllDetail}

        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn(interface='GigabitEthernet0/0/0/1',
                   address_family='ipv6',
                   vrf='VRF1')

        self.maxDiff = None
        # Verify Ops was created successfully
        self.assertDictEqual(intf.info,
                             InterfaceOutput.interfaceOpsOutput_custom_info)