Exemplo n.º 1
0
 def test_create_from_json(self):
     now = time.gmtime()
     data = json.dumps({
         "@source": "test01.example.com",
         "@type": "sometype",
         "@tags": ["tag1", "tag2", "tag3"],
         "@fields": {
             "key1": "field1",
             "key2": "field2",
             "key3": "field3"
         },
         "@timestamp": time.strftime("%Y-%m-%dT%H:%M:%S", now),
         "@message": "This is the message"
     })
     event = Event(data)
     self.assertEqual(event.getsource(), 'test01.example.com')
     self.assertEqual(event.gettags(), ['tag1', 'tag2', 'tag3'])
     self.assertEqual(event.getfields(), {
         "key1": "field1",
         "key2": "field2",
         "key3": "field3"
     })
     self.assertFalse(event.is_cancelled())
     self.assertEqual(event.gettype(), "sometype")
     self.assertEqual(event.gettimestamp(),
                      time.strftime("%Y-%m-%dT%H:%M:%S", now))
     self.assertEqual(event.getmessage(), "This is the message")
Exemplo n.º 2
0
    def test_create_new_event(self):
        event = Event()

        self.assertEqual(event.getsource(), 'unknown')
        self.assertEqual(event.gettags(), [])
        self.assertEqual(event.getfields(), {})
        self.assertFalse(event.is_cancelled())
        self.assertEqual(event.gettype(), None)
Exemplo n.º 3
0
 def test_create_new_event(self):
     event = Event()
     
     self.assertEqual(event.getsource(), 'unknown')
     self.assertEqual(event.gettags(), [])
     self.assertEqual(event.getfields(), {})
     self.assertFalse(event.is_cancelled())
     self.assertEqual(event.gettype(), None)
Exemplo n.º 4
0
 def test_create_from_json(self):
     now = time.gmtime()
     data = json.dumps({ "@source": "test01.example.com",
              "@type" : "sometype",
              "@tags" : [ "tag1", "tag2", "tag3" ],
              "@fields" : { "key1" : "field1",
                            "key2" : "field2",
                            "key3" : "field3" 
                          },
              "@timestamp" : time.strftime("%Y-%m-%dT%H:%M:%S",now),
              "@message" : "This is the message"
             })
     event = Event(data)
     self.assertEqual(event.getsource(), 'test01.example.com')
     self.assertEqual(event.gettags(), ['tag1', 'tag2', 'tag3'])
     self.assertEqual(event.getfields(), { "key1" : "field1",
                                      "key2" : "field2",
                                      "key3" : "field3"
                                    })
     self.assertFalse(event.is_cancelled())
     self.assertEqual(event.gettype(), "sometype")
     self.assertEqual(event.gettimestamp(), time.strftime("%Y-%m-%dT%H:%M:%S",now))
     self.assertEqual(event.getmessage(), "This is the message")