def test_get_flavor_with_limit(self): req = fakes.HTTPRequestV3.blank('/flavors?limit=2') response = self.controller.index(req) response_list = response["flavors"] response_links = response["flavors_links"] expected_flavors = [ { "id": "1", "name": "flavor 1", "links": [ { "rel": "self", "href": "http://localhost/v3/flavors/1", }, { "rel": "bookmark", "href": "http://localhost/flavors/1", }, ], }, { "id": "2", "name": "flavor 2", "links": [ { "rel": "self", "href": "http://localhost/v3/flavors/2", }, { "rel": "bookmark", "href": "http://localhost/flavors/2", }, ], } ] self.assertEqual(response_list, expected_flavors) self.assertEqual(response_links[0]['rel'], 'next') href_parts = urlparse.urlparse(response_links[0]['href']) self.assertEqual('/v3/flavors', href_parts.path) params = urlparse.parse_qs(href_parts.query) self.assertThat({'limit': ['2'], 'marker': ['2']}, matchers.DictMatches(params))
def test_get_image(self, get_mocked): request = fakes.HTTPRequest.blank('/v2/fake/images/123') actual_image = self.controller.show(request, '123') self.assertThat(actual_image, matchers.DictMatches(self.expected_image_123)) get_mocked.assert_called_once_with(mock.ANY, '123')