예제 #1
0
 def test_get_multiple_return_binds(self):
     """
     A "GET" response should only return one varbind.
     """
     data = readbytes('get_sysoid_01_error.hex')
     with patch('puresnmp.api.raw.send') as mck:
         mck.return_value = data
         with six.assertRaisesRegex(self, SnmpError, 'varbind'):
             get('::1', 'private', '1.2.3')
예제 #2
0
 def test_get_non_existing_oid(self):
     """
     A "GET" response on a non-existing OID should raise an appropriate
     exception.
     """
     data = readbytes('get_non_existing.hex')
     with patch('puresnmp.api.raw.send') as mck:
         mck.return_value = data
         with self.assertRaises(NoSuchOID):
             get('::1', 'private', '1.2.3')
예제 #3
0
 def test_get_oid(self):
     data = readbytes('get_sysoid_01.hex')
     expected = ObjectIdentifier.from_string('1.3.6.1.4.1.8072.3.2.10')
     with patch('puresnmp.api.raw.send') as mck:
         mck.return_value = data
         result = get('::1', 'private', '1.2.3')
     self.assertEqual(result, expected)
예제 #4
0
 def test_get_string(self):
     data = readbytes('get_sysdescr_01.hex')
     expected = OctetString(
         b'Linux d24cf7f36138 4.4.0-28-generic #47-Ubuntu SMP '
         b'Fri Jun 24 10:09:13 UTC 2016 x86_64')
     with patch('puresnmp.api.raw.send') as mck:
         mck.return_value = data
         result = get('::1', 'private', '1.2.3')
     self.assertEqual(result, expected)