Пример #1
0
    def test_webhook_get_all_with_limit_marker(self):
        webhook_ids = ['webhook1', 'webhook2', 'webhook3']
        for v in webhook_ids:
            shared.create_webhook(self.ctx,
                                  self.obj_id,
                                  self.obj_type,
                                  self.action,
                                  id=v,
                                  created_time=tu.utcnow())

        webhooks = db_api.webhook_get_all(self.ctx, limit=1)
        self.assertEqual(1, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, limit=2)
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, limit=5)
        self.assertEqual(3, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, marker='webhook1')
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, marker='webhook2')
        self.assertEqual(1, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, marker='webhook3')
        self.assertEqual(0, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, limit=1, marker='webhook1')
        self.assertEqual(1, len(webhooks))
Пример #2
0
    def test_webhook_get_all_with_limit_marker(self):
        webhook_ids = ['webhook1', 'webhook2', 'webhook3']
        for v in webhook_ids:
            shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                  self.action, id=v,
                                  created_time=tu.utcnow())

        webhooks = db_api.webhook_get_all(self.ctx, limit=1)
        self.assertEqual(1, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, limit=2)
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, limit=5)
        self.assertEqual(3, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, marker='webhook1')
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, marker='webhook2')
        self.assertEqual(1, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, marker='webhook3')
        self.assertEqual(0, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, limit=1, marker='webhook1')
        self.assertEqual(1, len(webhooks))
Пример #3
0
    def test_webhook_get_by_name_show_deleted(self):
        webhook_name = 'fake_webhook_name'
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name=webhook_name)
        webhook = db_api.webhook_get_by_name(self.ctx, webhook_name)
        self.assertIsNotNone(webhook)
        self.assertEqual(webhook_name, webhook.name)

        webhook_id = webhook.id
        db_api.webhook_delete(self.ctx, webhook_id)

        res = db_api.webhook_get_by_name(self.ctx, webhook_name)
        self.assertIsNone(res)

        res = db_api.webhook_get_by_name(self.ctx,
                                         webhook_name,
                                         show_deleted=False)
        self.assertIsNone(res)

        res = db_api.webhook_get_by_name(self.ctx,
                                         webhook_name,
                                         show_deleted=True)
        self.assertEqual(webhook_id, res.id)
Пример #4
0
    def test_webhook_get_by_short_id(self):
        webhook_id1 = 'same-part-unique-part'
        webhook_id2 = 'same-part-part-unique'
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              id=webhook_id1,
                              name='webhook-1')
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              id=webhook_id2,
                              name='webhook-2')

        for x in range(len('same-part-')):
            self.assertRaises(exception.MultipleChoices,
                              db_api.webhook_get_by_short_id, self.ctx,
                              webhook_id1[:x])

        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id1[:11])
        self.assertEqual(webhook_id1, res.id)
        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id2[:11])
        self.assertEqual(webhook_id2, res.id)
        res = db_api.webhook_get_by_short_id(self.ctx, 'non-existent')
        self.assertIsNone(res)
Пример #5
0
    def test_webhook_get_by_short_id_show_deleted(self):
        webhook_id = 'this-is-a-unique-id'
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              id=webhook_id)

        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:5])
        self.assertEqual(webhook_id, res.id)
        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:7])
        self.assertEqual(webhook_id, res.id)

        db_api.webhook_delete(self.ctx, webhook_id)

        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:5])
        self.assertIsNone(res)
        res = db_api.webhook_get_by_short_id(self.ctx,
                                             webhook_id[:5],
                                             show_deleted=False)
        self.assertIsNone(res)
        res = db_api.webhook_get_by_short_id(self.ctx,
                                             webhook_id[:5],
                                             show_deleted=True)
        self.assertEqual(webhook_id, res.id)
Пример #6
0
    def test_webhook_get_all_with_empty_filters(self):
        shared.create_webhook(self.ctx, self.obj_id,
                              self.obj_type, self.action, name='webhook1')
        shared.create_webhook(self.ctx, self.obj_id,
                              self.obj_type, self.action, name='webhook2')

        filters = None
        results = db_api.webhook_get_all(self.ctx, filters=filters)
        self.assertEqual(2, len(results))
