def test_empty_output(self): self.maxDiff = None eigrp = Eigrp(device=self.device) # Set outputs eigrp.maker.outputs[ShowIpEigrpNeighborsDetail] = {'': {}} eigrp.maker.outputs[ShowIpv6EigrpNeighborsDetail] = {'': {}} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature eigrp.learn() # Verify attribute is missing with self.assertRaises(AttributeError): eigrp.info['eigrp_instance']
def test_complete_output(self): self.maxDiff = None eigrp = Eigrp(device=self.device) # Set outputs eigrp.maker.outputs[ShowIpEigrpNeighborsDetail] = { '': EigrpOutput.ShowIpEigrpNeighborsDetail } eigrp.maker.outputs[ShowIpv6EigrpNeighborsDetail] = { '': EigrpOutput.ShowIpv6EigrpNeighborsDetail } # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature eigrp.learn() # Verify Ops was created successfully self.assertEqual(eigrp.info, EigrpOutput.EigrpInfo)
def test_missing_attributes(self): self.maxDiff = None eigrp = Eigrp(device=self.device) # Set outputs eigrp.maker.outputs[ShowIpEigrpNeighborsDetail] = { '': EigrpOutput.ShowIpEigrpNeighborsDetail } eigrp.maker.outputs[ShowIpv6EigrpNeighborsDetail] = {'': {}} # Return outputs above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature eigrp.learn() # Veritfy key not created to do output missing with self.assertRaises(KeyError): single_value_preference = eigrp.info['eigrp_instance']['vrf']\ ['address_family']['eigrp_interface']\ ['eigrp_nbr']['nbr_sw_ver']
def test_selective_attribute(self): self.maxDiff = None eigrp = Eigrp(device=self.device) # Set outputs eigrp.maker.outputs[ShowIpEigrpNeighborsDetail] = { '': EigrpOutput.ShowIpEigrpNeighborsDetail } eigrp.maker.outputs[ShowIpv6EigrpNeighborsDetail] = { '': EigrpOutput.ShowIpv6EigrpNeighborsDetail } # Return outputd above as inputs to parser when called self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature eigrp.learn() self.assertEqual(5, eigrp.info['eigrp_instance']['100']['vrf']\ ['default']['address_family']['ipv4']\ ['eigrp_interface']['Ethernet1/0']\ ['eigrp_nbr']['10.1.2.1']\ ['nbr_sw_ver']['os_majorver'])