Client test cases for Policy Target, L2 Policy, L3 Policy
Change-Id: I4489f34028036f9b167941f8de37e4d710dca34a Closes-Bug: 1393865
This commit is contained in:
parent
a7c2326f82
commit
2d83b68c2f
@ -379,7 +379,7 @@ class CreateL3Policy(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--ip-version',
|
||||
type=int,
|
||||
default=4, choices=[4, 6],
|
||||
# default=4, choices=[4, 6],
|
||||
help=_('IP version, default is 4'))
|
||||
parser.add_argument(
|
||||
'--ip-pool',
|
||||
@ -387,7 +387,7 @@ class CreateL3Policy(neutronV20.CreateCommand):
|
||||
parser.add_argument(
|
||||
'--subnet-prefix-length',
|
||||
type=int,
|
||||
default=24,
|
||||
# default=24,
|
||||
help=_('Subnet prefix length, default is 24'))
|
||||
parser.add_argument(
|
||||
'name', metavar='NAME',
|
||||
|
66
gbpclient/tests/unit/test_cli20_l2policy.py
Normal file
66
gbpclient/tests/unit/test_cli20_l2policy.py
Normal file
@ -0,0 +1,66 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from gbpclient.gbp.v2_0 import groupbasedpolicy as gbp
|
||||
from gbpclient.tests.unit import test_cli20
|
||||
|
||||
|
||||
class CLITestV20L2PolicyJSON(test_cli20.CLITestV20Base):
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
def setUp(self):
|
||||
super(CLITestV20L2PolicyJSON, self).setUp()
|
||||
|
||||
def test_create_l2_policy_with_mandatory_params(self):
|
||||
resource = 'l2_policy'
|
||||
cmd = gbp.CreateL2Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
name = 'my-name'
|
||||
tenant_id = 'my-tenant'
|
||||
my_id = 'my-id'
|
||||
args = ['--tenant-id', tenant_id,
|
||||
name]
|
||||
position_names = ['name', ]
|
||||
position_values = [name, ]
|
||||
self._test_create_resource(resource, cmd, name, my_id, args,
|
||||
position_names, position_values,
|
||||
tenant_id=tenant_id)
|
||||
|
||||
def test_list_l2_policies(self):
|
||||
resource = 'l2_policies'
|
||||
cmd = gbp.ListL2Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(resource, cmd, True)
|
||||
|
||||
def test_show_l2_policy(self):
|
||||
resource = 'l2_policy'
|
||||
cmd = gbp.ShowL2Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
args = ['--fields', 'id', self.test_id]
|
||||
self._test_show_resource(resource, cmd, self.test_id, args, ['id'])
|
||||
|
||||
def test_update_l2_policy(self):
|
||||
resource = 'l2_policy'
|
||||
cmd = gbp.UpdateL2Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
self._test_update_resource(resource, cmd, 'myid',
|
||||
['myid', '--name', 'myname',
|
||||
'--tags', 'a', 'b'],
|
||||
{'name': 'myname', 'tags': ['a', 'b'], })
|
||||
|
||||
def test_delete_l2_policy_name(self):
|
||||
resource = 'l2_policy'
|
||||
cmd = gbp.DeleteL2Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(resource, cmd, my_id, args)
|
66
gbpclient/tests/unit/test_cli20_l3policy.py
Normal file
66
gbpclient/tests/unit/test_cli20_l3policy.py
Normal file
@ -0,0 +1,66 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from gbpclient.gbp.v2_0 import groupbasedpolicy as gbp
|
||||
from gbpclient.tests.unit import test_cli20
|
||||
|
||||
|
||||
class CLITestV20L3PolicyJSON(test_cli20.CLITestV20Base):
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
def setUp(self):
|
||||
super(CLITestV20L3PolicyJSON, self).setUp()
|
||||
|
||||
def test_create_l3_policy_with_mandatory_params(self):
|
||||
resource = 'l3_policy'
|
||||
cmd = gbp.CreateL3Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
name = 'my-name'
|
||||
tenant_id = 'my-tenant'
|
||||
my_id = 'my-id'
|
||||
args = ['--tenant-id', tenant_id,
|
||||
name]
|
||||
position_names = ['name', ]
|
||||
position_values = [name, ]
|
||||
self._test_create_resource(resource, cmd, name, my_id, args,
|
||||
position_names, position_values,
|
||||
tenant_id=tenant_id)
|
||||
|
||||
def test_list_l3_policies(self):
|
||||
resource = 'l3_policies'
|
||||
cmd = gbp.ListL3Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(resource, cmd, True)
|
||||
|
||||
def test_show_l3_policy(self):
|
||||
resource = 'l3_policy'
|
||||
cmd = gbp.ShowL3Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
args = ['--fields', 'id', self.test_id]
|
||||
self._test_show_resource(resource, cmd, self.test_id, args, ['id'])
|
||||
|
||||
def test_update_l3_policy(self):
|
||||
resource = 'l3_policy'
|
||||
cmd = gbp.UpdateL3Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
self._test_update_resource(resource, cmd, 'myid',
|
||||
['myid', '--name', 'myname',
|
||||
'--tags', 'a', 'b'],
|
||||
{'name': 'myname', 'tags': ['a', 'b'], })
|
||||
|
||||
def test_delete_l3_policy_name(self):
|
||||
resource = 'l3_policy'
|
||||
cmd = gbp.DeleteL3Policy(test_cli20.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(resource, cmd, my_id, args)
|
66
gbpclient/tests/unit/test_cli20_policytarget.py
Normal file
66
gbpclient/tests/unit/test_cli20_policytarget.py
Normal file
@ -0,0 +1,66 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from gbpclient.gbp.v2_0 import groupbasedpolicy as gbp
|
||||
from gbpclient.tests.unit import test_cli20
|
||||
|
||||
|
||||
class CLITestV20PolicyTargetJSON(test_cli20.CLITestV20Base):
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
def setUp(self):
|
||||
super(CLITestV20PolicyTargetJSON, self).setUp()
|
||||
|
||||
def test_create_policy_target_with_mandatory_params(self):
|
||||
resource = 'policy_target'
|
||||
cmd = gbp.CreatePolicyTarget(test_cli20.MyApp(sys.stdout), None)
|
||||
name = 'my-name'
|
||||
tenant_id = 'my-tenant'
|
||||
my_id = 'my-id'
|
||||
args = ['--tenant-id', tenant_id,
|
||||
name]
|
||||
position_names = ['name', ]
|
||||
position_values = [name, ]
|
||||
self._test_create_resource(resource, cmd, name, my_id, args,
|
||||
position_names, position_values,
|
||||
tenant_id=tenant_id)
|
||||
|
||||
def test_list_policy_targets(self):
|
||||
resource = 'policy_targets'
|
||||
cmd = gbp.ListPolicyTarget(test_cli20.MyApp(sys.stdout), None)
|
||||
self._test_list_resources(resource, cmd, True)
|
||||
|
||||
def test_show_policy_target_name(self):
|
||||
resource = 'policy_target'
|
||||
cmd = gbp.ShowPolicyTarget(test_cli20.MyApp(sys.stdout), None)
|
||||
args = ['--fields', 'id', self.test_id]
|
||||
self._test_show_resource(resource, cmd, self.test_id, args, ['id'])
|
||||
|
||||
def test_update_policy_target(self):
|
||||
resource = 'policy_target'
|
||||
cmd = gbp.UpdatePolicyTarget(test_cli20.MyApp(sys.stdout), None)
|
||||
self._test_update_resource(resource, cmd, 'myid',
|
||||
['myid', '--name', 'myname',
|
||||
'--tags', 'a', 'b'],
|
||||
{'name': 'myname', 'tags': ['a', 'b'], })
|
||||
|
||||
def test_delete_policy_target_name(self):
|
||||
resource = 'policy_target'
|
||||
cmd = gbp.DeletePolicyTarget(test_cli20.MyApp(sys.stdout), None)
|
||||
my_id = 'my-id'
|
||||
args = [my_id]
|
||||
self._test_delete_resource(resource, cmd, my_id, args)
|
Loading…
x
Reference in New Issue
Block a user