Merge "Return 201 on v2 image create"
This commit is contained in:
commit
2580d3b0f5
|
@ -316,6 +316,7 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
image[key] = timeutils.isotime(value)
|
||||
|
||||
def create(self, response, image):
|
||||
response.status_int = 201
|
||||
response.body = json.dumps(self._format_image(image))
|
||||
response.content_type = 'application/json'
|
||||
response.location = self._get_image_href(image)
|
||||
|
|
|
@ -138,7 +138,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
response, content = http.request(path, 'POST',
|
||||
headers=headers,
|
||||
body=json.dumps(image_entity))
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response.status, 201)
|
||||
data = json.loads(content)
|
||||
image_id = data['id']
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class TestImages(functional.FunctionalTest):
|
|||
headers = self._headers({'content-type': 'application/json'})
|
||||
data = json.dumps({'name': 'image-1', 'type': 'kernel', 'foo': 'bar'})
|
||||
response = requests.post(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(201, response.status_code)
|
||||
image_location_header = response.headers['Location']
|
||||
|
||||
# Returned image entity should have a generated id and status
|
||||
|
@ -202,7 +202,7 @@ class TestImages(functional.FunctionalTest):
|
|||
headers = self._headers({'Content-Type': 'application/json'})
|
||||
data = json.dumps({'name': 'image-1'})
|
||||
response = requests.post(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(201, response.status_code)
|
||||
image_id = json.loads(response.text)['id']
|
||||
|
||||
# TENANT1 should see the image in their list
|
||||
|
@ -295,7 +295,7 @@ class TestImages(functional.FunctionalTest):
|
|||
headers = self._headers({'Content-Type': 'application/json'})
|
||||
data = json.dumps({'name': 'image-1', 'tags': ['sniff', 'sniff']})
|
||||
response = requests.post(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(201, response.status_code)
|
||||
image_id = json.loads(response.text)['id']
|
||||
|
||||
# Image should show a list with a single tag
|
||||
|
@ -384,7 +384,7 @@ class TestImages(functional.FunctionalTest):
|
|||
for fixture in fixtures:
|
||||
data = json.dumps(fixture)
|
||||
response = requests.post(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(201, response.status_code)
|
||||
images.append(json.loads(response.text))
|
||||
|
||||
# Image list should contain 7 images
|
||||
|
@ -474,7 +474,7 @@ class TestImageDirectURLVisibility(functional.FunctionalTest):
|
|||
headers = self._headers({'content-type': 'application/json'})
|
||||
data = json.dumps({'name': 'image-1', 'type': 'kernel', 'foo': 'bar'})
|
||||
response = requests.post(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(201, response.status_code)
|
||||
|
||||
# Get the image id
|
||||
image = json.loads(response.text)
|
||||
|
@ -529,7 +529,7 @@ class TestImageDirectURLVisibility(functional.FunctionalTest):
|
|||
headers = self._headers({'content-type': 'application/json'})
|
||||
data = json.dumps({'name': 'image-1', 'type': 'kernel', 'foo': 'bar'})
|
||||
response = requests.post(path, headers=headers, data=data)
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(201, response.status_code)
|
||||
|
||||
# Get the image id
|
||||
image = json.loads(response.text)
|
||||
|
|
|
@ -817,6 +817,7 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
}
|
||||
response = webob.Response()
|
||||
self.serializer.create(response, self.fixtures[0])
|
||||
self.assertEqual(response.status_int, 201)
|
||||
self.assertEqual(expected, json.loads(response.body))
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(response.location, '/v2/images/%s' % UUID1)
|
||||
|
|
Loading…
Reference in New Issue