diff --git a/neutronclient/tests/unit/qos/test_cli20_policy.py b/neutronclient/tests/unit/qos/test_cli20_policy.py index 9e4bf6d0e..6eae329c1 100755 --- a/neutronclient/tests/unit/qos/test_cli20_policy.py +++ b/neutronclient/tests/unit/qos/test_cli20_policy.py @@ -21,6 +21,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20QoSPolicyJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['policy'] + def setUp(self): super(CLITestV20QoSPolicyJSON, self).setUp() self.res = 'policy' diff --git a/neutronclient/tests/unit/qos/test_cli20_rule.py b/neutronclient/tests/unit/qos/test_cli20_rule.py index c2fe92130..776fafd37 100644 --- a/neutronclient/tests/unit/qos/test_cli20_rule.py +++ b/neutronclient/tests/unit/qos/test_cli20_rule.py @@ -22,6 +22,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20QoSRuleJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['bandwidth_limit_rule'] + def setUp(self): super(CLITestV20QoSRuleJSON, self).setUp() self.res = 'bandwidth_limit_rule' diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py index 2ce2b2bcf..2e609a0bd 100644 --- a/neutronclient/tests/unit/test_cli20.py +++ b/neutronclient/tests/unit/test_cli20.py @@ -15,7 +15,6 @@ # import contextlib -import copy import itertools import sys @@ -39,17 +38,6 @@ FORMAT = 'json' TOKEN = 'testtoken' 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 def capture_std_streams(): @@ -187,6 +175,8 @@ class CLITestV20Base(base.BaseTestCase): test_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' id_field = 'id' + non_admin_status_resources = [] + def _find_resourceid(self, client, resource, name_or_id, cmd_resource=None, parent_id=None): return name_or_id @@ -198,7 +188,6 @@ class CLITestV20Base(base.BaseTestCase): """Prepare the test environment.""" super(CLITestV20Base, self).setUp() client.Client.EXTED_PLURALS.update(constants.PLURALS) - self.non_admin_status_resources = copy.copy(non_admin_status_resources) if plurals is not None: client.Client.EXTED_PLURALS.update(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) 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) def _test_create_resource(self, resource, cmd, name, myid, args, diff --git a/neutronclient/tests/unit/test_cli20_address_scope.py b/neutronclient/tests/unit/test_cli20_address_scope.py index e7b8a33b2..7b8ea7b78 100755 --- a/neutronclient/tests/unit/test_cli20_address_scope.py +++ b/neutronclient/tests/unit/test_cli20_address_scope.py @@ -24,6 +24,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20AddressScopeJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['address_scope'] + def setUp(self): super(CLITestV20AddressScopeJSON, self).setUp(plurals={'tags': 'tag'}) diff --git a/neutronclient/tests/unit/test_cli20_credential.py b/neutronclient/tests/unit/test_cli20_credential.py index 4f4a1d35d..58c413da6 100644 --- a/neutronclient/tests/unit/test_cli20_credential.py +++ b/neutronclient/tests/unit/test_cli20_credential.py @@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20Credential(test_cli20.CLITestV20Base): + non_admin_status_resources = ['credential'] + def test_create_credential(self): """Create credential: myid.""" resource = 'credential' diff --git a/neutronclient/tests/unit/test_cli20_floatingips.py b/neutronclient/tests/unit/test_cli20_floatingips.py index 4f09856b1..f42f145ba 100644 --- a/neutronclient/tests/unit/test_cli20_floatingips.py +++ b/neutronclient/tests/unit/test_cli20_floatingips.py @@ -21,6 +21,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20FloatingIpsJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['floatingip'] + def test_create_floatingip(self): """Create floatingip: fip1.""" resource = 'floatingip' diff --git a/neutronclient/tests/unit/test_cli20_metering.py b/neutronclient/tests/unit/test_cli20_metering.py index 9be645f9b..ad9e99b6c 100644 --- a/neutronclient/tests/unit/test_cli20_metering.py +++ b/neutronclient/tests/unit/test_cli20_metering.py @@ -19,6 +19,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20MeteringJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['metering_label', 'metering_label_rule'] + def test_create_metering_label(self): """Create a metering label.""" resource = 'metering_label' diff --git a/neutronclient/tests/unit/test_cli20_networkprofile.py b/neutronclient/tests/unit/test_cli20_networkprofile.py index c5a735338..673aeca4c 100644 --- a/neutronclient/tests/unit/test_cli20_networkprofile.py +++ b/neutronclient/tests/unit/test_cli20_networkprofile.py @@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20NetworkProfile(test_cli20.CLITestV20Base): + non_admin_status_resources = ['network_profile'] + def test_create_networkprofile(self): """Create networkprofile: myid.""" resource = 'network_profile' diff --git a/neutronclient/tests/unit/test_cli20_nsx_networkgateway.py b/neutronclient/tests/unit/test_cli20_nsx_networkgateway.py index 0d77d4ddf..0ce2c8121 100644 --- a/neutronclient/tests/unit/test_cli20_nsx_networkgateway.py +++ b/neutronclient/tests/unit/test_cli20_nsx_networkgateway.py @@ -28,6 +28,8 @@ class CLITestV20NetworkGatewayJSON(test_cli20.CLITestV20Base): gw_resource = "network_gateway" dev_resource = "gateway_device" + non_admin_status_resources = ['network_gateway', 'gateway_device'] + def setUp(self): super(CLITestV20NetworkGatewayJSON, self).setUp( plurals={'devices': 'device', diff --git a/neutronclient/tests/unit/test_cli20_nsx_queue.py b/neutronclient/tests/unit/test_cli20_nsx_queue.py index f65087347..1cbe0c747 100644 --- a/neutronclient/tests/unit/test_cli20_nsx_queue.py +++ b/neutronclient/tests/unit/test_cli20_nsx_queue.py @@ -21,6 +21,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20QosQueueJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['qos_queue'] + def setUp(self): super(CLITestV20QosQueueJSON, self).setUp( plurals={'qos_queues': 'qos_queue'}) diff --git a/neutronclient/tests/unit/test_cli20_nuage_netpartition.py b/neutronclient/tests/unit/test_cli20_nuage_netpartition.py index 18f9d3ab0..a9839f523 100644 --- a/neutronclient/tests/unit/test_cli20_nuage_netpartition.py +++ b/neutronclient/tests/unit/test_cli20_nuage_netpartition.py @@ -21,6 +21,7 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20NetPartitionJSON(test_cli20.CLITestV20Base): resource = 'net_partition' + non_admin_status_resources = ['net_partition'] def test_create_netpartition(self): cmd = netpartition.CreateNetPartition(test_cli20.MyApp(sys.stdout), diff --git a/neutronclient/tests/unit/test_cli20_policyprofile.py b/neutronclient/tests/unit/test_cli20_policyprofile.py index 94cbf2c57..6a7fa6d51 100644 --- a/neutronclient/tests/unit/test_cli20_policyprofile.py +++ b/neutronclient/tests/unit/test_cli20_policyprofile.py @@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20PolicyProfile(test_cli20.CLITestV20Base): + non_admin_status_resources = ['policy_profile'] + def test_list_policyprofile_detail(self): """List policyprofile: -D.""" resources = 'policy_profiles' diff --git a/neutronclient/tests/unit/test_cli20_rbac.py b/neutronclient/tests/unit/test_cli20_rbac.py index fd51ffb7d..4027d617e 100644 --- a/neutronclient/tests/unit/test_cli20_rbac.py +++ b/neutronclient/tests/unit/test_cli20_rbac.py @@ -20,6 +20,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20RBACJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['rbac_policy'] + def test_create_rbac_policy_with_mandatory_params(self): """Create rbac: rbac_object --type network --action access_as_shared""" resource = 'rbac_policy' diff --git a/neutronclient/tests/unit/test_cli20_securitygroup.py b/neutronclient/tests/unit/test_cli20_securitygroup.py index 61b86fd9d..8a8b1ada8 100644 --- a/neutronclient/tests/unit/test_cli20_securitygroup.py +++ b/neutronclient/tests/unit/test_cli20_securitygroup.py @@ -27,6 +27,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['security_group', 'security_group_rule'] + def test_create_security_group(self): """Create security group: webservers.""" resource = 'security_group' diff --git a/neutronclient/tests/unit/test_cli20_subnet.py b/neutronclient/tests/unit/test_cli20_subnet.py index e166cf91a..a5b1b62eb 100644 --- a/neutronclient/tests/unit/test_cli20_subnet.py +++ b/neutronclient/tests/unit/test_cli20_subnet.py @@ -25,6 +25,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20SubnetJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['subnet'] + def setUp(self): super(CLITestV20SubnetJSON, self).setUp(plurals={'tags': 'tag'}) diff --git a/neutronclient/tests/unit/test_cli20_subnetpool.py b/neutronclient/tests/unit/test_cli20_subnetpool.py index 9873e848c..e5555f793 100644 --- a/neutronclient/tests/unit/test_cli20_subnetpool.py +++ b/neutronclient/tests/unit/test_cli20_subnetpool.py @@ -24,6 +24,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20SubnetPoolJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['subnetpool'] + def setUp(self): super(CLITestV20SubnetPoolJSON, self).setUp(plurals={'tags': 'tag'}) diff --git a/neutronclient/tests/unit/test_client_extension.py b/neutronclient/tests/unit/test_client_extension.py index 8684c0891..1cd4dcb96 100644 --- a/neutronclient/tests/unit/test_client_extension.py +++ b/neutronclient/tests/unit/test_client_extension.py @@ -26,6 +26,9 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20ExtensionJSON(test_cli20.CLITestV20Base): + + non_admin_status_resources = ['fox_socket'] + def setUp(self): # need to mock before super because extensions loaded on instantiation self._mock_extension_loading() diff --git a/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py b/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py index d21fb1455..604e2cc07 100644 --- a/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py +++ b/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py @@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20VpnIkePolicyJSON(test_cli20.CLITestV20Base): + non_admin_status_resources = ['ikepolicy'] + def test_create_ikepolicy_all_params(self): """vpn-ikepolicy-create all params.""" resource = 'ikepolicy' diff --git a/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py b/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py index 7d3d0ba1e..d133e5ec3 100644 --- a/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py +++ b/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py @@ -22,6 +22,8 @@ from neutronclient.tests.unit import test_cli20 class CLITestV20VpnIpsecPolicyJSON(test_cli20.CLITestV20Base): + non_admin_status_resources = ['ipsecpolicy'] + def test_create_ipsecpolicy_all_params(self): """vpn-ipsecpolicy-create all params with dashes.""" resource = 'ipsecpolicy'