Example #1
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)
Example #2
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)
Example #3
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)
Example #4
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)
Example #5
0
    def test_webhook_delete_not_found(self):
        webhook_id = 'BogusWebhookID'
        res = db_api.webhook_delete(self.ctx, webhook_id)
        self.assertIsNone(res)

        res = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNone(res)
Example #6
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))
Example #7
0
    def test_webhook_delete_not_found(self):
        webhook_id = 'BogusWebhookID'
        res = db_api.webhook_delete(self.ctx, webhook_id)
        self.assertIsNone(res)

        res = db_api.webhook_get(self.ctx, webhook_id)
        self.assertIsNone(res)
Example #8
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))
Example #9
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)
Example #10
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)
Example #11
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)
Example #12
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)