Use ddt.named_data decorator to avoid random test names
There are few tests that generate random test names because random parameters are given to the ddt.data decorator. In the ddt version number 1.6.0 there is a possibility to determine the name of the tests without relying on the given values. I think this could be a good solution for the randomly generated names. This change is being re-introduced as ddt version 1.6.0 is now usable in the downstream CI. The original change is: Iaf39f4a83e383fb9db7f519136b9169352ff84af The following change is also included: I4d274869e5e9e7800be44bccf7a2641b4a5febe8 Which replaces periods to underscores, a needed fix. Change-Id: Iaf39f4a83e383fb9db7f519136b9169352ff84ad
This commit is contained in:
parent
7604da8054
commit
de4bf8d29e
|
@ -113,22 +113,26 @@ class ShareTypesAdminTest(base.BaseSharesAdminTest):
|
|||
@utils.skip_if_microversion_not_supported("2.50")
|
||||
@decorators.idempotent_id('a9af19e1-e789-4c4f-a39b-dd8df6ed00b1')
|
||||
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
|
||||
@ddt.data(
|
||||
('2.50', data_utils.rand_name("type_updated"),
|
||||
@ddt.named_data(
|
||||
('2_50_name_description_public', '2.50',
|
||||
data_utils.rand_name("type_updated"), 'description_updated', True),
|
||||
('2_50_name', '2.50', data_utils.rand_name("type_updated"), None,
|
||||
None),
|
||||
('2_50_description_public', '2.50', None, 'description_updated',
|
||||
None),
|
||||
('2_50_public', '2.50', None, None, True),
|
||||
('2_50', '2.50', None, None, False),
|
||||
(f'{LATEST_MICROVERSION}_name_description_public',
|
||||
LATEST_MICROVERSION, data_utils.rand_name("type_updated"),
|
||||
'description_updated', True),
|
||||
('2.50', data_utils.rand_name("type_updated"), None, None),
|
||||
('2.50', None, 'description_updated', None),
|
||||
('2.50', None, None, True),
|
||||
('2.50', None, None, False),
|
||||
(LATEST_MICROVERSION, data_utils.rand_name("type_updated"),
|
||||
'description_updated', True),
|
||||
(LATEST_MICROVERSION, data_utils.rand_name("type_updated"),
|
||||
None, None),
|
||||
(LATEST_MICROVERSION, None, 'description_updated', None),
|
||||
(LATEST_MICROVERSION, None, None, True),
|
||||
(LATEST_MICROVERSION, None, None, False),
|
||||
(f'{LATEST_MICROVERSION}_name', LATEST_MICROVERSION,
|
||||
data_utils.rand_name("type_updated"), None, None),
|
||||
(f'{LATEST_MICROVERSION}_description', LATEST_MICROVERSION, None,
|
||||
'description_updated', None),
|
||||
(f'{LATEST_MICROVERSION}_public', LATEST_MICROVERSION, None, None,
|
||||
True),
|
||||
(LATEST_MICROVERSION, LATEST_MICROVERSION, None, None, False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_share_type_create_update(self, version, st_name,
|
||||
st_description, st_is_public):
|
||||
name = data_utils.rand_name("tempest-manila")
|
||||
|
|
|
@ -83,15 +83,17 @@ class ShareTypesNegativeTest(base.BaseSharesMixedTest):
|
|||
@utils.skip_if_microversion_not_supported("2.50")
|
||||
@decorators.idempotent_id('4a22945c-8988-43a1-88c9-eb86e6abcd8e')
|
||||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
|
||||
@ddt.data(
|
||||
('2.50', '', None, None),
|
||||
(LATEST_MICROVERSION, '', None, None),
|
||||
('2.50', None, None, 'not_bool'),
|
||||
(LATEST_MICROVERSION, None, None, 'not_bool'),
|
||||
('2.50', None, generate_long_description(256), None),
|
||||
(LATEST_MICROVERSION, None, generate_long_description(256), None),
|
||||
@ddt.named_data(
|
||||
('2_50', '2.50', '', None, None),
|
||||
(LATEST_MICROVERSION, LATEST_MICROVERSION, '', None, None),
|
||||
('2_50_bad_public', '2.50', None, None, 'not_bool'),
|
||||
(f'{LATEST_MICROVERSION}_bad_public', LATEST_MICROVERSION, None, None,
|
||||
'not_bool'),
|
||||
('2_50_description', '2.50', None, generate_long_description(256),
|
||||
None),
|
||||
(f'{LATEST_MICROVERSION}_description', LATEST_MICROVERSION, None,
|
||||
generate_long_description(256), None),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_share_type_update_bad_request(
|
||||
self, version, st_name, st_description, st_is_public):
|
||||
st_id = self.st['id']
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
|
||||
ddt>=1.0.1 # MIT
|
||||
ddt>=1.6.0 # MIT
|
||||
oslo.log>=3.36.0 # Apache-2.0
|
||||
tempest>=31.1.0 # Apache-2.0
|
||||
|
|
Loading…
Reference in New Issue