Пример #7
0
    def test_webhook_get_by_name(self):
        webhook_name = 'fake_webhook_name'
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, name=webhook_name)
        webhook = db_api.webhook_get_by_name(self.ctx, webhook_name)
        self.assertIsNotNone(webhook)
        self.assertEqual(webhook_name, webhook.name)

        res = db_api.webhook_get_by_name(self.ctx, 'BogusName')
        self.assertIsNone(res)
Пример #8
0
    def test_webhook_get_by_name_diff_project(self):
        webhook_name = 'fake_webhook_name'
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, name=webhook_name)

        new_ctx = utils.dummy_context(project='a-different-project')
        res = db_api.webhook_get_by_name(new_ctx, webhook_name)
        self.assertIsNone(res)
        res = db_api.webhook_get_by_name(new_ctx, webhook_name,
                                         project_safe=False)
        self.assertIsNotNone(res)
        self.assertEqual(webhook_name, res.name)
Пример #9
0
    def test_webhook_get_by_short_id_diff_project(self):
        webhook_id = 'same-part-unique-part'
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, id=webhook_id, name='webhook-1')

        new_ctx = utils.dummy_context(project='a-different-project')
        res = db_api.webhook_get_by_short_id(new_ctx, webhook_id[:11])
        self.assertIsNone(res)
        res = db_api.webhook_get_by_short_id(new_ctx, webhook_id[:11],
                                             project_safe=False)
        self.assertIsNotNone(res)
        self.assertEqual(webhook_id, res.id)
Пример #10
0
    def test_webhook_get_by_name(self):
        webhook_name = 'fake_webhook_name'
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name=webhook_name)
        webhook = db_api.webhook_get_by_name(self.ctx, webhook_name)
        self.assertIsNotNone(webhook)
        self.assertEqual(webhook_name, webhook.name)

        res = db_api.webhook_get_by_name(self.ctx, 'BogusName')
        self.assertIsNone(res)
Пример #11
0
    def test_webhook_get_all_with_empty_filters(self):
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name='webhook1')
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name='webhook2')

        filters = None
        results = db_api.webhook_get_all(self.ctx, filters=filters)
        self.assertEqual(2, len(results))
Пример #12
0
    def test_webhook_get_all_with_filters(self):
        shared.create_webhook(self.ctx, self.obj_id,
                              self.obj_type, self.action, name='webhook1')
        shared.create_webhook(self.ctx, self.obj_id,
                              self.obj_type, self.action, name='webhook2')

        filters = {'name': ['webhook1', 'webhookx']}
        results = db_api.webhook_get_all(self.ctx, filters=filters)
        self.assertEqual(1, len(results))
        self.assertEqual('webhook1', results[0]['name'])

        filters = {'name': 'webhook1'}
        results = db_api.webhook_get_all(self.ctx, filters=filters)
        self.assertEqual(1, len(results))
        self.assertEqual('webhook1', results[0]['name'])
Пример #13
0
    def test_webhook_get_all_show_deleted(self):
        values = [{'id': 'webhook1'}, {'id': 'webhook2'}, {'id': 'webhook3'}]
        for v in values:
            shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                  self.action, **v)

        db_api.webhook_delete(self.ctx, 'webhook2')

        webhooks = db_api.webhook_get_all(self.ctx)
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, show_deleted=False)
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, show_deleted=True)
        self.assertEqual(3, len(webhooks))
