• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dbapi.exists_send_status函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stacktach.dbapi.exists_send_status函数的典型用法代码示例。如果您正苦于以下问题:Python exists_send_status函数的具体用法?Python exists_send_status怎么用?Python exists_send_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了exists_send_status函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_send_status_batch_multiple_results

    def test_send_status_batch_multiple_results(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        messages = {
            MESSAGE_ID_1: 200,
        }
        body_dict = {'messages': messages}
        body = json.dumps(body_dict)
        fake_request.body = body
        self.mox.StubOutWithMock(transaction, 'commit_on_success')
        trans_obj = self.mox.CreateMockAnything()
        transaction.commit_on_success().AndReturn(trans_obj)
        trans_obj.__enter__()
        results = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results)
        exception = models.InstanceExists.MultipleObjectsReturned()
        results.get(message_id=MESSAGE_ID_1).AndRaise(exception)
        trans_obj.__exit__(dbapi.APIException().__class__,
                           mox.IgnoreArg(),
                           mox.IgnoreArg())
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 500)
        body = json.loads(resp.content)
        self.assertEqual(body.get("status"), 500)
        msg = "Multiple Exists records with message_id = '%s'"
        msg = msg % MESSAGE_ID_1
        self.assertEqual(body.get("message"), msg)
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:30,代码来源:test_dbapi.py


示例2: test_send_status_batch

    def test_send_status_batch(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        messages = {
            MESSAGE_ID_1: 200,
            MESSAGE_ID_2: 400
        }
        body_dict = {'messages': messages}
        body = json.dumps(body_dict)
        fake_request.body = body
        results1 = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results1)
        exists1 = self.mox.CreateMockAnything()
        results1.get(message_id=MESSAGE_ID_2).AndReturn(exists1)
        exists1.save()
        results2 = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results2)
        exists2 = self.mox.CreateMockAnything()
        results2.get(message_id=MESSAGE_ID_1).AndReturn(exists2)
        exists2.save()
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 200)
        exists1.send_status = 200
        self.mox.VerifyAll()
开发者ID:pperezrubio,项目名称:stacktach,代码行数:26,代码来源:test_dbapi.py


示例3: test_send_status_batch

    def test_send_status_batch(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        messages = {
            MESSAGE_ID_1: 200,
            MESSAGE_ID_2: 400
        }
        body_dict = {'messages': messages}
        body = json.dumps(body_dict)
        fake_request.body = body
        self.mox.StubOutWithMock(transaction, 'commit_on_success')
        trans_obj = self.mox.CreateMockAnything()
        transaction.commit_on_success().AndReturn(trans_obj)
        trans_obj.__enter__()
        results1 = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results1)
        exists1 = self.mox.CreateMockAnything()
        results1.get(message_id=MESSAGE_ID_2).AndReturn(exists1)
        exists1.save()
        results2 = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results2)
        exists2 = self.mox.CreateMockAnything()
        results2.get(message_id=MESSAGE_ID_1).AndReturn(exists2)
        exists2.save()
        trans_obj.__exit__(None, None, None)
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 200)
        exists1.send_status = 200
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:31,代码来源:test_dbapi.py


