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')
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)
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)
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
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
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'])
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)
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)