Пример #1
0
def set_events(resource, lst):
    resource_events = orm.DBResourceEvents.get_or_create(resource)
    for ev in resource_events.events.as_set():
        ev.delete()
    for ev in lst:
        event_db = orm.DBEvent(**ev.to_dict())
        event_db.save()
        resource_events.events.add(event_db)
Пример #2
0
 def test_save_several(self):
     ev = orm.DBEvent(
         parent='n1',
         parent_action='run',
         state='success',
         child_action='run',
         child='n2',
         etype='dependency')
     ev.save()
     ev1 = orm.DBEvent(
         parent='n1',
         parent_action='run',
         state='success',
         child_action='run',
         child='n3',
         etype='dependency')
     ev1.save()
     self.assertEqual(len(orm.DBEvent.load_all()), 2)
Пример #3
0
def add_event(ev):
    rst = all_events(ev.parent)
    for rev in rst:
        if ev == rev:
            break
    else:
        rst.append(ev)
        resource_events = orm.DBResourceEvents.get_or_create(ev.parent)
        event_db = orm.DBEvent(**ev.to_dict())
        event_db.save()
        resource_events.events.add(event_db)
Пример #4
0
    def test_save_and_load_by_parent(self):
        ev = orm.DBEvent(
            parent='n1',
            parent_action='run',
            state='success',
            child_action='run',
            child='n2',
            etype='dependency')
        ev.save()

        rst = orm.DBEvent.load(ev.id)
        self.assertEqual(rst, ev)
Пример #5
0
    def test_removal_of_event(self):
        r = orm.DBResourceEvents(id='test1')
        r.save()

        ev = orm.DBEvent(
            parent='test1',
            parent_action='run',
            state='success',
            child_action='run',
            child='n2',
            etype='dependency')
        ev.save()
        r.events.add(ev)

        self.assertEqual(r.events.as_set(), {ev})
        ev.delete()

        r = orm.DBResourceEvents.load('test1')
        self.assertEqual(r.events.as_set(), set())
Пример #6
0
def remove_event(ev):
    event_db = orm.DBEvent(**ev.to_dict())
    event_db.delete()