def test_empty_output(self): self.maxDiff = None ospf = Ospf(device=self.device) # Set outputs ospf.maker.outputs[ShowIpProtocols] = {"{'vrf':''}": {}} ospf.maker.outputs[ShowIpOspf] = {'': {}} ospf.maker.outputs[ShowIpOspfInterface] = {"{'interface':''}": {}} ospf.maker.outputs[ShowIpOspfNeighborDetail] = {"{'neighbor':''}": {}} ospf.maker.outputs[ShowIpOspfShamLinks] = {'': {}} ospf.maker.outputs[ShowIpOspfVirtualLinks] = {'': {}} ospf.maker.outputs[ShowIpOspfDatabaseRouter] = {'': {}} ospf.maker.outputs[ShowIpOspfDatabaseExternal] = {'': {}} ospf.maker.outputs[ShowIpOspfDatabaseNetwork] = {'': {}} ospf.maker.outputs[ShowIpOspfDatabaseSummary] = {'': {}} ospf.maker.outputs[ShowIpOspfDatabaseOpaqueArea] = {'': {}} ospf.maker.outputs[ShowIpOspfMplsLdpInterface] = { "{'interface':''}": {} } ospf.maker.outputs[ShowIpOspfMplsTrafficEngLink] = {'': {}} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature ospf.learn() # Verify attribute is missing with self.assertRaises(AttributeError): ospf.info['vrf']
def test_selective_attribute(self): self.maxDiff = None ospf = Ospf(device=self.device) # Set outputs ospf.maker.outputs[ShowIpProtocols] = {'':OspfOutput.ShowIpProtocols} ospf.maker.outputs[ShowIpOspf] = {'':OspfOutput.ShowIpOspf} ospf.maker.outputs[ShowIpOspfInterface] = {'':OspfOutput.ShowIpOspfInterface} ospf.maker.outputs[ShowIpOspfNeighborDetail] = {'':OspfOutput.ShowIpOspfNeighborDetail} ospf.maker.outputs[ShowIpOspfShamLinks] = {'':OspfOutput.ShowIpOspfShamLinks} ospf.maker.outputs[ShowIpOspfVirtualLinks] = {'':OspfOutput.ShowIpOspfVirtualLinks} ospf.maker.outputs[ShowIpOspfDatabaseRouter] = {'':OspfOutput.ShowIpOspfDatabaseRouter} ospf.maker.outputs[ShowIpOspfDatabaseExternal] = {'':OspfOutput.ShowIpOspfDatabaseExternal} ospf.maker.outputs[ShowIpOspfDatabaseNetwork] = {'':OspfOutput.ShowIpOspfDatabaseNetwork} ospf.maker.outputs[ShowIpOspfDatabaseSummary] = {'':OspfOutput.ShowIpOspfDatabaseSummary} ospf.maker.outputs[ShowIpOspfDatabaseOpaqueArea] = {'':OspfOutput.ShowIpOspfDatabaseOpaqueArea} ospf.maker.outputs[ShowIpOspfMplsLdpInterface] = {'':OspfOutput.ShowIpOspfMplsLdpInterface} ospf.maker.outputs[ShowIpOspfMplsTrafficEngLink] = {'':OspfOutput.ShowIpOspfMplsTrafficEngLink} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature ospf.learn() # Check selective attribute self.assertEqual(288, ospf.info['vrf']['VRF1']['address_family']\ ['ipv4']['instance']['2']['areas']\ ['0.0.0.1']['database']['lsa_types'][1]\ ['lsas']['10.1.77.77 10.1.77.77']\ ['ospfv2']['header']['age'])
def test_missing_attributes(self): self.maxDiff = None ospf = Ospf(device=self.device) # Set outputs ospf.maker.outputs[ShowIpProtocols] = {'':{}} ospf.maker.outputs[ShowIpOspf] = {'':OspfOutput.ShowIpOspf} ospf.maker.outputs[ShowIpOspfInterface] = {'':OspfOutput.ShowIpOspfInterface} ospf.maker.outputs[ShowIpOspfNeighborDetail] = {'':OspfOutput.ShowIpOspfNeighborDetail} ospf.maker.outputs[ShowIpOspfShamLinks] = {'':OspfOutput.ShowIpOspfShamLinks} ospf.maker.outputs[ShowIpOspfVirtualLinks] = {'':OspfOutput.ShowIpOspfVirtualLinks} ospf.maker.outputs[ShowIpOspfDatabaseRouter] = {'':OspfOutput.ShowIpOspfDatabaseRouter} ospf.maker.outputs[ShowIpOspfDatabaseExternal] = {'':OspfOutput.ShowIpOspfDatabaseExternal} ospf.maker.outputs[ShowIpOspfDatabaseNetwork] = {'':OspfOutput.ShowIpOspfDatabaseNetwork} ospf.maker.outputs[ShowIpOspfDatabaseSummary] = {'':OspfOutput.ShowIpOspfDatabaseSummary} ospf.maker.outputs[ShowIpOspfDatabaseOpaqueArea] = {'':OspfOutput.ShowIpOspfDatabaseOpaqueArea} ospf.maker.outputs[ShowIpOspfMplsLdpInterface] = {'':OspfOutput.ShowIpOspfMplsLdpInterface} ospf.maker.outputs[ShowIpOspfMplsTrafficEngLink] = {'':OspfOutput.ShowIpOspfMplsTrafficEngLink} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature ospf.learn() # Verify key not created due to ouput missing with self.assertRaises(KeyError): single_value_preference = ospf.info['vrf']['default']\ ['address_family']['ipv4']['instance']\ ['1']['preference']['single_value']['all']
def test_complete_output(self): self.maxDiff = None ospf = Ospf(device=self.device) # Set outputs ospf.maker.outputs[ShowIpProtocols] = {'':OspfOutput.ShowIpProtocols} ospf.maker.outputs[ShowIpOspf] = {'':OspfOutput.ShowIpOspf} ospf.maker.outputs[ShowIpOspfInterface] = {'':OspfOutput.ShowIpOspfInterface} ospf.maker.outputs[ShowIpOspfNeighborDetail] = {'':OspfOutput.ShowIpOspfNeighborDetail} ospf.maker.outputs[ShowIpOspfShamLinks] = {'':OspfOutput.ShowIpOspfShamLinks} ospf.maker.outputs[ShowIpOspfVirtualLinks] = {'':OspfOutput.ShowIpOspfVirtualLinks} ospf.maker.outputs[ShowIpOspfDatabaseRouter] = {'':OspfOutput.ShowIpOspfDatabaseRouter} ospf.maker.outputs[ShowIpOspfDatabaseExternal] = {'':OspfOutput.ShowIpOspfDatabaseExternal} ospf.maker.outputs[ShowIpOspfDatabaseNetwork] = {'':OspfOutput.ShowIpOspfDatabaseNetwork} ospf.maker.outputs[ShowIpOspfDatabaseSummary] = {'':OspfOutput.ShowIpOspfDatabaseSummary} ospf.maker.outputs[ShowIpOspfDatabaseOpaqueArea] = {'':OspfOutput.ShowIpOspfDatabaseOpaqueArea} ospf.maker.outputs[ShowIpOspfMplsLdpInterface] = {'':OspfOutput.ShowIpOspfMplsLdpInterface} ospf.maker.outputs[ShowIpOspfMplsTrafficEngLink] = {'':OspfOutput.ShowIpOspfMplsTrafficEngLink} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature ospf.learn() # Verify Ops was created successfully self.assertEqual(ospf.info, OspfOutput.OspfInfo)
def test_custom_output(self): self.maxDiff = None ospf = Ospf(device=self.device) # Set outputs ospf.maker.outputs[ShowIpProtocols] = {"{'vrf':'default'}":OspfOutput.ShowIpProtocols} ospf.maker.outputs[ShowIpOspf] = {'':OspfOutput.ShowIpOspf} ospf.maker.outputs[ShowIpOspfInterface] = {"{'interface':'GigabitEthernet1'}":OspfOutput.ShowIpOspfInterface_custom} ospf.maker.outputs[ShowIpOspfNeighborDetail] = {"{'neighbor':'10.64.4.4'}":OspfOutput.ShowIpOspfNeighborDetail_custom} ospf.maker.outputs[ShowIpOspfShamLinks] = {'':OspfOutput.ShowIpOspfShamLinks} ospf.maker.outputs[ShowIpOspfVirtualLinks] = {'':OspfOutput.ShowIpOspfVirtualLinks} ospf.maker.outputs[ShowIpOspfDatabaseRouter] = {'':OspfOutput.ShowIpOspfDatabaseRouter} ospf.maker.outputs[ShowIpOspfDatabaseExternal] = {'':OspfOutput.ShowIpOspfDatabaseExternal} ospf.maker.outputs[ShowIpOspfDatabaseNetwork] = {'':OspfOutput.ShowIpOspfDatabaseNetwork} ospf.maker.outputs[ShowIpOspfDatabaseSummary] = {'':OspfOutput.ShowIpOspfDatabaseSummary} ospf.maker.outputs[ShowIpOspfDatabaseOpaqueArea] = {'':OspfOutput.ShowIpOspfDatabaseOpaqueArea} ospf.maker.outputs[ShowIpOspfMplsLdpInterface] = {"{'interface':'GigabitEthernet1'}":OspfOutput.ShowIpOspfMplsLdpInterface_custom} ospf.maker.outputs[ShowIpOspfMplsTrafficEngLink] = {'':OspfOutput.ShowIpOspfMplsTrafficEngLink} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature ospf.learn(vrf='default', interface='GigabitEthernet1', neighbor='10.64.4.4') # Verify Ops was created successfully self.assertEqual(ospf.info, OspfOutput.OspfInfo_custom)