From 9012f46fe6899e2b78bee50bfad5f05add9cd2e8 Mon Sep 17 00:00:00 2001 From: Eiichi Aikawa Date: Wed, 5 Mar 2014 16:43:32 +0900 Subject: [PATCH] Prepare for enabling H302 rule(api/image) Currently H302 rule is ignored by tox. However, this rule should be enabled. This patch partially fixes this problem to prepare for H302 rule. Change-Id: Ieb47937ae222e3ccf8d8c630f344a64db8d256ba --- tempest/api/image/v1/test_image_members.py | 8 +++--- .../image/v1/test_image_members_negative.py | 10 +++---- tempest/api/image/v1/test_images_negative.py | 18 ++++++------ tempest/api/image/v2/test_images.py | 28 +++++++++---------- tempest/api/image/v2/test_images_member.py | 10 +++---- .../image/v2/test_images_member_negative.py | 6 ++-- tempest/api/image/v2/test_images_negative.py | 16 +++++------ tempest/api/image/v2/test_images_tags.py | 4 +-- .../api/image/v2/test_images_tags_negative.py | 6 ++-- 9 files changed, 53 insertions(+), 53 deletions(-) diff --git a/tempest/api/image/v1/test_image_members.py b/tempest/api/image/v1/test_image_members.py index e6a078eebd..4cbb62f4fb 100644 --- a/tempest/api/image/v1/test_image_members.py +++ b/tempest/api/image/v1/test_image_members.py @@ -14,12 +14,12 @@ from tempest.api.image import base -from tempest.test import attr +from tempest import test class ImageMembersTest(base.BaseV1ImageMembersTest): - @attr(type='gate') + @test.attr(type='gate') def test_add_image_member(self): image = self._create_image() resp = self.client.add_member(self.alt_tenant_id, image) @@ -33,7 +33,7 @@ class ImageMembersTest(base.BaseV1ImageMembersTest): resp, body = self.alt_img_cli.get_image(image) self.assertEqual(200, resp.status) - @attr(type='gate') + @test.attr(type='gate') def test_get_shared_images(self): image = self._create_image() resp = self.client.add_member(self.alt_tenant_id, image) @@ -48,7 +48,7 @@ class ImageMembersTest(base.BaseV1ImageMembersTest): self.assertIn(share_image, images) self.assertIn(image, images) - @attr(type='gate') + @test.attr(type='gate') def test_remove_member(self): image_id = self._create_image() resp = self.client.add_member(self.alt_tenant_id, image_id) diff --git a/tempest/api/image/v1/test_image_members_negative.py b/tempest/api/image/v1/test_image_members_negative.py index d68ef03e3a..aac63b411d 100644 --- a/tempest/api/image/v1/test_image_members_negative.py +++ b/tempest/api/image/v1/test_image_members_negative.py @@ -16,26 +16,26 @@ from tempest.api.image import base from tempest.common.utils import data_utils from tempest import exceptions -from tempest.test import attr +from tempest import test class ImageMembersNegativeTest(base.BaseV1ImageMembersTest): - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_add_member_with_non_existing_image(self): # Add member with non existing image. non_exist_image = data_utils.rand_uuid() self.assertRaises(exceptions.NotFound, self.client.add_member, self.alt_tenant_id, non_exist_image) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_member_with_non_existing_image(self): # Delete member with non existing image. non_exist_image = data_utils.rand_uuid() self.assertRaises(exceptions.NotFound, self.client.delete_member, self.alt_tenant_id, non_exist_image) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_member_with_non_existing_tenant(self): # Delete member with non existing tenant. image_id = self._create_image() @@ -43,7 +43,7 @@ class ImageMembersNegativeTest(base.BaseV1ImageMembersTest): self.assertRaises(exceptions.NotFound, self.client.delete_member, non_exist_tenant, image_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_get_image_without_membership(self): # Image is hidden from another tenants. image_id = self._create_image() diff --git a/tempest/api/image/v1/test_images_negative.py b/tempest/api/image/v1/test_images_negative.py index 5695884f4f..66556e0fdc 100644 --- a/tempest/api/image/v1/test_images_negative.py +++ b/tempest/api/image/v1/test_images_negative.py @@ -15,30 +15,30 @@ from tempest.api.image import base from tempest import exceptions -from tempest.test import attr +from tempest import test class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest): """Here are negative tests for the deletion and creation of images.""" - @attr(type=['negative', 'gate']) + @test.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']) + @test.attr(type=['negative', 'gate']) def test_register_with_invalid_disk_format(self): self.assertRaises(exceptions.BadRequest, self.client.create_image, 'test', 'bare', 'wrong') - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_image_with_invalid_image_id(self): # An image should not be deleted with invalid image id self.assertRaises(exceptions.NotFound, self.client.delete_image, '!@$%^&*()') - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_non_existent_image(self): # Return an error while trying to delete a non-existent image @@ -46,24 +46,24 @@ class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest): self.assertRaises(exceptions.NotFound, self.client.delete_image, non_existent_image_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_image_blank_id(self): # Return an error while trying to delete an image with blank Id self.assertRaises(exceptions.NotFound, self.client.delete_image, '') - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_image_non_hex_string_id(self): # Return an error while trying to delete an image with non hex id image_id = '11a22b9-120q-5555-cc11-00ab112223gj' self.assertRaises(exceptions.NotFound, self.client.delete_image, image_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_image_negative_image_id(self): # Return an error while trying to delete an image with negative id self.assertRaises(exceptions.NotFound, self.client.delete_image, -1) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_image_id_is_over_35_character_limit(self): # Return an error while trying to delete image with id over limit self.assertRaises(exceptions.NotFound, self.client.delete_image, diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py index d448c01ce0..ce11911e24 100644 --- a/tempest/api/image/v2/test_images.py +++ b/tempest/api/image/v2/test_images.py @@ -19,7 +19,7 @@ import random from tempest.api.image import base from tempest.common.utils import data_utils -from tempest.test import attr +from tempest import test class BasicOperationsImagesTest(base.BaseV2ImageTest): @@ -27,7 +27,7 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): Here we test the basic operations of images """ - @attr(type='gate') + @test.attr(type='gate') def test_register_upload_get_image_file(self): """ @@ -68,7 +68,7 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): self.assertEqual(200, resp.status) self.assertEqual(file_content, body) - @attr(type='gate') + @test.attr(type='gate') def test_delete_image(self): # Deletes an image by image_id @@ -90,7 +90,7 @@ class BasicOperationsImagesTest(base.BaseV2ImageTest): self.assertEqual(resp.status, 200) self.assertNotIn(image_id, images) - @attr(type='gate') + @test.attr(type='gate') def test_update_image(self): # Updates an image by image_id @@ -176,7 +176,7 @@ class ListImagesTest(base.BaseV2ImageTest): msg = "Failed to list images by %s" % key self.assertEqual(params[key], image[key], msg) - @attr(type='gate') + @test.attr(type='gate') def test_index_no_params(self): # Simple test to see all fixture images returned resp, images_list = self.client.image_list() @@ -186,25 +186,25 @@ class ListImagesTest(base.BaseV2ImageTest): for image in self.created_images: self.assertIn(image, image_list) - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_container_format(self): # Test to get all images with container_format='bare' params = {"container_format": "bare"} self._list_by_param_value_and_assert(params) - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_disk_format(self): # Test to get all images with disk_format = raw params = {"disk_format": "raw"} self._list_by_param_value_and_assert(params) - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_visibility(self): # Test to get all images with visibility = public params = {"visibility": "public"} self._list_by_param_value_and_assert(params) - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_size(self): # Test to get all images by size image_id = self.created_images[1] @@ -215,7 +215,7 @@ class ListImagesTest(base.BaseV2ImageTest): params = {"size": image['size']} self._list_by_param_value_and_assert(params) - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_min_max_size(self): # Test to get all images with size between 2000 to 3000 image_id = self.created_images[1] @@ -234,13 +234,13 @@ class ListImagesTest(base.BaseV2ImageTest): image_size <= params['size_max'], "Failed to get images by size_min and size_max") - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_status(self): # Test to get all active images params = {"status": "active"} self._list_by_param_value_and_assert(params) - @attr(type='gate') + @test.attr(type='gate') def test_list_images_param_limit(self): # Test to get images by limit params = {"limit": 2} @@ -250,7 +250,7 @@ class ListImagesTest(base.BaseV2ImageTest): self.assertEqual(len(images_list), params['limit'], "Failed to get images by limit") - @attr(type='gate') + @test.attr(type='gate') def test_get_image_schema(self): # Test to get image schema schema = "image" @@ -258,7 +258,7 @@ class ListImagesTest(base.BaseV2ImageTest): self.assertEqual(200, resp.status) self.assertEqual("image", body['name']) - @attr(type='gate') + @test.attr(type='gate') def test_get_images_schema(self): # Test to get images schema schema = "images" diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py index 530262f2cf..e6c5b610be 100644 --- a/tempest/api/image/v2/test_images_member.py +++ b/tempest/api/image/v2/test_images_member.py @@ -11,13 +11,13 @@ # under the License. from tempest.api.image import base -from tempest.test import attr +from tempest import test class ImagesMemberTest(base.BaseV2MemberImageTest): _interface = 'json' - @attr(type='gate') + @test.attr(type='gate') def test_image_share_accept(self): image_id = self._create_image() resp, member = self.os_img_client.add_member(image_id, @@ -40,7 +40,7 @@ class ImagesMemberTest(base.BaseV2MemberImageTest): self.assertEqual(member['image_id'], image_id) self.assertEqual(member['status'], 'accepted') - @attr(type='gate') + @test.attr(type='gate') def test_image_share_reject(self): image_id = self._create_image() resp, member = self.os_img_client.add_member(image_id, @@ -56,7 +56,7 @@ class ImagesMemberTest(base.BaseV2MemberImageTest): self.assertEqual(200, resp.status) self.assertNotIn(image_id, self._list_image_ids_as_alt()) - @attr(type='gate') + @test.attr(type='gate') def test_get_image_member(self): image_id = self._create_image() self.os_img_client.add_member(image_id, @@ -73,7 +73,7 @@ class ImagesMemberTest(base.BaseV2MemberImageTest): self.assertEqual(image_id, member['image_id']) self.assertEqual('accepted', member['status']) - @attr(type='gate') + @test.attr(type='gate') def test_remove_image_member(self): image_id = self._create_image() self.os_img_client.add_member(image_id, diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py index 4c7cc5a534..98ef649193 100644 --- a/tempest/api/image/v2/test_images_member_negative.py +++ b/tempest/api/image/v2/test_images_member_negative.py @@ -12,13 +12,13 @@ from tempest.api.image import base from tempest import exceptions -from tempest.test import attr +from tempest import test class ImagesMemberNegativeTest(base.BaseV2MemberImageTest): _interface = 'json' - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_image_share_invalid_status(self): image_id = self._create_image() resp, member = self.os_img_client.add_member(image_id, @@ -28,7 +28,7 @@ class ImagesMemberNegativeTest(base.BaseV2MemberImageTest): self.alt_img_client.update_member_status, image_id, self.alt_tenant_id, 'notavalidstatus') - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_image_share_owner_cannot_accept(self): image_id = self._create_image() resp, member = self.os_img_client.add_member(image_id, diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py index b8ba868135..27ba39c51f 100644 --- a/tempest/api/image/v2/test_images_negative.py +++ b/tempest/api/image/v2/test_images_negative.py @@ -18,7 +18,7 @@ import uuid from tempest.api.image import base from tempest import exceptions -from tempest.test import attr +from tempest import test class ImagesNegativeTest(base.BaseV2ImageTest): @@ -35,20 +35,20 @@ class ImagesNegativeTest(base.BaseV2ImageTest): ** delete the deleted image """ - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_get_non_existent_image(self): # get the non-existent image non_existent_id = str(uuid.uuid4()) self.assertRaises(exceptions.NotFound, self.client.get_image, non_existent_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_get_image_null_id(self): # get image with image_id = NULL image_id = "" self.assertRaises(exceptions.NotFound, self.client.get_image, image_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_get_delete_deleted_image(self): # get and delete the deleted image # create and delete image @@ -67,27 +67,27 @@ class ImagesNegativeTest(base.BaseV2ImageTest): self.assertRaises(exceptions.NotFound, self.client.delete_image, image_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_non_existing_image(self): # delete non-existent image non_existent_image_id = str(uuid.uuid4()) self.assertRaises(exceptions.NotFound, self.client.delete_image, non_existent_image_id) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_image_null_id(self): # delete image with image_id=NULL image_id = "" self.assertRaises(exceptions.NotFound, self.client.delete_image, image_id) - @attr(type=['negative', 'gate']) + @test.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']) + @test.attr(type=['negative', 'gate']) def test_register_with_invalid_disk_format(self): self.assertRaises(exceptions.BadRequest, self.client.create_image, 'test', 'bare', 'wrong') diff --git a/tempest/api/image/v2/test_images_tags.py b/tempest/api/image/v2/test_images_tags.py index f0e343d9b2..504c0e8d98 100644 --- a/tempest/api/image/v2/test_images_tags.py +++ b/tempest/api/image/v2/test_images_tags.py @@ -14,12 +14,12 @@ from tempest.api.image import base from tempest.common.utils import data_utils -from tempest.test import attr +from tempest import test class ImagesTagsTest(base.BaseV2ImageTest): - @attr(type='gate') + @test.attr(type='gate') def test_update_delete_tags_for_image(self): resp, body = self.create_image(container_format='bare', disk_format='raw', diff --git a/tempest/api/image/v2/test_images_tags_negative.py b/tempest/api/image/v2/test_images_tags_negative.py index 0628d297ae..3233db7993 100644 --- a/tempest/api/image/v2/test_images_tags_negative.py +++ b/tempest/api/image/v2/test_images_tags_negative.py @@ -17,12 +17,12 @@ import uuid from tempest.api.image import base from tempest.common.utils import data_utils from tempest import exceptions -from tempest.test import attr +from tempest import test class ImagesTagsNegativeTest(base.BaseV2ImageTest): - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_update_tags_for_non_existing_image(self): # Update tag with non existing image. tag = data_utils.rand_name('tag-') @@ -30,7 +30,7 @@ class ImagesTagsNegativeTest(base.BaseV2ImageTest): self.assertRaises(exceptions.NotFound, self.client.add_image_tag, non_exist_image, tag) - @attr(type=['negative', 'gate']) + @test.attr(type=['negative', 'gate']) def test_delete_non_existing_tag(self): # Delete non existing tag. resp, body = self.create_image(container_format='bare',