Beispiel #1
0
 def test_create_request_failed(self):
     message = [
         '{"clock": "1457445366", "host: \
         "host1", "value": "1", "key": "key1"}',
         '{"clock": "1457445366", "host": \
         "host2", "value": "2", "key": "key2"}']
     zs = ZabbixSender()
     result = zs._create_request(message)
     with self.assertRaises(Exception):
         result = json.loads(result.decode())
Beispiel #2
0
 def test_create_request_failed(self):
     message = [
         '{"clock": "1457445366", "host: \
         "host1", "value": "1", "key": "key1"}',
         '{"clock": "1457445366", "host": \
         "host2", "value": "2", "key": "key2"}']
     zs = ZabbixSender()
     result = zs._create_request(message)
     with self.assertRaises(Exception):
         result = json.loads(result.decode())
Beispiel #3
0
 def test_create_request(self):
     message = [
         '{"clock": "1457445366", "host": "host1",\
         "value": "1", "key": "key1"}',
         '{"clock": "1457445366", "host": "host2",\
         "value": "2", "key": "key2"}']
     zs = ZabbixSender()
     result = zs._create_request(message)
     self.assertIsInstance(result, bytes)
     result = json.loads(result.decode())
     self.assertEqual(result['request'], 'sender data')
     self.assertEqual(len(result['data']), 2)
Beispiel #4
0
 def test_create_request(self):
     message = [
         '{"clock": "1457445366", "host": "host1",\
         "value": "1", "key": "key1"}',
         '{"clock": "1457445366", "host": "host2",\
         "value": "2", "key": "key2"}']
     zs = ZabbixSender()
     result = zs._create_request(message)
     self.assertIsInstance(result, bytes)
     result = json.loads(result.decode())
     self.assertEqual(result['request'], 'sender data')
     self.assertEqual(len(result['data']), 2)
Beispiel #5
0
 def test_create_packet(self):
     message = [
         '{"clock": "1457445366", "host": "host1",\
         "value": "1", "key": "key1"}',
         '{"clock": "1457445366", "host": "host2",\
         "value": "2", "key": "key2"}']
     zs = ZabbixSender()
     request = zs._create_request(message)
     result = zs._create_packet(request)
     data_len = struct.pack('<Q', len(request))
     self.assertEqual(result[5:13], data_len)
     self.assertEqual(result[:13],
                      b'ZBXD\x01\xc4\x00\x00\x00\x00\x00\x00\x00')
Beispiel #6
0
 def test_create_packet(self):
     message = [
         '{"clock": "1457445366", "host": "host1",\
         "value": "1", "key": "key1"}',
         '{"clock": "1457445366", "host": "host2",\
         "value": "2", "key": "key2"}']
     zs = ZabbixSender()
     request = zs._create_request(message)
     result = zs._create_packet(request)
     data_len = struct.pack('<Q', len(request))
     self.assertEqual(result[5:13], data_len)
     self.assertEqual(result[:13],
                      b'ZBXD\x01\xc4\x00\x00\x00\x00\x00\x00\x00')