'Tests that the /images API returns list of
public images sorted alphabetically by name in
ascending order.'

def test_get_index_sort_name_asc(self):

    UUID3 = _gen_uuid()
    extra_fixture = {'id': UUID3, 'status': 'active', 'is_public': True, 'disk_format': 'vhd', 'container_format': 'ovf', 'name': 'asdf', 'size': 19, 'checksum': None}
    db_api.image_create(self.context, extra_fixture)
    UUID4 = _gen_uuid()
    extra_fixture = {'id': UUID4, 'status': 'active', 'is_public': True, 'disk_format': 'vhd', 'container_format': 'ovf', 'name': 'xyz', 'size': 20, 'checksum': None}
    db_api.image_create(self.context, extra_fixture)
    req = webob.Request.blank('/images?sort_key=name&sort_dir=asc')
    res = req.get_response(self.api)
    self.assertEqual(http_client.OK, res.status_int)
    res_dict = jsonutils.loads(res.body)
    images = res_dict['images']
    self.assertEqual(3, len(images))
    self.assertEqual(UUID3, images[0]['id'])
    self.assertEqual(UUID2, images[1]['id'])
    self.assertEqual(UUID4, images[2]['id'])
