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_workbook_delete(self): created = db_api.workbook_create(WORKBOOKS[0]) self.assertIsInstance(created, dict) fetched = db_api.workbook_get(created['name']) self.assertIsInstance(fetched, dict) self.assertDictEqual(created, fetched) db_api.workbook_delete(created['name']) self.assertIsNone(db_api.workbook_get(created['name']))
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_workbook_update(self): created = db_api.workbook_create(WORKBOOKS[0]) self.assertIsInstance(created, dict) updated = db_api.workbook_update(created['name'], {'description': 'my new desc'}) self.assertIsInstance(updated, dict) self.assertEqual('my new desc', updated['description']) fetched = db_api.workbook_get(created['name']) self.assertDictEqual(updated, fetched)
def test_workbook_delete(self): created = db_api.workbook_create(WORKBOOKS[0]) self.assertIsInstance(created, dict) fetched = db_api.workbook_get(created['name']) self.assertIsInstance(fetched, dict) self.assertDictEqual(created, fetched) db_api.workbook_delete(created['name']) self.assertRaises(exc.NotFoundException, db_api.workbook_get, created['name'])