def test_get_server_details_with_limit_and_other_params(self):
req = fakes.HTTPRequest.blank('/fake/servers/detail'
'?limit=3&blah=2:t'
'&sort_key=id1&sort_dir=asc')
res = self.controller.detail(req)
servers = res['servers']
self.assertEqual([fakes.get_fake_uuid(i) for i in range(len(servers))],
[s['id'] for s in servers])
servers_links = res['servers_links']
self.assertEqual('next', servers_links[0]['rel'])
# Retrieve the parameters from the next link, they should contain the
# same limit, filter, and sort information as the original request as
# well as a marker; this ensures that the caller can simply use the
# "next" link and that they do not need to manually insert the limit
# and sort information.
href_parts = urlparse.urlparse(servers_links[0]['href'])
self.assertEqual('/v2/fake/servers/detail', href_parts.path)
params = urlparse.parse_qs(href_parts.query)
expected = {'limit': ['3'], 'blah': ['2:t'],
'sort_key': ['id1'], 'sort_dir': ['asc'],
'marker': [fakes.get_fake_uuid(2)]}
self.assertThat(params, matchers.DictMatches(expected))
test_servers.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录