本文整理汇总了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')
示例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)
示例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')
示例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'))
示例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, [])