Beispiel #1
0
    def test_trigger_get_all(self):
        ids = ['trigger1', 'trigger2']

        for pid in ids:
            self._create_trigger(self.ctx, id=pid)

        triggers = db_api.trigger_get_all(self.ctx)
        self.assertEqual(2, len(triggers))
        trigger_ids = [p.id for p in triggers]
        for pid in ids:
            self.assertIn(pid, trigger_ids)

        # test show_deleted here
        db_api.trigger_delete(self.ctx, triggers[1].id)

        # after delete one of them
        triggers = db_api.trigger_get_all(self.ctx)
        self.assertEqual(1, len(triggers))

        triggers = db_api.trigger_get_all(self.ctx, show_deleted=False)
        self.assertEqual(1, len(triggers))

        triggers = db_api.trigger_get_all(self.ctx, show_deleted=True)
        self.assertEqual(2, len(triggers))

        # after delete both triggers
        db_api.trigger_delete(self.ctx, triggers[0].id)

        triggers = db_api.trigger_get_all(self.ctx)
        self.assertEqual(0, len(triggers))
        triggers = db_api.trigger_get_all(self.ctx, show_deleted=True)
        self.assertEqual(2, len(triggers))
Beispiel #2
0
    def test_trigger_get_all(self):
        ids = ['trigger1', 'trigger2']

        for pid in ids:
            self._create_trigger(self.ctx, id=pid)

        triggers = db_api.trigger_get_all(self.ctx)
        self.assertEqual(2, len(triggers))
        trigger_ids = [p.id for p in triggers]
        for pid in ids:
            self.assertIn(pid, trigger_ids)

        # test show_deleted here
        db_api.trigger_delete(self.ctx, triggers[1].id)

        # after delete one of them
        triggers = db_api.trigger_get_all(self.ctx)
        self.assertEqual(1, len(triggers))

        triggers = db_api.trigger_get_all(self.ctx, show_deleted=False)
        self.assertEqual(1, len(triggers))

        triggers = db_api.trigger_get_all(self.ctx, show_deleted=True)
        self.assertEqual(2, len(triggers))

        # after delete both triggers
        db_api.trigger_delete(self.ctx, triggers[0].id)

        triggers = db_api.trigger_get_all(self.ctx)
        self.assertEqual(0, len(triggers))
        triggers = db_api.trigger_get_all(self.ctx, show_deleted=True)
        self.assertEqual(2, len(triggers))
Beispiel #3
0
    def test_trigger_delete(self):
        trigger = self._create_trigger(self.ctx)
        self.assertIsNotNone(trigger)
        trigger_id = trigger.id
        db_api.trigger_delete(self.ctx, trigger_id)

        trigger = db_api.trigger_get(self.ctx, trigger_id)
        self.assertIsNone(trigger)

        # not found in delete is okay
        res = db_api.trigger_delete(self.ctx, trigger_id)
        self.assertIsNone(res)
Beispiel #4
0
    def test_trigger_delete(self):
        trigger = self._create_trigger(self.ctx)
        self.assertIsNotNone(trigger)
        trigger_id = trigger.id
        db_api.trigger_delete(self.ctx, trigger_id)

        trigger = db_api.trigger_get(self.ctx, trigger_id)
        self.assertIsNone(trigger)

        # not found in delete is okay
        res = db_api.trigger_delete(self.ctx, trigger_id)
        self.assertIsNone(res)
Beispiel #5
0
    def test_trigger_get_by_name_show_deleted(self):
        trigger_name = 'my_best_trigger'

        trigger_id = self._create_trigger(self.ctx, name=trigger_name).id

        db_api.trigger_delete(self.ctx, trigger_id)

        # default case
        trigger = db_api.trigger_get_by_name(self.ctx, trigger_name)
        self.assertIsNone(trigger)

        # explicit false
        trigger = db_api.trigger_get_by_name(self.ctx, trigger_name,
                                             show_deleted=False)
        self.assertIsNone(trigger)

        # explicit true
        trigger = db_api.trigger_get_by_name(self.ctx, trigger_name,
                                             show_deleted=True)
        self.assertIsNotNone(trigger)
        self.assertEqual(trigger_id, trigger.id)
Beispiel #6
0
    def test_trigger_get_show_deleted(self):
        trigger_id = self._create_trigger(self.ctx).id

        # check created
        trigger = db_api.trigger_get(self.ctx, trigger_id)
        self.assertIsNotNone(trigger)

        # Now, delete it
        db_api.trigger_delete(self.ctx, trigger_id)

        # default equivalent to false
        trigger = db_api.trigger_get(self.ctx, trigger_id)
        self.assertIsNone(trigger)

        # explicit false
        trigger = db_api.trigger_get(self.ctx, trigger_id, show_deleted=False)
        self.assertIsNone(trigger)

        # explicit true
        trigger = db_api.trigger_get(self.ctx, trigger_id, show_deleted=True)
        self.assertIsNotNone(trigger)
        self.assertEqual(trigger_id, trigger.id)
Beispiel #7
0
    def test_trigger_get_show_deleted(self):
        trigger_id = self._create_trigger(self.ctx).id

        # check created
        trigger = db_api.trigger_get(self.ctx, trigger_id)
        self.assertIsNotNone(trigger)

        # Now, delete it
        db_api.trigger_delete(self.ctx, trigger_id)

        # default equivalent to false
        trigger = db_api.trigger_get(self.ctx, trigger_id)
        self.assertIsNone(trigger)

        # explicit false
        trigger = db_api.trigger_get(self.ctx, trigger_id, show_deleted=False)
        self.assertIsNone(trigger)

        # explicit true
        trigger = db_api.trigger_get(self.ctx, trigger_id, show_deleted=True)
        self.assertIsNotNone(trigger)
        self.assertEqual(trigger_id, trigger.id)
Beispiel #8
0
    def test_trigger_get_by_name_show_deleted(self):
        trigger_name = 'my_best_trigger'

        trigger_id = self._create_trigger(self.ctx, name=trigger_name).id

        db_api.trigger_delete(self.ctx, trigger_id)

        # default case
        trigger = db_api.trigger_get_by_name(self.ctx, trigger_name)
        self.assertIsNone(trigger)

        # explicit false
        trigger = db_api.trigger_get_by_name(self.ctx,
                                             trigger_name,
                                             show_deleted=False)
        self.assertIsNone(trigger)

        # explicit true
        trigger = db_api.trigger_get_by_name(self.ctx,
                                             trigger_name,
                                             show_deleted=True)
        self.assertIsNotNone(trigger)
        self.assertEqual(trigger_id, trigger.id)