Пример #14
0
    def test_webhook_get_all_used_sort_keys(self):
        webhook_ids = ['webhook1', 'webhook2', 'webhook3']
        for v in webhook_ids:
            shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                  self.action, id=v)

        mock_paginate = self.patchobject(db_api.utils, 'paginate_query')
        sort_keys = ['name', 'created_time', 'deleted_time',
                     'obj_id', 'obj_type']

        db_api.webhook_get_all(self.ctx, sort_keys=sort_keys)
        args = mock_paginate.call_args[0]
        used_sort_keys = set(args[3])
        expected_keys = set(['name', 'created_time', 'deleted_time',
                             'obj_id', 'obj_type', 'id'])
        self.assertEqual(expected_keys, used_sort_keys)
Пример #15
0
    def test_webhook_get_all_with_project_safe(self):
        shared.create_webhook(self.ctx, self.obj_id,
                              self.obj_type, self.action, name='webhook1')
        shared.create_webhook(self.ctx, self.obj_id,
                              self.obj_type, self.action, name='webhook2')

        self.ctx.project = 'a-different-project'
        results = db_api.webhook_get_all(self.ctx, project_safe=False)
        self.assertEqual(2, len(results))

        self.ctx.project = 'a-different-project'
        results = db_api.webhook_get_all(self.ctx)
        self.assertEqual(0, len(results))

        results = db_api.webhook_get_all(self.ctx, project_safe=True)
        self.assertEqual(0, len(results))
Пример #16
0
    def test_webhook_get_all_show_deleted(self):
        values = [{'id': 'webhook1'}, {'id': 'webhook2'}, {'id': 'webhook3'}]
        for v in values:
            shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                  self.action, **v)

        db_api.webhook_delete(self.ctx, 'webhook2')

        webhooks = db_api.webhook_get_all(self.ctx)
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, show_deleted=False)
        self.assertEqual(2, len(webhooks))

        webhooks = db_api.webhook_get_all(self.ctx, show_deleted=True)
        self.assertEqual(3, len(webhooks))
Пример #17
0
    def test_webhook_get_all_default_sort_dir(self):
        values = [{'id': '001', 'name': 'webhook1'},
                  {'id': '002', 'name': 'webhook2'},
                  {'id': '003', 'name': 'webhook3'}]
        obj_ids = {'webhook1': 'id3',
                   'webhook2': 'id2',
                   'webhook3': 'id1'}
        for v in values:
            shared.create_webhook(self.ctx, obj_ids[v['name']],
                                  self.obj_type,
                                  self.action, **v)

        webhooks = db_api.webhook_get_all(self.ctx, sort_dir='asc')
        self.assertEqual(3, len(webhooks))
        self.assertEqual(values[2]['id'], webhooks[0].id)
        self.assertEqual(values[1]['id'], webhooks[1].id)
        self.assertEqual(values[0]['id'], webhooks[2].id)
Пример #18
0
 def test_webhook_get_diff_project(self):
     new_ctx = utils.dummy_context(project='a-different-project')
     webhook = shared.create_webhook(self.ctx, self.obj_id,
                                     self.obj_type, self.action)
     res = db_api.webhook_get(new_ctx, webhook.id)
     self.assertIsNone(res)
     res = db_api.webhook_get(new_ctx, webhook.id, project_safe=False)
     self.assertIsNotNone(res)
     self.assertEqual(webhook.id, res.id)
Пример #19
0
    def test_webhook_get_by_short_id(self):
        webhook_id1 = 'same-part-unique-part'
        webhook_id2 = 'same-part-part-unique'
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, id=webhook_id1, name='webhook-1')
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, id=webhook_id2, name='webhook-2')

        for x in range(len('same-part-')):
            self.assertRaises(exception.MultipleChoices,
                              db_api.webhook_get_by_short_id,
                              self.ctx, webhook_id1[:x])

        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id1[:11])
        self.assertEqual(webhook_id1, res.id)
        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id2[:11])
        self.assertEqual(webhook_id2, res.id)
        res = db_api.webhook_get_by_short_id(self.ctx, 'non-existent')
        self.assertIsNone(res)
Пример #20
0
    def test_webhook_delete(self):
        res = shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                    self.action)
        webhook_id = res.id
        webhook = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNotNone(webhook)

        db_api.webhook_delete(self.ctx, webhook_id)
        res = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNone(res)
