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)
    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)
    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)
    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)
    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)
Exemple #6
0
    def test_webhook_store(self):
        webhook = webhook_mod.Webhook('test-obj-id', 'test-obj-type',
                                      'test-action', context=self.context)

        self.assertIsNotNone(webhook.id)
        webhook_id = webhook.store(self.context)
        self.assertIsNotNone(webhook_id)
        self.assertEqual(webhook_id, webhook.id)

        result = db_api.webhook_get(self.context, webhook_id)

        self.assertIsNotNone(result)
        self.assertEqual(webhook_id, result.id)
        self.assertEqual(webhook.name, result.name)
        self.assertEqual(webhook.user, result.user)
        self.assertEqual(webhook.project, result.project)
        self.assertEqual(webhook.domain, result.domain)
        self.assertEqual(webhook.created_time, result.created_time)
        self.assertEqual(webhook.deleted_time, result.deleted_time)
        self.assertEqual(webhook.credential, result.credential)
        self.assertEqual(webhook.params, result.params)

        self.assertEqual('test-obj-id', result.obj_id)
        self.assertEqual('test-obj-type', result.obj_type)
        self.assertEqual('test-action', result.action)

        self.assertIsNotNone(result.created_time)
        self.assertIsNone(result.deleted_time)
Exemple #7
0
    def test_webhook_store(self):
        webhook = webhook_mod.Webhook('test-obj-id', 'test-obj-type',
                                      'test-action')

        self.assertIsNotNone(webhook.id)
        webhook_id = webhook.store(self.context)
        self.assertIsNotNone(webhook_id)
        self.assertEqual(webhook_id, webhook.id)

        result = db_api.webhook_get(self.context, webhook_id)

        self.assertIsNotNone(result)
        self.assertEqual(webhook_id, result.id)
        self.assertEqual(webhook.name, result.name)
        self.assertEqual(webhook.user, result.user)
        self.assertEqual(webhook.project, result.project)
        self.assertEqual(webhook.domain, result.domain)
        self.assertEqual(webhook.created_time, result.created_time)
        self.assertEqual(webhook.deleted_time, result.deleted_time)
        self.assertEqual(webhook.credential, result.credential)
        self.assertEqual(webhook.params, result.params)

        self.assertEqual('test-obj-id', result.obj_id)
        self.assertEqual('test-obj-type', result.obj_type)
        self.assertEqual('test-action', result.action)

        self.assertIsNotNone(result.created_time)
        self.assertIsNone(result.deleted_time)
    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)
    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)
Exemple #10
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)
Exemple #11
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)