diff --git a/vlanmang.py b/vlanmang.py index 23a5626..9d37474 100644 --- a/vlanmang.py +++ b/vlanmang.py @@ -555,6 +555,32 @@ class _TestSNMPSwitch(unittest.TestCase): # and call _getmany w/ the correct arg gm.assert_called_with(arg) + @mock.patch('pysnmp.hlapi.ContextData') + @mock.patch('vlanmang.getCmd') + def test_getmany(self, gc, cd): + # that a switch + switch = SNMPSwitch(None, None) + + # when getCmd returns tooBig when too many oids are asked for + def custgetcmd(eng, cd, targ, contextdata, *oids): + # induce a too big error + if len(oids) > 3: + res = ( None, 'tooBig', None, None ) + else: + #import pdb; pdb.set_trace() + [ oid.resolveWithMib(_mvc) for oid in oids ] + res = ( None, None, None, oids ) + + return iter([res]) + + gc.side_effect = custgetcmd + + #import pdb; pdb.set_trace() + res = switch.getegress(*xrange(1, 10)) + + # will still return the complete set of results + self.assertEqual(res, { x: '' for x in xrange(1, 10) }) + _skipSwitchTests = True class _TestSwitch(unittest.TestCase):