当前位置: 首页>>代码示例>>Python>>正文


Python VolumeController.index方法代码示例

本文整理汇总了Python中lunr.api.controller.volume.VolumeController.index方法的典型用法代码示例。如果您正苦于以下问题:Python VolumeController.index方法的具体用法?Python VolumeController.index怎么用?Python VolumeController.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lunr.api.controller.volume.VolumeController的用法示例。


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

示例1: test_index_filtered_by_restore_of

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import index [as 别名]
 def test_index_filtered_by_restore_of(self):
     volume = db.models.Volume(node=None, account=self.account,
                               status='ACTIVE', size=1, restore_of='foo')
     self.db.add(volume)
     self.db.commit()
     self.assertEqual(volume.restore_of, 'foo')
     c = Controller({'account_id': self.account_id, 'id': volume.id},
                    self.mock_app)
     req = Request.blank('?restore_of=foo')
     res = c.index(req)
     self.assertEqual(len(res.body), 1)
     self.assertEqual(res.body[0]['id'], volume.id)
     self.assertEqual(res.body[0]['restore_of'], 'foo')
开发者ID:corystone,项目名称:lunr,代码行数:15,代码来源:test_volume.py

示例2: test_index_name_and_cinder_host

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import index [as 别名]
    def test_index_name_and_cinder_host(self):
        cinder_host = 'somehost'
        name = 'somehostvolume'
        n = db.models.Node('somehostnode', 1000, volume_type=self.vtype,
                           hostname='10.127.0.99', port=8099,
                           cinder_host=cinder_host)
        # Two volumes, same name
        v1 = db.models.Volume(node=self.node0, account=self.account,
                              status='ACTIVE', size=1, name=name)
        v2 = db.models.Volume(node=n, account=self.account,
                              status='ACTIVE', size=1, name=name)
        # One one the right node, different name
        v3 = db.models.Volume(node=n, account=self.account,
                              status='ACTIVE', size=1)
        self.db.add_all([n, v1, v2])
        self.db.commit()

        # Query by name
        c = Controller({'account_id':  self.account_id, 'id': 'test'},
                       self.mock_app)
        req = Request.blank('?name=%s' % name)
        res = c.index(req)
        self.assertEqual(len(res.body), 2)
        vol_ids = (v1.id, v2.id,)
        self.assertEqual((res.body[0]['id'], res.body[1]['id']), vol_ids)

        # Query by cinder_host
        req = Request.blank('?cinder_host=%s' % cinder_host)
        res = c.index(req)
        self.assertEqual(len(res.body), 2)
        vol_ids = (v2.id, v3.id,)
        self.assertEqual((res.body[0]['id'], res.body[1]['id']), vol_ids)

        # Query by both
        req = Request.blank('?cinder_host=%s&name=%s' % (cinder_host, name))
        res = c.index(req)
        self.assertEqual(len(res.body), 1)
        self.assertEqual(res.body[0]['id'], v2.id)
开发者ID:corystone,项目名称:lunr,代码行数:40,代码来源:test_volume.py

示例3: test_index_filtered

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import index [as 别名]
    def test_index_filtered(self):
        c = Controller({'account_id':  self.account_id, 'id': 'test'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)
        c = Controller({'account_id':  self.account_id, 'id': 'test2'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)

        c = Controller({'account_id':  self.account_id}, self.mock_app)
        req = Request.blank('?id=test2')
        res = c.index(req)
        self.assertEqual(len(res.body), 1)
        self.assertEqual(res.body[0]['id'], 'test2')
开发者ID:corystone,项目名称:lunr,代码行数:17,代码来源:test_volume.py

示例4: test_index_populated

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import index [as 别名]
    def test_index_populated(self):
        c = Controller({'account_id':  self.account_id, 'id': 'test'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)
        c = Controller({'account_id':  self.account_id, 'id': 'test2'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)

        c = Controller({'account_id':  self.account_id}, self.mock_app)
        req = Request.blank('')
        res = c.index(req)
        self.assertEqual(len(res.body), 2)
        for v in res.body:
            self.assert_(v['id'].startswith('test'))
开发者ID:corystone,项目名称:lunr,代码行数:18,代码来源:test_volume.py

示例5: test_index_empty

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import index [as 别名]
 def test_index_empty(self):
     c = Controller({'account_id':  self.account_id}, self.mock_app)
     req = Request.blank('')
     res = c.index(req)
     self.assertEqual(res.body, [])
开发者ID:corystone,项目名称:lunr,代码行数:7,代码来源:test_volume.py


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