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

Python dbapi.get_db_objects函数代码示例

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

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



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

示例1: test_list_usage_exists_no_custom_filters

 def test_list_usage_exists_no_custom_filters(self):
     fake_request = self.mox.CreateMockAnything()
     fake_request.GET = {}
     self.mox.StubOutWithMock(dbapi, 'get_db_objects')
     objects = self.mox.CreateMockAnything()
     dbapi.get_db_objects(models.InstanceExists, fake_request, 'id',
                          custom_filters={}).AndReturn(objects)
     self.mox.StubOutWithMock(dbapi, '_convert_model_list')
     dbapi._convert_model_list(objects, dbapi._exists_extra_values)
     self.mox.ReplayAll()
     resp = dbapi.list_usage_exists(fake_request)
     self.assertEqual(resp.status_code, 200)
     self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:13,代码来源:test_dbapi.py


示例2: test_list_usage_exists_with_received_max

 def test_list_usage_exists_with_received_max(self):
     fake_request = self.mox.CreateMockAnything()
     date = str(datetime.datetime.utcnow())
     fake_request.GET = {'received_max': date}
     self.mox.StubOutWithMock(dbapi, 'get_db_objects')
     unix_date = stacktach_utils.str_time_to_unix(date)
     custom_filters = {'received_max': {'raw__when__lte': unix_date}}
     objects = self.mox.CreateMockAnything()
     dbapi.get_db_objects(models.InstanceExists, fake_request, 'id',
                          custom_filters=custom_filters).AndReturn(objects)
     self.mox.StubOutWithMock(dbapi, '_convert_model_list')
     dbapi._convert_model_list(objects, dbapi._exists_extra_values)
     self.mox.ReplayAll()
     resp = dbapi.list_usage_exists(fake_request)
     self.assertEqual(resp.status_code, 200)
     self.mox.VerifyAll()
开发者ID:manalilatkar,项目名称:stacktach,代码行数:16,代码来源:test_dbapi.py


示例3: test_get_db_objects_with_custom_filter

    def test_get_db_objects_with_custom_filter(self):
        fake_model = self.make_fake_model()
        fake_request = self.mox.CreateMockAnything()
        filters = {'instance': INSTANCE_ID_1}
        custom_filters = {'raw': {'raw__id': 1}}
        fake_request.GET = filters
        self.mox.StubOutWithMock(dbapi, '_get_filter_args')
        dbapi._get_filter_args(fake_model, fake_request,
                               custom_filters=custom_filters).AndReturn(filters)
        self.mox.StubOutWithMock(dbapi, '_check_has_field')
        dbapi._check_has_field(fake_model, 'id')
        result = self.mox.CreateMockAnything()
        all_filters = {}
        all_filters.update(filters)
        all_filters.update(custom_filters['raw'])
        fake_model.objects.filter(**all_filters).AndReturn(result)
        result.order_by('-id').AndReturn(result)
        s = slice(None, dbapi.DEFAULT_LIMIT, None)
        result.__getitem__(s).AndReturn(result)
        self.mox.ReplayAll()

        query_result = dbapi.get_db_objects(fake_model, fake_request, 'id',
                                            custom_filters=custom_filters)
        self.assertEquals(query_result, result)

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


