Merge "Define non_admin_status_resources in each test"
This commit is contained in:
commit
adc53158c8
neutronclient/tests/unit
qos
test_cli20.pytest_cli20_address_scope.pytest_cli20_credential.pytest_cli20_floatingips.pytest_cli20_metering.pytest_cli20_networkprofile.pytest_cli20_nsx_networkgateway.pytest_cli20_nsx_queue.pytest_cli20_nuage_netpartition.pytest_cli20_policyprofile.pytest_cli20_rbac.pytest_cli20_securitygroup.pytest_cli20_subnet.pytest_cli20_subnetpool.pytest_client_extension.pyvpn
@ -21,6 +21,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20QoSPolicyJSON(test_cli20.CLITestV20Base):
|
class CLITestV20QoSPolicyJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['policy']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20QoSPolicyJSON, self).setUp()
|
super(CLITestV20QoSPolicyJSON, self).setUp()
|
||||||
self.res = 'policy'
|
self.res = 'policy'
|
||||||
|
@ -22,6 +22,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20QoSRuleJSON(test_cli20.CLITestV20Base):
|
class CLITestV20QoSRuleJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['bandwidth_limit_rule']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20QoSRuleJSON, self).setUp()
|
super(CLITestV20QoSRuleJSON, self).setUp()
|
||||||
self.res = 'bandwidth_limit_rule'
|
self.res = 'bandwidth_limit_rule'
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import copy
|
|
||||||
import itertools
|
import itertools
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -39,17 +38,6 @@ FORMAT = 'json'
|
|||||||
TOKEN = 'testtoken'
|
TOKEN = 'testtoken'
|
||||||
ENDURL = 'localurl'
|
ENDURL = 'localurl'
|
||||||
|
|
||||||
non_admin_status_resources = ['subnet', 'floatingip', 'security_group',
|
|
||||||
'security_group_rule', 'qos_queue',
|
|
||||||
'network_gateway', 'gateway_device',
|
|
||||||
'credential', 'network_profile',
|
|
||||||
'policy_profile', 'ikepolicy',
|
|
||||||
'ipsecpolicy', 'metering_label',
|
|
||||||
'metering_label_rule', 'net_partition',
|
|
||||||
'fox_socket', 'subnetpool',
|
|
||||||
'rbac_policy', 'address_scope',
|
|
||||||
'policy', 'bandwidth_limit_rule']
|
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def capture_std_streams():
|
def capture_std_streams():
|
||||||
@ -187,6 +175,8 @@ class CLITestV20Base(base.BaseTestCase):
|
|||||||
test_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
test_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||||
id_field = 'id'
|
id_field = 'id'
|
||||||
|
|
||||||
|
non_admin_status_resources = []
|
||||||
|
|
||||||
def _find_resourceid(self, client, resource, name_or_id,
|
def _find_resourceid(self, client, resource, name_or_id,
|
||||||
cmd_resource=None, parent_id=None):
|
cmd_resource=None, parent_id=None):
|
||||||
return name_or_id
|
return name_or_id
|
||||||
@ -198,7 +188,6 @@ class CLITestV20Base(base.BaseTestCase):
|
|||||||
"""Prepare the test environment."""
|
"""Prepare the test environment."""
|
||||||
super(CLITestV20Base, self).setUp()
|
super(CLITestV20Base, self).setUp()
|
||||||
client.Client.EXTED_PLURALS.update(constants.PLURALS)
|
client.Client.EXTED_PLURALS.update(constants.PLURALS)
|
||||||
self.non_admin_status_resources = copy.copy(non_admin_status_resources)
|
|
||||||
if plurals is not None:
|
if plurals is not None:
|
||||||
client.Client.EXTED_PLURALS.update(plurals)
|
client.Client.EXTED_PLURALS.update(plurals)
|
||||||
self.metadata = {'plurals': client.Client.EXTED_PLURALS,
|
self.metadata = {'plurals': client.Client.EXTED_PLURALS,
|
||||||
@ -221,6 +210,18 @@ class CLITestV20Base(base.BaseTestCase):
|
|||||||
self.client = client.Client(token=TOKEN, endpoint_url=self.endurl)
|
self.client = client.Client(token=TOKEN, endpoint_url=self.endurl)
|
||||||
|
|
||||||
def register_non_admin_status_resource(self, resource_name):
|
def register_non_admin_status_resource(self, resource_name):
|
||||||
|
# TODO(amotoki):
|
||||||
|
# It is recommended to define
|
||||||
|
# "non_admin_status_resources in each test class rather than
|
||||||
|
# using register_non_admin_status_resource method.
|
||||||
|
|
||||||
|
# If we change self.non_admin_status_resources like this,
|
||||||
|
# we need to ensure this should be an instance variable
|
||||||
|
# to avoid changing the class variable.
|
||||||
|
if (id(self.non_admin_status_resources) ==
|
||||||
|
id(self.__class__.non_admin_status_resources)):
|
||||||
|
self.non_admin_status_resources = (self.__class__.
|
||||||
|
non_admin_status_resources[:])
|
||||||
self.non_admin_status_resources.append(resource_name)
|
self.non_admin_status_resources.append(resource_name)
|
||||||
|
|
||||||
def _test_create_resource(self, resource, cmd, name, myid, args,
|
def _test_create_resource(self, resource, cmd, name, myid, args,
|
||||||
|
@ -24,6 +24,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20AddressScopeJSON(test_cli20.CLITestV20Base):
|
class CLITestV20AddressScopeJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['address_scope']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20AddressScopeJSON, self).setUp(plurals={'tags': 'tag'})
|
super(CLITestV20AddressScopeJSON, self).setUp(plurals={'tags': 'tag'})
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
class CLITestV20Credential(test_cli20.CLITestV20Base):
|
class CLITestV20Credential(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['credential']
|
||||||
|
|
||||||
def test_create_credential(self):
|
def test_create_credential(self):
|
||||||
"""Create credential: myid."""
|
"""Create credential: myid."""
|
||||||
resource = 'credential'
|
resource = 'credential'
|
||||||
|
@ -21,6 +21,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20FloatingIpsJSON(test_cli20.CLITestV20Base):
|
class CLITestV20FloatingIpsJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['floatingip']
|
||||||
|
|
||||||
def test_create_floatingip(self):
|
def test_create_floatingip(self):
|
||||||
"""Create floatingip: fip1."""
|
"""Create floatingip: fip1."""
|
||||||
resource = 'floatingip'
|
resource = 'floatingip'
|
||||||
|
@ -19,6 +19,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20MeteringJSON(test_cli20.CLITestV20Base):
|
class CLITestV20MeteringJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['metering_label', 'metering_label_rule']
|
||||||
|
|
||||||
def test_create_metering_label(self):
|
def test_create_metering_label(self):
|
||||||
"""Create a metering label."""
|
"""Create a metering label."""
|
||||||
resource = 'metering_label'
|
resource = 'metering_label'
|
||||||
|
@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
class CLITestV20NetworkProfile(test_cli20.CLITestV20Base):
|
class CLITestV20NetworkProfile(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['network_profile']
|
||||||
|
|
||||||
def test_create_networkprofile(self):
|
def test_create_networkprofile(self):
|
||||||
"""Create networkprofile: myid."""
|
"""Create networkprofile: myid."""
|
||||||
resource = 'network_profile'
|
resource = 'network_profile'
|
||||||
|
@ -28,6 +28,8 @@ class CLITestV20NetworkGatewayJSON(test_cli20.CLITestV20Base):
|
|||||||
gw_resource = "network_gateway"
|
gw_resource = "network_gateway"
|
||||||
dev_resource = "gateway_device"
|
dev_resource = "gateway_device"
|
||||||
|
|
||||||
|
non_admin_status_resources = ['network_gateway', 'gateway_device']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20NetworkGatewayJSON, self).setUp(
|
super(CLITestV20NetworkGatewayJSON, self).setUp(
|
||||||
plurals={'devices': 'device',
|
plurals={'devices': 'device',
|
||||||
|
@ -21,6 +21,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20QosQueueJSON(test_cli20.CLITestV20Base):
|
class CLITestV20QosQueueJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['qos_queue']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20QosQueueJSON, self).setUp(
|
super(CLITestV20QosQueueJSON, self).setUp(
|
||||||
plurals={'qos_queues': 'qos_queue'})
|
plurals={'qos_queues': 'qos_queue'})
|
||||||
|
@ -21,6 +21,7 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
class CLITestV20NetPartitionJSON(test_cli20.CLITestV20Base):
|
class CLITestV20NetPartitionJSON(test_cli20.CLITestV20Base):
|
||||||
resource = 'net_partition'
|
resource = 'net_partition'
|
||||||
|
non_admin_status_resources = ['net_partition']
|
||||||
|
|
||||||
def test_create_netpartition(self):
|
def test_create_netpartition(self):
|
||||||
cmd = netpartition.CreateNetPartition(test_cli20.MyApp(sys.stdout),
|
cmd = netpartition.CreateNetPartition(test_cli20.MyApp(sys.stdout),
|
||||||
|
@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
class CLITestV20PolicyProfile(test_cli20.CLITestV20Base):
|
class CLITestV20PolicyProfile(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['policy_profile']
|
||||||
|
|
||||||
def test_list_policyprofile_detail(self):
|
def test_list_policyprofile_detail(self):
|
||||||
"""List policyprofile: -D."""
|
"""List policyprofile: -D."""
|
||||||
resources = 'policy_profiles'
|
resources = 'policy_profiles'
|
||||||
|
@ -20,6 +20,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20RBACJSON(test_cli20.CLITestV20Base):
|
class CLITestV20RBACJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['rbac_policy']
|
||||||
|
|
||||||
def test_create_rbac_policy_with_mandatory_params(self):
|
def test_create_rbac_policy_with_mandatory_params(self):
|
||||||
"""Create rbac: rbac_object --type network --action access_as_shared"""
|
"""Create rbac: rbac_object --type network --action access_as_shared"""
|
||||||
resource = 'rbac_policy'
|
resource = 'rbac_policy'
|
||||||
|
@ -27,6 +27,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
|
class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['security_group', 'security_group_rule']
|
||||||
|
|
||||||
def test_create_security_group(self):
|
def test_create_security_group(self):
|
||||||
"""Create security group: webservers."""
|
"""Create security group: webservers."""
|
||||||
resource = 'security_group'
|
resource = 'security_group'
|
||||||
|
@ -25,6 +25,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
|
class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['subnet']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20SubnetJSON, self).setUp(plurals={'tags': 'tag'})
|
super(CLITestV20SubnetJSON, self).setUp(plurals={'tags': 'tag'})
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20SubnetPoolJSON(test_cli20.CLITestV20Base):
|
class CLITestV20SubnetPoolJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['subnetpool']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20SubnetPoolJSON, self).setUp(plurals={'tags': 'tag'})
|
super(CLITestV20SubnetPoolJSON, self).setUp(plurals={'tags': 'tag'})
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
|
|
||||||
class CLITestV20ExtensionJSON(test_cli20.CLITestV20Base):
|
class CLITestV20ExtensionJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['fox_socket']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# need to mock before super because extensions loaded on instantiation
|
# need to mock before super because extensions loaded on instantiation
|
||||||
self._mock_extension_loading()
|
self._mock_extension_loading()
|
||||||
|
@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
class CLITestV20VpnIkePolicyJSON(test_cli20.CLITestV20Base):
|
class CLITestV20VpnIkePolicyJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['ikepolicy']
|
||||||
|
|
||||||
def test_create_ikepolicy_all_params(self):
|
def test_create_ikepolicy_all_params(self):
|
||||||
"""vpn-ikepolicy-create all params."""
|
"""vpn-ikepolicy-create all params."""
|
||||||
resource = 'ikepolicy'
|
resource = 'ikepolicy'
|
||||||
|
@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
class CLITestV20VpnIpsecPolicyJSON(test_cli20.CLITestV20Base):
|
class CLITestV20VpnIpsecPolicyJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['ipsecpolicy']
|
||||||
|
|
||||||
def test_create_ipsecpolicy_all_params(self):
|
def test_create_ipsecpolicy_all_params(self):
|
||||||
"""vpn-ipsecpolicy-create all params with dashes."""
|
"""vpn-ipsecpolicy-create all params with dashes."""
|
||||||
resource = 'ipsecpolicy'
|
resource = 'ipsecpolicy'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user