Browse Source

add test case for when the server returns tooBig.. make sure we

subdivide the query into smaller chunks..   perfect example of how
the pysnmp hlapi isn't that high level...
ssh-lenovo
John-Mark Gurney 5 years ago
parent
commit
2cda272a04
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      vlanmang.py

+ 26
- 0
vlanmang.py View File

@@ -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):


Loading…
Cancel
Save