Пример #21
0
    def test_webhook_delete(self):
        res = shared.create_webhook(self.ctx, self.obj_id,
                                    self.obj_type, self.action)
        webhook_id = res.id
        webhook = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNotNone(webhook)

        db_api.webhook_delete(self.ctx, webhook_id)
        res = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNone(res)
Пример #22
0
    def test_webhook_get_all_sort_keys_and_dir(self):
        values = [{
            'id': '001',
            'name': 'webhook1'
        }, {
            'id': '002',
            'name': 'webhook3'
        }, {
            'id': '003',
            'name': 'webhook2'
        }]
        obj_ids = {'webhook1': 'id3', 'webhook2': 'id2', 'webhook3': 'id1'}
        for v in values:
            shared.create_webhook(self.ctx, obj_ids[v['name']], self.obj_type,
                                  self.action, **v)

        webhooks = db_api.webhook_get_all(self.ctx,
                                          sort_keys=['name', 'obj_id'],
                                          sort_dir='asc')
        self.assertEqual(3, len(webhooks))
        # Sorted by name (ascending)
        self.assertEqual('001', webhooks[0].id)
        self.assertEqual('003', webhooks[1].id)
        self.assertEqual('002', webhooks[2].id)

        webhooks = db_api.webhook_get_all(self.ctx,
                                          sort_keys=['obj_id', 'name'],
                                          sort_dir='asc')
        self.assertEqual(3, len(webhooks))
        # Sorted by obj_id (ascending)
        self.assertEqual('002', webhooks[0].id)
        self.assertEqual('003', webhooks[1].id)
        self.assertEqual('001', webhooks[2].id)

        webhooks = db_api.webhook_get_all(self.ctx,
                                          sort_keys=['obj_id', 'name'],
                                          sort_dir='desc')
        self.assertEqual(3, len(webhooks))
        # Sorted by obj_id (descending)
        self.assertEqual('001', webhooks[0].id)
        self.assertEqual('003', webhooks[1].id)
        self.assertEqual('002', webhooks[2].id)
Пример #23
0
    def test_webhook_get_by_short_id_show_deleted(self):
        webhook_id = 'this-is-a-unique-id'
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, id=webhook_id)

        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:5])
        self.assertEqual(webhook_id, res.id)
        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:7])
        self.assertEqual(webhook_id, res.id)

        db_api.webhook_delete(self.ctx, webhook_id)

        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:5])
        self.assertIsNone(res)
        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:5],
                                             show_deleted=False)
        self.assertIsNone(res)
        res = db_api.webhook_get_by_short_id(self.ctx, webhook_id[:5],
                                             show_deleted=True)
        self.assertEqual(webhook_id, res.id)
Пример #24
0
    def test_webhook_get_all_with_filters(self):
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name='webhook1')
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name='webhook2')

        filters = {'name': ['webhook1', 'webhookx']}
        results = db_api.webhook_get_all(self.ctx, filters=filters)
        self.assertEqual(1, len(results))
        self.assertEqual('webhook1', results[0]['name'])

        filters = {'name': 'webhook1'}
        results = db_api.webhook_get_all(self.ctx, filters=filters)
        self.assertEqual(1, len(results))
        self.assertEqual('webhook1', results[0]['name'])
Пример #25
0
    def test_webhook_get_by_name_show_deleted(self):
        webhook_name = 'fake_webhook_name'
        shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                              self.action, name=webhook_name)
        webhook = db_api.webhook_get_by_name(self.ctx, webhook_name)
        self.assertIsNotNone(webhook)
        self.assertEqual(webhook_name, webhook.name)

        webhook_id = webhook.id
        db_api.webhook_delete(self.ctx, webhook_id)

        res = db_api.webhook_get_by_name(self.ctx, webhook_name)
        self.assertIsNone(res)

        res = db_api.webhook_get_by_name(self.ctx, webhook_name,
                                         show_deleted=False)
        self.assertIsNone(res)

        res = db_api.webhook_get_by_name(self.ctx, webhook_name,
                                         show_deleted=True)
        self.assertEqual(webhook_id, res.id)
