def test_trigger_crud(self):
        triggertype = ReactorModelTest._create_save_triggertype()
        saved = ReactorModelTest._create_save_trigger(triggertype)
        retrieved = Trigger.get_by_id(saved.id)
        self.assertEqual(saved.name, retrieved.name,
                         'Same trigger was not returned.')
        # test update
        self.assertEqual(retrieved.description, '')
        retrieved.description = DUMMY_DESCRIPTION
        saved = Trigger.add_or_update(retrieved)
        retrieved = Trigger.get_by_id(saved.id)
        self.assertEqual(retrieved.description, DUMMY_DESCRIPTION, 'Update to trigger failed.')
        # cleanup
        ReactorModelTest._delete([retrieved, triggertype])
        try:
            retrieved = Trigger.get_by_id(saved.id)
        except __HOLE__:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
dataset/ETHPy150Open StackStorm/st2/st2common/tests/unit/test_db.py/ReactorModelTest.test_trigger_crud