示例4: test_list_usage_deletes_for_glance

    def test_list_usage_deletes_for_glance(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'GET'
        fake_request.GET = {}
        self.mox.StubOutWithMock(dbapi, 'get_db_objects')
        mock_objects = self.mox.CreateMockAnything()
        deletes = {'a': 1}
        self.mox.StubOutWithMock(dbapi, '_convert_model_list')
        dbapi._convert_model_list(mock_objects).AndReturn(deletes)
        dbapi.get_db_objects(models.ImageDeletes, fake_request, 'deleted_at').AndReturn(mock_objects)
        self.mox.ReplayAll()

        resp = dbapi.list_usage_deletes_glance(fake_request)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(json.loads(resp.content), {'deletes': deletes})
        self.mox.VerifyAll()
开发者ID:Priyaag,项目名称:stacktach,代码行数:16,代码来源:test_dbapi.py


示例5: test_list_usage_launches_without_service

    def test_list_usage_launches_without_service(self):
        fake_request = self.mox.CreateMockAnything()
        fake_request.method = 'GET'
        fake_request.GET = {}
        self.mox.StubOutWithMock(dbapi, 'get_db_objects')
        mock_objects = self.mox.CreateMockAnything()
        launches = {'a': 1}
        self.mox.StubOutWithMock(dbapi, '_convert_model_list')
        dbapi._convert_model_list(mock_objects).AndReturn(launches)
        dbapi.get_db_objects(models.InstanceUsage, fake_request, 'launched_at').AndReturn(mock_objects)
        self.mox.ReplayAll()

        resp = dbapi.list_usage_launches(fake_request)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(json.loads(resp.content), {'launches': launches})
        self.mox.VerifyAll()
开发者ID:Priyaag,项目名称:stacktach,代码行数:16,代码来源:test_dbapi.py


示例6: test_get_db_objects_offset_and_limit

    def test_get_db_objects_offset_and_limit(self):
        fake_model = self.make_fake_model()
        fake_request = self.mox.CreateMockAnything()
        fake_request.GET = {'offset': 2, 'limit': 2}
        self.mox.StubOutWithMock(dbapi, '_get_filter_args')
        dbapi._get_filter_args(fake_model, fake_request,
                               custom_filters=None).AndReturn({})
        self.mox.StubOutWithMock(dbapi, '_check_has_field')
        dbapi._check_has_field(fake_model, 'id')
        result = self.mox.CreateMockAnything()
        fake_model.objects.all().AndReturn(result)
        result.order_by('-id').AndReturn(result)
        result.__getslice__(2, 4).AndReturn(result)
        self.mox.ReplayAll()

        query_result = dbapi.get_db_objects(fake_model, fake_request, 'id')
        self.assertEquals(query_result, result)

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


示例7: test_get_db_objects_desc

    def test_get_db_objects_desc(self):
        fake_model = self.make_fake_model()
        fake_request = self.mox.CreateMockAnything()
        fake_request.GET = {'direction': 'desc'}
        self.mox.StubOutWithMock(dbapi, '_get_filter_args')
        dbapi._get_filter_args(fake_model, fake_request,
                               custom_filters=None).AndReturn({})
        self.mox.StubOutWithMock(dbapi, '_check_has_field')
        dbapi._check_has_field(fake_model, 'id')
        result = self.mox.CreateMockAnything()
        fake_model.objects.all().AndReturn(result)
        result.order_by('-id').AndReturn(result)
        result.__getitem__(slice(None, None, None)).AndReturn(result)
        self.mox.ReplayAll()

        query_result = dbapi.get_db_objects(fake_model, fake_request, 'id')
        self.assertEquals(query_result, result)

        self.mox.VerifyAll()
开发者ID:AsherBond,项目名称:stacktach,代码行数:19,代码来源:test_dbapi.py


示例8: test_get_db_objects_with_filter

    def test_get_db_objects_with_filter(self):
        fake_model = self.make_fake_model()
        fake_request = self.mox.CreateMockAnything()
        filters = {'instance': INSTANCE_ID_1}
        fake_request.GET = filters
        self.mox.StubOutWithMock(dbapi, '_get_filter_args')
        dbapi._get_filter_args(fake_model, fake_request,
                               custom_filters=None).AndReturn(filters)
        self.mox.StubOutWithMock(dbapi, '_check_has_field')
        dbapi._check_has_field(fake_model, 'id')
        result = self.mox.CreateMockAnything()
        fake_model.objects.filter(**filters).AndReturn(result)
        result.order_by('id').AndReturn(result)
        result.__getitem__(slice(None, None, None)).AndReturn(result)
        self.mox.ReplayAll()

        query_result = dbapi.get_db_objects(fake_model, fake_request, 'id')
        self.assertEquals(query_result, result)

        self.mox.VerifyAll()
开发者ID:AsherBond,项目名称:stacktach,代码行数:20,代码来源:test_dbapi.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python stacklog.get_logger函数代码示例发布时间:2022-05-27
下一篇:
Python dbapi.exists_send_status函数代码示例发布时间: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