示例#1
0
    def test_event(self):
        """Testing Event: dump()"""
        event = Event("example", Severity.CRITICAL, "message",
                      nodename="test", timestamp=0)
        assert event.is_event()
        assert event.dump() == "E|0|test|example|2|message"

        event = Event("example", Severity.CRITICAL, "message", nodename="test")
        assert event.dump() == ("E|%d|test|example|2|message" %
                                (int(time.time()),))
示例#2
0
    def test_event(self):
        """Testing Event: dump()"""
        event = Event("example",
                      Severity.CRITICAL,
                      "message",
                      nodename="test",
                      timestamp=0)
        assert event.is_event()
        assert event.dump() == "E|0|test|example|2|message"

        event = Event("example", Severity.CRITICAL, "message", nodename="test")
        assert event.dump() == ("E|%d|test|example|2|message" %
                                (int(time.time()), ))
示例#3
0
 def test_event_malformed(self):
     """Testing Event: malformed event"""
     with self.assertRaises(ValueError):
         Event.from_dump("E|0")
示例#4
0
 def test_event_dump(self):
     """Testing Event: from_dump()"""
     event = Event.from_dump("E|0|test|example|2|message")
     assert event.dump() == "E|0|test|example|2|message" == repr(event)
示例#5
0
 def test_event_malformed(self):
     """Testing Event: malformed event"""
     with self.assertRaises(ValueError):
         Event.from_dump("E|0")
示例#6
0
 def test_event_dump(self):
     """Testing Event: from_dump()"""
     event = Event.from_dump("E|0|test|example|2|message")
     assert event.dump() == "E|0|test|example|2|message" == repr(event)