示例4: test_send_status

    def test_send_status(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        body_dict = {'send_status': 200}
        body = json.dumps(body_dict)
        fake_request.body = body
        exists = self.mox.CreateMockAnything()
        result = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(result)
        result.get(message_id=MESSAGE_ID_1).AndReturn(exists)
        exists.save()
        self.mox.ReplayAll()

        dbapi.exists_send_status(fake_request, MESSAGE_ID_1)

        self.assertEqual(exists.send_status, 200)
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:17,代码来源:test_dbapi.py


示例5: test_send_status_batch_wrong_method

    def test_send_status_batch_wrong_method(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'GET'
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 400)
        body = json.loads(resp.content)
        self.assertEqual(body.get('status'), 400)
        self.assertEqual(body.get('message'), "Invalid method")
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:11,代码来源:test_dbapi.py


示例6: test_send_status_batch_empty_body

    def test_send_status_batch_empty_body(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        fake_request.body = ''
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 400)
        body = json.loads(resp.content)
        self.assertEqual(body.get('status'), 400)
        self.assertEqual(body.get('message'), "Request body required")
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:12,代码来源:test_dbapi.py


示例7: test_send_status_no_body

    def test_send_status_no_body(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        fake_request.body = None
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, MESSAGE_ID_1)
        self.assertEqual(resp.status_code, 400)
        body = json.loads(resp.content)
        self.assertEqual(body.get("status"), 400)
        self.assertEqual(body.get("message"), "Request body required")
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:12,代码来源:test_dbapi.py


示例8: test_send_status_batch_bad_body

    def test_send_status_batch_bad_body(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        body_dict = {'bad': 'body'}
        fake_request.body = json.dumps(body_dict)
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 400)
        body = json.loads(resp.content)
        self.assertEqual(body.get('status'), 400)
        msg = "'messages' missing from request body"
        self.assertEqual(body.get('message'), msg)
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:14,代码来源:test_dbapi.py


示例9: test_send_status_batch_accepts_post_for_nova_and_glance_when_version_is_1

    def test_send_status_batch_accepts_post_for_nova_and_glance_when_version_is_1(
            self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'POST'
        fake_request.GET = {'service': 'glance'}
        messages = {
            'nova': {MESSAGE_ID_3: 201},
            'glance': {MESSAGE_ID_1: 201, MESSAGE_ID_2: 201}
        }
        body_dict = {'version': 1, 'messages': messages}
        body = json.dumps(body_dict)
        fake_request.body = body
        self.mox.StubOutWithMock(transaction, 'commit_on_success')
        trans_obj = self.mox.CreateMockAnything()
        transaction.commit_on_success().AndReturn(trans_obj)
        trans_obj.__enter__()
        results1 = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results1)
        exists1 = self.mox.CreateMockAnything()
        results1.get(message_id=MESSAGE_ID_3).AndReturn(exists1)
        exists1.save()
        trans_obj.__exit__(None, None, None)
        trans_obj = self.mox.CreateMockAnything()
        transaction.commit_on_success().AndReturn(trans_obj)
        trans_obj.__enter__()
        results1 = self.mox.CreateMockAnything()
        models.ImageExists.objects.select_for_update().AndReturn(results1)
        exists1A = self.mox.CreateMockAnything()
        exists1B = self.mox.CreateMockAnything()
        results1.filter(message_id=MESSAGE_ID_2).AndReturn(
            [exists1A, exists1B])
        exists1A.save()
        exists1B.save()
        results2 = self.mox.CreateMockAnything()
        models.ImageExists.objects.select_for_update().AndReturn(results2)
        exists2A = self.mox.CreateMockAnything()
        exists2B = self.mox.CreateMockAnything()
        results2.filter(message_id=MESSAGE_ID_1).AndReturn(
            [exists2A, exists2B])
        exists2A.save()
        exists2B.save()
        trans_obj.__exit__(None, None, None)
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 200)
        self.mox.VerifyAll()
开发者ID:DragonDM,项目名称:stacktach,代码行数:47,代码来源:test_dbapi.py


示例10: test_send_status_multiple_results

    def test_send_status_multiple_results(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        body_dict = {'send_status': 200}
        body = json.dumps(body_dict)
        fake_request.body = body
        result = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(result)
        exception = models.InstanceExists.MultipleObjectsReturned()
        result.get(message_id=MESSAGE_ID_1).AndRaise(exception)
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, MESSAGE_ID_1)

        self.assertEqual(resp.status_code, 500)
        body = json.loads(resp.content)
        self.assertEqual(body.get("status"), 500)
        msg = "Multiple Exists records with message_id = '%s'"
        msg = msg % MESSAGE_ID_1
        self.assertEqual(body.get("message"), msg)
        self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:21,代码来源:test_dbapi.py


示例11: test_send_status_batch_not_found

    def test_send_status_batch_not_found(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'PUT'
        messages = {
            MESSAGE_ID_1: 200,
        }
        body_dict = {'messages': messages}
        body = json.dumps(body_dict)
        fake_request.body = body
        results = self.mox.CreateMockAnything()
        models.InstanceExists.objects.select_for_update().AndReturn(results)
        exception = models.InstanceExists.DoesNotExist()
        results.get(message_id=MESSAGE_ID_1).AndRaise(exception)
        self.mox.ReplayAll()

        resp = dbapi.exists_send_status(fake_request, 'batch')
        self.assertEqual(resp.status_code, 404)
        body = json.loads(resp.content)
        self.assertEqual(body.get("status"), 404)
        msg = "Could not find Exists record with message_id = '%s'"
        msg = msg % MESSAGE_ID_1
        self.assertEqual(body.get("message"), msg)
        self.mox.VerifyAll()
开发者ID:pperezrubio,项目名称:stacktach,代码行数:23,代码来源:test_dbapi.py



注:本文中的stacktach.dbapi.exists_send_status函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dbapi.get_db_objects函数代码示例发布时间:2022-05-27
下一篇:
Python datetime_to_decimal.dt_to_decimal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap