Esempio n. 1
0
    def test_get_call_args_issue_22(self):
        data = readbytes('dummy.hex')  # any dump would do
        packet = Sequence(Integer(Version.V2C), OctetString('public'),
                          BulkGetRequest(0, 0, 2, ObjectIdentifier(1, 2, 3)))
        with patch('puresnmp.api.raw.Transport') as mck:
            mck().send.return_value = data
            mck().get_request_id.return_value = 0

            with six.assertRaisesRegex(self, TypeError, 'OIDS.*list'):
                # we need to wrap this in a list to consume the generator.
                list(bulkwalk('::1', 'public', '1.2.3', bulk_size=2))
Esempio n. 2
0
    def test_get_call_args(self):
        data = readbytes('dummy.hex')  # any dump would do
        packet = Sequence(Integer(Version.V2C), OctetString('public'),
                          BulkGetRequest(0, 0, 2, ObjectIdentifier(1, 2, 3)))
        with patch('puresnmp.api.raw.send') as mck, \
                patch('puresnmp.api.raw.get_request_id') as mck2:
            mck2.return_value = 0
            mck.return_value = data

            # we need to wrap this in a list to consume the generator.
            list(bulkwalk('::1', 'public', ['1.2.3'], bulk_size=2))
            mck.assert_called_with('::1', 161, to_bytes(packet), timeout=2)
Esempio n. 3
0
 def test_get_call_args(self):
     data = readbytes('dummy.hex')  # any dump would do
     packet = Sequence(
         Integer(Version.V2C), OctetString('public'),
         BulkGetRequest(0, 1, 2, ObjectIdentifier(1, 2, 3),
                        ObjectIdentifier(1, 2, 4)))
     with patch('puresnmp.api.raw.send') as mck, \
             patch('puresnmp.api.raw.get_request_id') as mck2:
         mck2.return_value = 0
         mck.return_value = data
         bulkget('::1', 'public', ['1.2.3'], ['1.2.4'], max_list_size=2)
         mck.assert_called_with('::1', 161, to_bytes(packet), timeout=2)
Esempio n. 4
0
    async def test_get_call_args_issue_22(self):
        data = readbytes('dummy.hex')  # any dump would do
        packet = Sequence(Integer(Version.V2C), OctetString('public'),
                          BulkGetRequest(0, 0, 2, ObjectIdentifier(1, 2, 3)))
        with patch('puresnmp.aio.api.raw.send', new_callable=AsyncMock) as mck, \
                patch('puresnmp.aio.api.raw.get_request_id') as mck2:
            mck2.return_value = 0
            mck.return_value = data

            with pytest.raises(TypeError, match=r'OIDS.*list'):
                # we need to wrap this in a list to consume the generator.
                async for x in bulkwalk('::1', 'public', '1.2.3', bulk_size=2):
                    pass
Esempio n. 5
0
    async def test_get_call_args(self):
        data = readbytes('dummy.hex')  # any dump would do
        packet = Sequence(Integer(Version.V2C), OctetString('public'),
                          BulkGetRequest(0, 0, 2, ObjectIdentifier(1, 2, 3)))
        with patch('puresnmp.aio.api.raw.Transport') as mck:
            mck().send = AsyncMock()
            mck().get_request_id.return_value = 0
            mck().send.return_value = data

            # we need to wrap this in a list to consume the generator.
            async for x in bulkwalk('::1', 'public', ['1.2.3'], bulk_size=2):
                pass
            mck.assert_called_with(timeout=6)
            mck().send.assert_called_with('::1', 161, to_bytes(packet))