Пример #26
0
    def test_webhook_get_all_used_sort_keys(self):
        webhook_ids = ['webhook1', 'webhook2', 'webhook3']
        for v in webhook_ids:
            shared.create_webhook(self.ctx,
                                  self.obj_id,
                                  self.obj_type,
                                  self.action,
                                  id=v)

        mock_paginate = self.patchobject(db_api.utils, 'paginate_query')
        sort_keys = [
            'name', 'created_time', 'deleted_time', 'obj_id', 'obj_type'
        ]

        db_api.webhook_get_all(self.ctx, sort_keys=sort_keys)
        args = mock_paginate.call_args[0]
        used_sort_keys = set(args[3])
        expected_keys = set([
            'name', 'created_time', 'deleted_time', 'obj_id', 'obj_type', 'id'
        ])
        self.assertEqual(expected_keys, used_sort_keys)
Пример #27
0
    def test_webhook_get_all_default_sort_dir(self):
        values = [{
            'id': '001',
            'name': 'webhook1'
        }, {
            'id': '002',
            'name': 'webhook2'
        }, {
            'id': '003',
            'name': 'webhook3'
        }]
        obj_ids = {'webhook1': 'id3', 'webhook2': 'id2', 'webhook3': 'id1'}
        for v in values:
            shared.create_webhook(self.ctx, obj_ids[v['name']], self.obj_type,
                                  self.action, **v)

        webhooks = db_api.webhook_get_all(self.ctx, sort_dir='asc')
        self.assertEqual(3, len(webhooks))
        self.assertEqual(values[2]['id'], webhooks[0].id)
        self.assertEqual(values[1]['id'], webhooks[1].id)
        self.assertEqual(values[0]['id'], webhooks[2].id)
Пример #28
0
    def test_webhook_get_all(self):
        values = [{'name': 'webhook1'},
                  {'name': 'webhook2'},
                  {'name': 'webhook3'}]
        [shared.create_webhook(
            self.ctx, self.obj_id, self.obj_type,
            self.action, **v) for v in values]

        webhooks = db_api.webhook_get_all(self.ctx)
        self.assertEqual(3, len(webhooks))

        names = [webhook.name for webhook in webhooks]
        [self.assertIn(val['name'], names) for val in values]
Пример #29
0
    def test_webhook_get_all_with_project_safe(self):
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name='webhook1')
        shared.create_webhook(self.ctx,
                              self.obj_id,
                              self.obj_type,
                              self.action,
                              name='webhook2')

        self.ctx.project = 'a-different-project'
        results = db_api.webhook_get_all(self.ctx, project_safe=False)
        self.assertEqual(2, len(results))

        self.ctx.project = 'a-different-project'
        results = db_api.webhook_get_all(self.ctx)
        self.assertEqual(0, len(results))

        results = db_api.webhook_get_all(self.ctx, project_safe=True)
        self.assertEqual(0, len(results))
Пример #30
0
    def test_webhook_get_all_sort_keys_and_dir(self):
        values = [{'id': '001', 'name': 'webhook1'},
                  {'id': '002', 'name': 'webhook3'},
                  {'id': '003', 'name': 'webhook2'}]
        obj_ids = {'webhook1': 'id3',
                   'webhook2': 'id2',
                   'webhook3': 'id1'}
        for v in values:
            shared.create_webhook(self.ctx, obj_ids[v['name']],
                                  self.obj_type,
                                  self.action, **v)

        webhooks = db_api.webhook_get_all(self.ctx,
                                          sort_keys=['name', 'obj_id'],
                                          sort_dir='asc')
        self.assertEqual(3, len(webhooks))
        # Sorted by name (ascending)
        self.assertEqual('001', webhooks[0].id)
        self.assertEqual('003', webhooks[1].id)
        self.assertEqual('002', webhooks[2].id)

        webhooks = db_api.webhook_get_all(self.ctx,
                                          sort_keys=['obj_id', 'name'],
                                          sort_dir='asc')
        self.assertEqual(3, len(webhooks))
        # Sorted by obj_id (ascending)
        self.assertEqual('002', webhooks[0].id)
        self.assertEqual('003', webhooks[1].id)
        self.assertEqual('001', webhooks[2].id)

        webhooks = db_api.webhook_get_all(self.ctx,
                                          sort_keys=['obj_id', 'name'],
                                          sort_dir='desc')
        self.assertEqual(3, len(webhooks))
        # Sorted by obj_id (descending)
        self.assertEqual('001', webhooks[0].id)
        self.assertEqual('003', webhooks[1].id)
        self.assertEqual('002', webhooks[2].id)
