Add pep8 check to use data_utils.rand_uuid()
There is a common method for generating random uuid value. So it is nice to avoid pointing it out on human review to reduce reviewing workload. In addition, this patch removes str() around the method calls because str() is called in the method. Change-Id: Ic8caea352d27c479fdb765a699d277b59f1c5bb4
This commit is contained in:
parent
326bbb4884
commit
d079c8925d
@ -20,6 +20,7 @@ Tempest Specific Commandments
|
||||
- [T110] Check that service client names of GET should be consistent
|
||||
- [T111] Check that service client names of DELETE should be consistent
|
||||
- [T112] Check that tempest.lib should not import local tempest code
|
||||
- [T113] Check that tests use data_utils.rand_uuid() instead of uuid.uuid4()
|
||||
- [N322] Method's default argument shouldn't be mutable
|
||||
|
||||
Test Data/Configuration
|
||||
|
@ -37,7 +37,7 @@ class TestPortsNegative(base.BaseBaremetalTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('30277ee8-0c60-4f1d-b125-0e51c2f43369')
|
||||
def test_create_port_nonexsistent_node_id(self):
|
||||
node_id = str(data_utils.rand_uuid())
|
||||
node_id = data_utils.rand_uuid()
|
||||
address = data_utils.rand_mac_address()
|
||||
self.assertRaises(lib_exc.BadRequest, self.create_port,
|
||||
node_id=node_id, address=address)
|
||||
|
@ -91,7 +91,7 @@ class FlavorsAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
@test.idempotent_id('94c9bb4e-2c2a-4f3c-bb1f-5f0daf918e6d')
|
||||
def test_create_flavor_with_uuid_id(self):
|
||||
flavor_id = str(uuid.uuid4())
|
||||
flavor_id = data_utils.rand_uuid()
|
||||
new_flavor_id = self._create_flavor(flavor_id)
|
||||
self.assertEqual(new_flavor_id, flavor_id)
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.compute import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -145,4 +143,4 @@ class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.remove_flavor_access,
|
||||
new_flavor['id'],
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.compute import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -38,7 +36,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('c136086a-0f67-4b2b-bc61-8482bd68989f')
|
||||
def test_show_nonexistent_hypervisor(self):
|
||||
nonexistent_hypervisor_id = str(uuid.uuid4())
|
||||
nonexistent_hypervisor_id = data_utils.rand_uuid()
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
@ -70,7 +68,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('02463d69-0ace-4d33-a4a8-93d7883a2bba')
|
||||
def test_show_servers_with_nonexistent_hypervisor(self):
|
||||
nonexistent_hypervisor_id = str(uuid.uuid4())
|
||||
nonexistent_hypervisor_id = data_utils.rand_uuid()
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
@ -87,7 +85,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('f60aa680-9a3a-4c7d-90e1-fae3a4891303')
|
||||
def test_get_nonexistent_hypervisor_uptime(self):
|
||||
nonexistent_hypervisor_id = str(uuid.uuid4())
|
||||
nonexistent_hypervisor_id = data_utils.rand_uuid()
|
||||
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import testtools
|
||||
|
||||
from tempest.api.compute import base
|
||||
@ -147,7 +145,7 @@ class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
# migrate a non existent server
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.migrate_server,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.idempotent_id('b0b17f83-d14e-4fc4-8f31-bcc9f3cfa629')
|
||||
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.compute.floating_ips import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest import config
|
||||
@ -47,7 +45,7 @@ class FloatingIPsNegativeTestJSON(base.BaseFloatingIPsTest):
|
||||
while True:
|
||||
cls.non_exist_id = data_utils.rand_int_id(start=999)
|
||||
if CONF.service_available.neutron:
|
||||
cls.non_exist_id = str(uuid.uuid4())
|
||||
cls.non_exist_id = data_utils.rand_uuid()
|
||||
if cls.non_exist_id not in cls.floating_ip_ids:
|
||||
break
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.compute import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest import config
|
||||
@ -39,7 +37,7 @@ class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
|
||||
# of non-existent floating IP
|
||||
# Creating a non-existent floatingIP id
|
||||
if CONF.service_available.neutron:
|
||||
non_exist_id = str(uuid.uuid4())
|
||||
non_exist_id = data_utils.rand_uuid()
|
||||
else:
|
||||
non_exist_id = data_utils.rand_int_id(start=999)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
|
@ -13,9 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.compute import base
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
@ -39,7 +38,7 @@ class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest):
|
||||
def test_list_virtual_interfaces_invalid_server_id(self):
|
||||
# Negative test: Should not be able to GET virtual interfaces
|
||||
# for an invalid server_id
|
||||
invalid_server_id = str(uuid.uuid4())
|
||||
invalid_server_id = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.list_virtual_interfaces,
|
||||
invalid_server_id)
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.compute import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest import config
|
||||
@ -45,7 +43,7 @@ class VolumesNegativeTest(base.BaseV2ComputeTest):
|
||||
# Creating a nonexistent volume id
|
||||
# Trying to GET a non existent volume
|
||||
self.assertRaises(lib_exc.NotFound, self.client.show_volume,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('54a34226-d910-4b00-9ef8-8683e6c55846')
|
||||
@ -54,7 +52,7 @@ class VolumesNegativeTest(base.BaseV2ComputeTest):
|
||||
# Creating nonexistent volume id
|
||||
# Trying to DELETE a non existent volume
|
||||
self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('5125ae14-152b-40a7-b3c5-eae15e9022ef')
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.identity import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -115,7 +113,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
@test.idempotent_id('38373691-8551-453a-b074-4260ad8298ef')
|
||||
def test_delete_role_non_existent(self):
|
||||
# Attempt to delete a non existent role should fail
|
||||
non_existent_role = str(uuid.uuid4().hex)
|
||||
non_existent_role = data_utils.rand_uuid_hex()
|
||||
self.assertRaises(lib_exc.NotFound, self.roles_client.delete_role,
|
||||
non_existent_role)
|
||||
|
||||
@ -146,7 +144,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
def test_assign_user_role_for_non_existent_role(self):
|
||||
# Attempt to assign a non existent role to user should fail
|
||||
(user, tenant, role) = self._get_role_params()
|
||||
non_existent_role = str(uuid.uuid4().hex)
|
||||
non_existent_role = data_utils.rand_uuid_hex()
|
||||
self.assertRaises(lib_exc.NotFound, self.roles_client.assign_user_role,
|
||||
tenant['id'], user['id'], non_existent_role)
|
||||
|
||||
@ -155,7 +153,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
def test_assign_user_role_for_non_existent_tenant(self):
|
||||
# Attempt to assign a role on a non existent tenant should fail
|
||||
(user, tenant, role) = self._get_role_params()
|
||||
non_existent_tenant = str(uuid.uuid4().hex)
|
||||
non_existent_tenant = data_utils.rand_uuid_hex()
|
||||
self.assertRaises(lib_exc.NotFound, self.roles_client.assign_user_role,
|
||||
non_existent_tenant, user['id'], role['id'])
|
||||
|
||||
@ -205,7 +203,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
self.roles_client.assign_user_role(tenant['id'],
|
||||
user['id'],
|
||||
role['id'])
|
||||
non_existent_role = str(uuid.uuid4().hex)
|
||||
non_existent_role = data_utils.rand_uuid_hex()
|
||||
self.assertRaises(lib_exc.NotFound, self.roles_client.delete_user_role,
|
||||
tenant['id'], user['id'], non_existent_role)
|
||||
|
||||
@ -217,7 +215,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
self.roles_client.assign_user_role(tenant['id'],
|
||||
user['id'],
|
||||
role['id'])
|
||||
non_existent_tenant = str(uuid.uuid4().hex)
|
||||
non_existent_tenant = data_utils.rand_uuid_hex()
|
||||
self.assertRaises(lib_exc.NotFound, self.roles_client.delete_user_role,
|
||||
non_existent_tenant, user['id'], role['id'])
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.identity import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -70,7 +68,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
def test_delete_non_existent_tenant(self):
|
||||
# Attempt to delete a non existent tenant should fail
|
||||
self.assertRaises(lib_exc.NotFound, self.tenants_client.delete_tenant,
|
||||
str(uuid.uuid4().hex))
|
||||
data_utils.rand_uuid_hex())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('af16f44b-a849-46cb-9f13-a751c388f739')
|
||||
@ -130,7 +128,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
def test_update_non_existent_tenant(self):
|
||||
# Attempt to update a non existent tenant should fail
|
||||
self.assertRaises(lib_exc.NotFound, self.tenants_client.update_tenant,
|
||||
str(uuid.uuid4().hex))
|
||||
data_utils.rand_uuid_hex())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('41704dc5-c5f7-4f79-abfa-76e6fedc570b')
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.identity import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -108,7 +106,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
|
||||
def test_update_user_for_non_existent_user(self):
|
||||
# Attempt to update a user non-existent user should fail
|
||||
user_name = data_utils.rand_name('user')
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound, self.users_client.update_user,
|
||||
non_existent_id, name=user_name)
|
||||
|
||||
|
@ -14,9 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.image import base
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
@ -38,7 +37,7 @@ class ImagesNegativeTest(base.BaseV2ImageTest):
|
||||
@test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81d9f')
|
||||
def test_get_non_existent_image(self):
|
||||
# get the non-existent image
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound, self.client.show_image,
|
||||
non_existent_id)
|
||||
|
||||
@ -72,7 +71,7 @@ class ImagesNegativeTest(base.BaseV2ImageTest):
|
||||
@test.idempotent_id('6fe40f1c-57bd-4918-89cc-8500f850f3de')
|
||||
def test_delete_non_existing_image(self):
|
||||
# delete non-existent image
|
||||
non_existent_image_id = str(uuid.uuid4())
|
||||
non_existent_image_id = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound, self.client.delete_image,
|
||||
non_existent_image_id)
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.image import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -27,7 +25,7 @@ class ImagesTagsNegativeTest(base.BaseV2ImageTest):
|
||||
def test_update_tags_for_non_existing_image(self):
|
||||
# Update tag with non existing image.
|
||||
tag = data_utils.rand_name('tag')
|
||||
non_exist_image = str(uuid.uuid4())
|
||||
non_exist_image = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound, self.client.add_image_tag,
|
||||
non_exist_image, tag)
|
||||
|
||||
|
@ -13,10 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.network import base_security_groups as base
|
||||
from tempest import config
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
@ -36,7 +35,7 @@ class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('424fd5c3-9ddc-486a-b45f-39bf0c820fc6')
|
||||
def test_show_non_existent_security_group(self):
|
||||
non_exist_id = str(uuid.uuid4())
|
||||
non_exist_id = data_utils.rand_uuid()
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound, self.security_groups_client.show_security_group,
|
||||
non_exist_id)
|
||||
@ -44,7 +43,7 @@ class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('4c094c09-000b-4e41-8100-9617600c02a6')
|
||||
def test_show_non_existent_security_group_rule(self):
|
||||
non_exist_id = str(uuid.uuid4())
|
||||
non_exist_id = data_utils.rand_uuid()
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.security_group_rules_client.show_security_group_rule,
|
||||
@ -53,7 +52,7 @@ class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('1f1bb89d-5664-4956-9fcd-83ee0fa603df')
|
||||
def test_delete_non_existent_security_group(self):
|
||||
non_exist_id = str(uuid.uuid4())
|
||||
non_exist_id = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.security_groups_client.delete_security_group,
|
||||
non_exist_id
|
||||
@ -91,7 +90,7 @@ class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
@test.idempotent_id('4bf786fd-2f02-443c-9716-5b98e159a49a')
|
||||
def test_create_security_group_rule_with_non_existent_remote_groupid(self):
|
||||
group_create_body, _ = self._create_security_group()
|
||||
non_exist_id = str(uuid.uuid4())
|
||||
non_exist_id = data_utils.rand_uuid()
|
||||
|
||||
# Create rule with non existent remote_group_id
|
||||
group_ids = ['bad_group_id', non_exist_id]
|
||||
@ -204,7 +203,7 @@ class NegativeSecGroupTest(base.BaseSecGroupTest):
|
||||
@test.idempotent_id('be308db6-a7cf-4d5c-9baf-71bafd73f35e')
|
||||
def test_create_security_group_rule_with_non_existent_security_group(self):
|
||||
# Create security group rules with not existing security group.
|
||||
non_existent_sg = str(uuid.uuid4())
|
||||
non_existent_sg = data_utils.rand_uuid()
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.security_group_rules_client.create_security_group_rule,
|
||||
|
@ -17,8 +17,6 @@ from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
import uuid
|
||||
|
||||
|
||||
class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest):
|
||||
"""Negative tests for show_alarm, update_alarm, show_alarm_history tests
|
||||
@ -33,7 +31,7 @@ class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest):
|
||||
@test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81e7d')
|
||||
def test_get_non_existent_alarm(self):
|
||||
# get the non-existent alarm
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = data_utils.rand_uuid()
|
||||
self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
|
||||
non_existent_id)
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.volume import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@ -53,7 +51,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
self.assertRaises(
|
||||
lib_exc.BadRequest,
|
||||
self.volume_types_client.update_volume_type_extra_specs,
|
||||
self.volume_type['id'], str(uuid.uuid4()),
|
||||
self.volume_type['id'], data_utils.rand_uuid(),
|
||||
extra_spec)
|
||||
|
||||
@test.idempotent_id('9bf7a657-b011-4aec-866d-81c496fbe5c8')
|
||||
@ -84,7 +82,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.volume_types_client.create_volume_type_extra_specs,
|
||||
str(uuid.uuid4()), extra_specs)
|
||||
data_utils.rand_uuid(), extra_specs)
|
||||
|
||||
@test.idempotent_id('c821bdc8-43a4-4bf4-86c8-82f3858d5f7d')
|
||||
def test_create_none_body(self):
|
||||
@ -110,7 +108,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.volume_types_client.delete_volume_type_extra_specs,
|
||||
str(uuid.uuid4()), extra_specs.keys()[0])
|
||||
data_utils.rand_uuid(), extra_specs.keys()[0])
|
||||
|
||||
@test.idempotent_id('dee5cf0c-cdd6-4353-b70c-e847050d71fb')
|
||||
def test_list_nonexistent_volume_type_id(self):
|
||||
@ -118,7 +116,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.volume_types_client.list_volume_types_extra_specs,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.idempotent_id('9f402cbd-1838-4eb4-9554-126a6b1908c9')
|
||||
def test_get_nonexistent_volume_type_id(self):
|
||||
@ -127,7 +125,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.volume_types_client.show_volume_type_extra_specs,
|
||||
str(uuid.uuid4()), extra_specs.keys()[0])
|
||||
data_utils.rand_uuid(), extra_specs.keys()[0])
|
||||
|
||||
@test.idempotent_id('c881797d-12ff-4f1a-b09d-9f6212159753')
|
||||
def test_get_nonexistent_extra_spec_id(self):
|
||||
@ -136,7 +134,7 @@ class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
self.assertRaises(
|
||||
lib_exc.NotFound,
|
||||
self.volume_types_client.show_volume_type_extra_specs,
|
||||
self.volume_type['id'], str(uuid.uuid4()))
|
||||
self.volume_type['id'], data_utils.rand_uuid())
|
||||
|
||||
|
||||
class ExtraSpecsNegativeV1Test(ExtraSpecsNegativeV2Test):
|
||||
|
@ -13,9 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.volume import base
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
@ -26,8 +25,8 @@ class VolumeTypesNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
def test_create_with_nonexistent_volume_type(self):
|
||||
# Should not be able to create volume with nonexistent volume_type.
|
||||
self.name_field = self.special_fields['name_field']
|
||||
params = {self.name_field: str(uuid.uuid4()),
|
||||
'volume_type': str(uuid.uuid4())}
|
||||
params = {self.name_field: data_utils.rand_uuid(),
|
||||
'volume_type': data_utils.rand_uuid()}
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.volumes_client.create_volume, **params)
|
||||
|
||||
@ -42,14 +41,14 @@ class VolumeTypesNegativeV2Test(base.BaseVolumeAdminTest):
|
||||
# Should not be able to get volume type with nonexistent type id.
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.volume_types_client.show_volume_type,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.idempotent_id('6b3926d2-7d73-4896-bc3d-e42dfd11a9f6')
|
||||
def test_delete_nonexistent_type_id(self):
|
||||
# Should not be able to delete volume type with nonexistent type id.
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.volume_types_client.delete_volume_type,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
|
||||
class VolumeTypesNegativeV1Test(VolumeTypesNegativeV2Test):
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.volume import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.common import waiters
|
||||
@ -44,14 +42,14 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
def test_volume_get_nonexistent_volume_id(self):
|
||||
# Should not be able to get a non-existent volume
|
||||
self.assertRaises(lib_exc.NotFound, self.client.show_volume,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('555efa6e-efcd-44ef-8a3b-4a7ca4837a29')
|
||||
def test_volume_delete_nonexistent_volume_id(self):
|
||||
# Should not be able to delete a non-existent Volume
|
||||
self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('1ed83a8a-682d-4dfb-a30e-ee63ffd6c049')
|
||||
@ -98,7 +96,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
v_name = data_utils.rand_name('Volume')
|
||||
metadata = {'Type': 'work'}
|
||||
self.assertRaises(lib_exc.NotFound, self.client.create_volume,
|
||||
size='1', volume_type=str(uuid.uuid4()),
|
||||
size='1', volume_type=data_utils.rand_uuid(),
|
||||
display_name=v_name, metadata=metadata)
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@ -108,7 +106,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
v_name = data_utils.rand_name('Volume')
|
||||
metadata = {'Type': 'work'}
|
||||
self.assertRaises(lib_exc.NotFound, self.client.create_volume,
|
||||
size='1', snapshot_id=str(uuid.uuid4()),
|
||||
size='1', snapshot_id=data_utils.rand_uuid(),
|
||||
display_name=v_name, metadata=metadata)
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@ -118,7 +116,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
v_name = data_utils.rand_name('Volume')
|
||||
metadata = {'Type': 'work'}
|
||||
self.assertRaises(lib_exc.NotFound, self.client.create_volume,
|
||||
size='1', source_volid=str(uuid.uuid4()),
|
||||
size='1', source_volid=data_utils.rand_uuid(),
|
||||
display_name=v_name, metadata=metadata)
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@ -127,7 +125,8 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
v_name = data_utils.rand_name('Volume')
|
||||
metadata = {'Type': 'work'}
|
||||
self.assertRaises(lib_exc.NotFound, self.client.update_volume,
|
||||
volume_id=str(uuid.uuid4()), display_name=v_name,
|
||||
volume_id=data_utils.rand_uuid(),
|
||||
display_name=v_name,
|
||||
metadata=metadata)
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@ -188,7 +187,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.attach_volume,
|
||||
str(uuid.uuid4()),
|
||||
data_utils.rand_uuid(),
|
||||
instance_uuid=server['id'],
|
||||
mountpoint=self.mountpoint)
|
||||
|
||||
@ -229,7 +228,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
# Extend volume size when volume is nonexistent.
|
||||
extend_size = int(self.volume['size']) + 1
|
||||
self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
|
||||
str(uuid.uuid4()), new_size=extend_size)
|
||||
data_utils.rand_uuid(), new_size=extend_size)
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115')
|
||||
@ -244,14 +243,14 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||
def test_reserve_volume_with_nonexistent_volume_id(self):
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.reserve_volume,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c')
|
||||
def test_unreserve_volume_with_nonexistent_volume_id(self):
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.unreserve_volume,
|
||||
str(uuid.uuid4()))
|
||||
data_utils.rand_uuid())
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c')
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from tempest.api.volume import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest import config
|
||||
@ -36,7 +34,8 @@ class VolumesV2SnapshotNegativeTestJSON(base.BaseVolumeTest):
|
||||
s_name = data_utils.rand_name('snap')
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.snapshots_client.create_snapshot,
|
||||
volume_id=str(uuid.uuid4()), display_name=s_name)
|
||||
volume_id=data_utils.rand_uuid(),
|
||||
display_name=s_name)
|
||||
|
||||
@test.attr(type=['negative'])
|
||||
@test.idempotent_id('bb9da53e-d335-4309-9c15-7e76fd5e4d6d')
|
||||
|
@ -241,6 +241,22 @@ def dont_import_local_tempest_into_lib(logical_line, filename):
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
def use_rand_uuid_instead_of_uuid4(logical_line, filename):
|
||||
"""Check that tests use data_utils.rand_uuid() instead of uuid.uuid4()
|
||||
|
||||
T113
|
||||
"""
|
||||
if 'tempest/lib/' in filename:
|
||||
return
|
||||
|
||||
if 'uuid.uuid4()' not in logical_line:
|
||||
return
|
||||
|
||||
msg = ("T113: Tests should use data_utils.rand_uuid()/rand_uuid_hex() "
|
||||
"instead of uuid.uuid4()/uuid.uuid4().hex")
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(import_no_clients_in_api_and_scenario_tests)
|
||||
register(scenario_tests_need_service_tags)
|
||||
@ -253,3 +269,4 @@ def factory(register):
|
||||
register(get_resources_on_service_clients)
|
||||
register(delete_resources_on_service_clients)
|
||||
register(dont_import_local_tempest_into_lib)
|
||||
register(use_rand_uuid_instead_of_uuid4)
|
||||
|
@ -19,7 +19,6 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
from oslo_log import log as logging
|
||||
@ -38,6 +37,7 @@ import tempest.common.generator.valid_generator as valid
|
||||
import tempest.common.validation_resources as vresources
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import decorators
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -714,10 +714,10 @@ class NegativeAutoTest(BaseTestCase):
|
||||
resource = resource['name']
|
||||
LOG.debug("Add resource to test %s" % resource)
|
||||
scn_name = "inv_res_%s" % (resource)
|
||||
scenario_list.append((scn_name, {"resource": (resource,
|
||||
str(uuid.uuid4())),
|
||||
"expected_result": expected_result
|
||||
}))
|
||||
scenario_list.append((scn_name, {
|
||||
"resource": (resource, data_utils.rand_uuid()),
|
||||
"expected_result": expected_result
|
||||
}))
|
||||
if schema is not None:
|
||||
for scenario in generator.generate_scenarios(schema):
|
||||
scenario_list.append((scenario['_negtest_name'],
|
||||
|
@ -13,11 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import testtools
|
||||
|
||||
from tempest.lib import base as test
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import decorators
|
||||
from tempest.tests.lib import base
|
||||
|
||||
@ -78,13 +77,13 @@ class TestIdempotentIdDecorator(base.TestCase):
|
||||
return foo
|
||||
|
||||
def test_positive(self):
|
||||
_id = str(uuid.uuid4())
|
||||
_id = data_utils.rand_uuid()
|
||||
foo = self._test_helper(_id)
|
||||
self.assertIn('id-%s' % _id, getattr(foo, '__testtools_attrs'))
|
||||
self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id))
|
||||
|
||||
def test_positive_without_doc(self):
|
||||
_id = str(uuid.uuid4())
|
||||
_id = data_utils.rand_uuid()
|
||||
foo = self._test_helper_without_doc(_id)
|
||||
self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id))
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslotest import mockpatch
|
||||
@ -21,6 +19,7 @@ import testtools
|
||||
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest import test
|
||||
from tempest.tests import fake_config
|
||||
from tempest.tests.lib import base
|
||||
@ -79,13 +78,13 @@ class TestIdempotentIdDecorator(BaseDecoratorsTest):
|
||||
return foo
|
||||
|
||||
def test_positive(self):
|
||||
_id = str(uuid.uuid4())
|
||||
_id = data_utils.rand_uuid()
|
||||
foo = self._test_helper(_id)
|
||||
self.assertIn('id-%s' % _id, getattr(foo, '__testtools_attrs'))
|
||||
self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id))
|
||||
|
||||
def test_positive_without_doc(self):
|
||||
_id = str(uuid.uuid4())
|
||||
_id = data_utils.rand_uuid()
|
||||
foo = self._test_helper_without_doc(_id)
|
||||
self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user