Example #1
0
 def test_trigger_get_diff_project(self):
     trigger = self._create_trigger(self.ctx)
     new_ctx = utils.dummy_context(project='a-different-project')
     retobj = db_api.trigger_get(new_ctx, trigger.id)
     self.assertIsNone(retobj)
     retobj = db_api.trigger_get(new_ctx, trigger.id, project_safe=False)
     self.assertIsNotNone(retobj)
     self.assertEqual(trigger.id, retobj.id)
Example #2
0
    def test_trigger_get_by_short_id(self):
        trigger_ids = ['same-part-unique-part',
                       'same-part-part-unique']

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

            # verify creation with set ID
            trigger = db_api.trigger_get(self.ctx, pid)
            self.assertIsNotNone(trigger)
            self.assertEqual(pid, trigger.id)

        # too short -> multiple choices
        for x in range(len('same-part-')):
            self.assertRaises(exception.MultipleChoices,
                              db_api.trigger_get_by_short_id,
                              self.ctx, trigger_ids[0][:x])

        # ids are unique
        trigger = db_api.trigger_get_by_short_id(self.ctx, trigger_ids[0][:11])
        self.assertEqual(trigger_ids[0], trigger.id)
        trigger = db_api.trigger_get_by_short_id(self.ctx, trigger_ids[1][:11])
        self.assertEqual(trigger_ids[1], trigger.id)

        # bad ids
        res = db_api.trigger_get_by_short_id(self.ctx, 'non-existent')
        self.assertIsNone(res)
Example #3
0
    def test_trigger_get_by_short_id(self):
        trigger_ids = ['same-part-unique-part', 'same-part-part-unique']

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

            # verify creation with set ID
            trigger = db_api.trigger_get(self.ctx, pid)
            self.assertIsNotNone(trigger)
            self.assertEqual(pid, trigger.id)

        # too short -> multiple choices
        for x in range(len('same-part-')):
            self.assertRaises(exception.MultipleChoices,
                              db_api.trigger_get_by_short_id, self.ctx,
                              trigger_ids[0][:x])

        # ids are unique
        trigger = db_api.trigger_get_by_short_id(self.ctx, trigger_ids[0][:11])
        self.assertEqual(trigger_ids[0], trigger.id)
        trigger = db_api.trigger_get_by_short_id(self.ctx, trigger_ids[1][:11])
        self.assertEqual(trigger_ids[1], trigger.id)

        # bad ids
        res = db_api.trigger_get_by_short_id(self.ctx, 'non-existent')
        self.assertIsNone(res)
Example #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)
Example #5
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)
Example #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)
Example #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)
Example #8
0
 def test_trigger_get_not_found(self):
     trigger = db_api.trigger_get(self.ctx, 'BOGUS_ID')
     self.assertIsNone(trigger)
Example #9
0
 def test_trigger_get(self):
     trigger = self._create_trigger(self.ctx)
     retobj = db_api.trigger_get(self.ctx, trigger.id)
     self.assertEqual(trigger.id, retobj.id)
     self.assertEqual(trigger.spec, retobj.spec)
Example #10
0
 def test_trigger_get_not_found(self):
     trigger = db_api.trigger_get(self.ctx, 'BOGUS_ID')
     self.assertIsNone(trigger)
Example #11
0
 def test_trigger_get(self):
     trigger = self._create_trigger(self.ctx)
     retobj = db_api.trigger_get(self.ctx, trigger.id)
     self.assertEqual(trigger.id, retobj.id)
     self.assertEqual(trigger.spec, retobj.spec)