def test_commit_multiple_objects(self): db_api.start_tx() try: created_trigger = db_api.trigger_create(TRIGGERS[0]) self.assertIsInstance(created_trigger, dict) fetched_trigger = db_api.trigger_get(created_trigger['id']) self.assertIsInstance(fetched_trigger, dict) self.assertDictEqual(created_trigger, fetched_trigger) created_workbook = db_api.workbook_create(WORKBOOKS[0]) self.assertIsInstance(created_workbook, dict) fetched_workbook = db_api.workbook_get(created_workbook['name']) self.assertIsInstance(fetched_workbook, dict) self.assertDictEqual(created_workbook, fetched_workbook) self.assertTrue(self.is_db_session_open()) db_api.commit_tx() finally: db_api.end_tx() self.assertFalse(self.is_db_session_open()) fetched_trigger = db_api.trigger_get(created_trigger['id']) self.assertIsInstance(fetched_trigger, dict) self.assertDictEqual(created_trigger, fetched_trigger) fetched_workbook = db_api.workbook_get(created_workbook['name']) self.assertIsInstance(fetched_workbook, dict) self.assertDictEqual(created_workbook, fetched_workbook) self.assertFalse(self.is_db_session_open())
def test_rollback_multiple_objects(self): db_api.start_tx() try: created_trigger = db_api.trigger_create(TRIGGERS[0]) self.assertIsInstance(created_trigger, dict) fetched_trigger = db_api.trigger_get(created_trigger['id']) self.assertIsInstance(fetched_trigger, dict) self.assertDictEqual(created_trigger, fetched_trigger) created_workbook = db_api.workbook_create(WORKBOOKS[0]) self.assertIsInstance(created_workbook, dict) fetched_workbook = db_api.workbook_get(created_workbook['name']) self.assertIsInstance(fetched_workbook, dict) self.assertDictEqual(created_workbook, fetched_workbook) self.assertTrue(self.is_db_session_open()) db_api.rollback_tx() finally: db_api.end_tx() self.assertFalse(self.is_db_session_open()) fetched_trigger = db_api.trigger_get(created_trigger['id']) self.assertIsNone(fetched_trigger) self.assertRaises(exc.NotFoundException, db_api.workbook_get, created_workbook['name']) self.assertFalse(self.is_db_session_open())
def test_rollback(self): db_api.start_tx() try: created = db_api.trigger_create(TRIGGERS[0]) self.assertIsInstance(created, dict) fetched = db_api.trigger_get(created['id']) self.assertIsInstance(fetched, dict) self.assertDictEqual(created, fetched) self.assertTrue(self.is_db_session_open()) db_api.rollback_tx() finally: db_api.end_tx() self.assertFalse(self.is_db_session_open()) fetched = db_api.trigger_get(created['id']) self.assertIsNone(fetched) self.assertFalse(self.is_db_session_open())