From 7cba108271fbd8b54ba56055004ef5e505202794 Mon Sep 17 00:00:00 2001 From: Hoisaleshwara Madan V S Date: Tue, 26 Nov 2013 12:43:04 +0530 Subject: [PATCH] Adds delete api test to glance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds api test for v2/images/​{image_id} also moves to negative tests in test_images to test_images_negative ​ Change-Id: Id231ff3325a6a9a1a3eab67fafb2658832170f0c --- tempest/api/image/v2/test_images.py | 40 ++++++++++++-------- tempest/api/image/v2/test_images_negative.py | 11 ++++++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py index 133bae03ad..6408c159af 100644 --- a/tempest/api/image/v2/test_images.py +++ b/tempest/api/image/v2/test_images.py @@ -1,8 +1,8 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2013 OpenStack Foundation +# Copyright 2013 IBM Corp # All Rights Reserved. -# Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -21,27 +21,15 @@ import random from tempest.api.image import base from tempest.common.utils import data_utils -from tempest import exceptions from tempest.test import attr -class CreateRegisterImagesTest(base.BaseV2ImageTest): +class BasicOperationsImagesTest(base.BaseV2ImageTest): """ - Here we test the registration and creation of images + Here we test the basic operations of images """ - @attr(type='gate') - def test_register_with_invalid_container_format(self): - # Negative tests for invalid data supplied to POST /images - self.assertRaises(exceptions.BadRequest, self.client.create_image, - 'test', 'wrong', 'vhd') - - @attr(type='gate') - def test_register_with_invalid_disk_format(self): - self.assertRaises(exceptions.BadRequest, self.client.create_image, - 'test', 'bare', 'wrong') - @attr(type='gate') def test_register_upload_get_image_file(self): @@ -83,6 +71,28 @@ class CreateRegisterImagesTest(base.BaseV2ImageTest): self.assertEqual(200, resp.status) self.assertEqual(file_content, body) + @attr(type='gate') + def test_delete_image(self): + # Deletes a image by image_id + + # Create image + image_name = data_utils.rand_name('image') + resp, body = self.client.create_image(name=image_name, + container_format='bare', + disk_format='raw', + visibility='public') + self.assertEqual(201, resp.status) + image_id = body['id'] + + # Delete Image + self.client.delete_image(image_id) + self.client.wait_for_resource_deletion(image_id) + + # Verifying deletion + resp, images = self.client.image_list() + self.assertEqual(resp.status, 200) + self.assertNotIn(image_id, images) + class ListImagesTest(base.BaseV2ImageTest): diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py index 5bdaa99b6a..1cd6f295de 100644 --- a/tempest/api/image/v2/test_images_negative.py +++ b/tempest/api/image/v2/test_images_negative.py @@ -82,3 +82,14 @@ class ImagesNegativeTest(base.BaseV2ImageTest): image_id = "" self.assertRaises(exceptions.NotFound, self.client.delete_image, image_id) + + @attr(type=['negative', 'gate']) + def test_register_with_invalid_container_format(self): + # Negative tests for invalid data supplied to POST /images + self.assertRaises(exceptions.BadRequest, self.client.create_image, + 'test', 'wrong', 'vhd') + + @attr(type=['negative', 'gate']) + def test_register_with_invalid_disk_format(self): + self.assertRaises(exceptions.BadRequest, self.client.create_image, + 'test', 'bare', 'wrong')