Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2013 OpenStack Foundation |
| 4 | # All Rights Reserved. |
| 5 | # Copyright 2013 IBM Corp. |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | # not use this file except in compliance with the License. You may obtain |
| 9 | # a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 16 | # License for the specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | |
| 19 | import uuid |
| 20 | |
| 21 | from tempest.api.image import base |
| 22 | from tempest import exceptions |
| 23 | from tempest.test import attr |
| 24 | |
| 25 | |
| 26 | class ImagesNegativeTest(base.BaseV2ImageTest): |
| 27 | |
| 28 | """ |
| 29 | here we have -ve tests for get_image and delete_image api |
| 30 | |
| 31 | Tests |
| 32 | ** get non-existent image |
| 33 | ** get image with image_id=NULL |
| 34 | ** get the deleted image |
| 35 | ** delete non-existent image |
| 36 | ** delete rimage with image_id=NULL |
| 37 | ** delete the deleted image |
| 38 | """ |
| 39 | |
| 40 | @attr(type=['negative', 'gate']) |
| 41 | def test_get_non_existent_image(self): |
| 42 | # get the non-existent image |
| 43 | non_existent_id = str(uuid.uuid4()) |
| 44 | self.assertRaises(exceptions.NotFound, self.client.get_image, |
| 45 | non_existent_id) |
| 46 | |
| 47 | @attr(type=['negative', 'gate']) |
| 48 | def test_get_image_null_id(self): |
| 49 | # get image with image_id = NULL |
| 50 | image_id = "" |
| 51 | self.assertRaises(exceptions.NotFound, self.client.get_image, image_id) |
| 52 | |
| 53 | @attr(type=['negative', 'gate']) |
| 54 | def test_get_delete_deleted_image(self): |
| 55 | # get and delete the deleted image |
| 56 | # create and delete image |
| 57 | resp, body = self.client.create_image(name='test', |
| 58 | container_format='bare', |
| 59 | disk_format='raw') |
| 60 | image_id = body['id'] |
| 61 | self.assertEqual(201, resp.status) |
| 62 | self.client.delete_image(image_id) |
| 63 | self.client.wait_for_resource_deletion(image_id) |
| 64 | |
| 65 | # get the deleted image |
| 66 | self.assertRaises(exceptions.NotFound, self.client.get_image, image_id) |
| 67 | |
| 68 | # delete the deleted image |
| 69 | self.assertRaises(exceptions.NotFound, self.client.delete_image, |
| 70 | image_id) |
| 71 | |
| 72 | @attr(type=['negative', 'gate']) |
| 73 | def test_delete_non_existing_image(self): |
| 74 | # delete non-existent image |
| 75 | non_existent_image_id = str(uuid.uuid4()) |
| 76 | self.assertRaises(exceptions.NotFound, self.client.delete_image, |
| 77 | non_existent_image_id) |
| 78 | |
| 79 | @attr(type=['negative', 'gate']) |
| 80 | def test_delete_image_null_id(self): |
| 81 | # delete image with image_id=NULL |
| 82 | image_id = "" |
| 83 | self.assertRaises(exceptions.NotFound, self.client.delete_image, |
| 84 | image_id) |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 85 | |
| 86 | @attr(type=['negative', 'gate']) |
| 87 | def test_register_with_invalid_container_format(self): |
| 88 | # Negative tests for invalid data supplied to POST /images |
| 89 | self.assertRaises(exceptions.BadRequest, self.client.create_image, |
| 90 | 'test', 'wrong', 'vhd') |
| 91 | |
| 92 | @attr(type=['negative', 'gate']) |
| 93 | def test_register_with_invalid_disk_format(self): |
| 94 | self.assertRaises(exceptions.BadRequest, self.client.create_image, |
| 95 | 'test', 'bare', 'wrong') |