Пример #31
0
 def test_webhook_create(self):
     res = shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                 self.action)
     webhook = db_api.webhook_get(self.ctx, res.id)
     self.assertIsNotNone(webhook)
     self.assertEqual(UUID1, webhook.obj_id)
     self.assertEqual('test_webhook_name', webhook.name)
     self.assertEqual(self.ctx.user, webhook.user)
     self.assertEqual(self.ctx.domain, webhook.domain)
     self.assertEqual(self.ctx.project, webhook.project)
     self.assertIsNone(webhook.created_time)
     self.assertIsNone(webhook.deleted_time)
     self.assertEqual('test_obj_type', webhook.obj_type)
     self.assertEqual('test_action', webhook.action)
Пример #32
0
 def test_webhook_create(self):
     res = shared.create_webhook(self.ctx, self.obj_id,
                                 self.obj_type, self.action)
     webhook = db_api.webhook_get(self.ctx, res.id)
     self.assertIsNotNone(webhook)
     self.assertEqual(UUID1, webhook.obj_id)
     self.assertEqual('test_webhook_name', webhook.name)
     self.assertEqual(self.ctx.user, webhook.user)
     self.assertEqual(self.ctx.domain, webhook.domain)
     self.assertEqual(self.ctx.project, webhook.project)
     self.assertIsNone(webhook.created_time)
     self.assertIsNone(webhook.deleted_time)
     self.assertEqual('test_obj_type', webhook.obj_type)
     self.assertEqual('test_action', webhook.action)
Пример #33
0
    def test_webhook_get_show_deleted(self):
        res = shared.create_webhook(self.ctx, self.obj_id,
                                    self.obj_type, self.action)
        webhook_id = res.id
        webhook = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNotNone(webhook)

        db_api.webhook_delete(self.ctx, webhook_id)

        webhook = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNone(webhook)

        webhook = db_api.webhook_get(self.ctx, webhook_id, show_deleted=False)
        self.assertIsNone(webhook)

        webhook = db_api.webhook_get(self.ctx, webhook_id, show_deleted=True)
        self.assertEqual(webhook_id, webhook.id)
Пример #34
0
    def test_webhook_get_show_deleted(self):
        res = shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                    self.action)
        webhook_id = res.id
        webhook = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNotNone(webhook)

        db_api.webhook_delete(self.ctx, webhook_id)

        webhook = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNone(webhook)

        webhook = db_api.webhook_get(self.ctx, webhook_id, show_deleted=False)
        self.assertIsNone(webhook)

        webhook = db_api.webhook_get(self.ctx, webhook_id, show_deleted=True)
        self.assertEqual(webhook_id, webhook.id)
Пример #35
0
    def test_webhook_get_all(self):
        values = [{
            'name': 'webhook1'
        }, {
            'name': 'webhook2'
        }, {
            'name': 'webhook3'
        }]
        [
            shared.create_webhook(self.ctx, self.obj_id, self.obj_type,
                                  self.action, **v) for v in values
        ]

        webhooks = db_api.webhook_get_all(self.ctx)
        self.assertEqual(3, len(webhooks))

        names = [webhook.name for webhook in webhooks]
        [self.assertIn(val['name'], names) for val in values]