예제 #1
0
def test_to_json_down(down):
    assert json.loads(proxy.event_to_json(Event.create_event(down))) == {
        "u_business_service": E2EMONITORING_SERVICE,
        "u_priority": E2EMONITORING_DOWN,
        "u_short_description": "unittest is Down",
        "u_description": "unittest is Down: for testing purpose.",
    }
예제 #2
0
 def create(self, event):
     if not isinstance(event, Event):
         event = Event.create_event(event)
     db_event = DBEvent.from_event(event)
     self.db.session.add(db_event)
     self.db.session.commit()
     return db_event
예제 #3
0
def test_to_json_up(up):
    assert json.loads(proxy.event_to_json(Event.create_event(up))) == {
        "u_business_service":
        E2EMONITORING_SERVICE,
        "u_priority":
        E2EMONITORING_UP,
        "u_short_description":
        "unittest is Up",
        "u_description":
        "unittest is Up (for testing purpose). It was down for 0:01:39.",
    }
예제 #4
0
def test_store_select(up):
    assert list(storage.select()) == []
    event = Event.create_event(up)
    storage.create(event)
    assert list(storage.select()) == [event]
    storage.flush(0)
예제 #5
0
def test_store_create(up, down):
    storage.create(Event.create_event(down))
    storage.create(up)
    assert repr(storage) == '<Store with 2 events>'
    assert len(storage) == 2
예제 #6
0
def test_create_down(down):
    event = Event.create_event(down)
    assert event.alert_type == 1
    assert event.alert_name == 'Down'
    assert event.alert_duration == 0
    assert event.monitor_name == 'unittest'
예제 #7
0
def test_create_up(up):
    event = Event.create_event(up)
    assert event.alert_type == 2
    assert event.alert_name == 'Up'
    assert event.alert_duration == 99
    assert event.monitor_name == 'unittest'
예제 #8
0
def test_format(down):
    assert repr(
        Event.create_event(down)
    ) == "<Event for unittest: Down(1) since 0:00:00, for testing purpose>"