def test_json_data(self): object_type = 'testobject' data = 'testdata' row = models.OpenDaylightJournal(object_type=object_type, object_uuid=uuidutils.generate_uuid(), operation=odl_const.ODL_CREATE, data=data) self.assertEqual("%ss" % object_type, self.journal._json_data(row)[1])
def test_json_data_customized_url(self): object_type = 'randomtestobject' data = 'testdata' journal.register_url_builder(object_type, lambda row: row.object_type) row = models.OpenDaylightJournal(object_type=object_type, object_uuid=uuidutils.generate_uuid(), operation=odl_const.ODL_CREATE, data=data) url_param = self.journal._json_data(row) self.assertEqual(object_type, url_param[1])
def create_pending_row(session, object_type, object_uuid, operation, data): row = models.OpenDaylightJournal(object_type=object_type, object_uuid=object_uuid, operation=operation, data=data, created_at=func.now(), state=odl_const.PENDING) session.add(row) # Keep session flush for unit tests. NOOP for L2/L3 events since calls are # made inside database session transaction with subtransactions=True. session.flush()
def create_pending_row(session, object_type, object_uuid, operation, data, depending_on=None): if depending_on is None: depending_on = [] row = models.OpenDaylightJournal(object_type=object_type, object_uuid=object_uuid, operation=operation, data=data, state=odl_const.PENDING, depending_on=depending_on) session.add(row) # Keep session flush for unit tests. NOOP for L2/L3 events since calls are # made inside database session transaction with subtransactions=True. session.flush() return row