'We test the following sequential series of actions:
0. POST /images with public image named Image1
and no custom properties
- Verify 201 returned
1. HEAD image
- Verify HTTP headers have correct information we just added
2. GET image
- Verify all information on image we just added is correct
3. DELETE image1
- Delete the newly added image
4. GET image
- Verify that 404 HTTPNotFound exception is raised'

def test_download_non_exists_image_raises_http_not_found(self):

    self.cleanup()
    self.start_servers(**self.__dict__.copy())
    image_data = ('*' * FIVE_KB)
    headers = minimal_headers('Image1')
    path = ('http://%s:%d/v1/images' % ('127.0.0.1', self.api_port))
    http = httplib2.Http()
    (response, content) = http.request(path, 'POST', headers=headers, body=image_data)
    self.assertEqual(http_client.CREATED, response.status)
    data = jsonutils.loads(content)
    image_id = data['image']['id']
    self.assertEqual(hashlib.md5(image_data).hexdigest(), data['image']['checksum'])
    self.assertEqual(FIVE_KB, data['image']['size'])
    self.assertEqual('Image1', data['image']['name'])
    self.assertTrue(data['image']['is_public'])
    path = ('http://%s:%d/v1/images/%s' % ('127.0.0.1', self.api_port, image_id))
    http = httplib2.Http()
    (response, content) = http.request(path, 'HEAD')
    self.assertEqual(http_client.OK, response.status)
    self.assertEqual('Image1', response['x-image-meta-name'])
    path = ('http://%s:%d/v1/images' % ('127.0.0.1', self.api_port))
    http = httplib2.Http()
    (response, content) = http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    expected_result = {'images': [{'container_format': 'ovf', 'disk_format': 'raw', 'id': image_id, 'name': 'Image1', 'checksum': 'c2e5db72bd7fd153f53ede5da5a06de3', 'size': 5120}]}
    self.assertEqual(expected_result, jsonutils.loads(content))
    path = ('http://%s:%d/v1/images/%s' % ('127.0.0.1', self.api_port, image_id))
    http = httplib2.Http()
    (response, content) = http.request(path, 'DELETE')
    self.assertEqual(http_client.OK, response.status)
    path = ('http://%s:%d/v1/images/%s' % ('127.0.0.1', self.api_port, image_id))
    http = httplib2.Http()
    (response, content) = http.request(path, 'GET')
    self.assertEqual(http_client.NOT_FOUND, response.status)
    self.stop_servers()
