def test_selective_attribute(self): self.maxDiff = None hsrp = Hsrp(device=self.device) # Get 'show standby all' output hsrp.maker.outputs[ShowStandbyAll] = { "": HsrpOutput.showStandbyAllOutput } # Get 'show standby internal' output hsrp.maker.outputs[ShowStandbyInternal] = { "": HsrpOutput.showStandbyInternalOutput } # Get 'show standby delay' output hsrp.maker.outputs[ShowStandbyDelay] = { "": HsrpOutput.showStandbyDelayOutput } # Get 'show standby delay' output hsrp.maker.outputs[ShowStandbyDelay] = { "": HsrpOutput.showStandbyDelayOutput } self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature hsrp.learn() self.assertEqual( 99, hsrp.info["GigabitEthernet1"]["delay"]["minimum_delay"])
def test_full(self): self.maxDiff = None hsrp = Hsrp(device=self.device) # Get 'show standby all' output hsrp.maker.outputs[ShowStandbyAll] = {"": HsrpOutput.showStandbyAllOutput} # Get 'show standby internal' output hsrp.maker.outputs[ShowStandbyInternal] = { "": HsrpOutput.showStandbyInternalOutput } # Get 'show standby delay' output hsrp.maker.outputs[ShowStandbyDelay] = {"": HsrpOutput.showStandbyDelayOutput} self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature hsrp.learn() self.assertEqual(hsrp.info, HsrpOutput.hsrpOpsOutput)
def test_missing_attributes(self): self.maxDiff = None hsrp = Hsrp(device=self.device) # Get 'show standby all' output hsrp.maker.outputs[ShowStandbyAll] = {"": HsrpOutput.showStandbyAllOutput} # Get 'show standby internal' output hsrp.maker.outputs[ShowStandbyInternal] = { "": HsrpOutput.showStandbyInternalOutput } # Get 'show standby delay' output hsrp.maker.outputs[ShowStandbyDelay] = {"": HsrpOutput.showStandbyDelayOutput} self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature hsrp.learn() with self.assertRaises(KeyError): hsrp_bfd_sessions_total = hsrp.info["num_bfd_sessions"]
def test_incomplete_output(self): self.maxDiff = None hsrp = Hsrp(device=self.device) # Get 'show standby all' output hsrp.maker.outputs[ShowStandbyAll] = {"": ""} # Get 'show standby internal' output hsrp.maker.outputs[ShowStandbyInternal] = { "": HsrpOutput.showStandbyInternalOutput } # Get 'show standby delay' output hsrp.maker.outputs[ShowStandbyDelay] = {"": HsrpOutput.showStandbyDelayOutput} self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature hsrp.learn() with self.assertRaises(KeyError): hsrp_groups = hsrp.info["groups"]