Files
python-group-based-policy-c…/gbpclient/tests/unit/test_cli20_l2policy.py
Igor Duarte Cardoso 80d73baae2 Adds --shared attribute to commands missing it
This is the final commit of 2 towards closing GBP client bug #1403417.
It shows the --shared option for commands that previously
didn't show it, but should. The following resources
have been fixed (for both create and update operations):
* l2policy
* l3policy
* network-service-policy
* policy-action
* policy-classifier
* policy-rule
* policy-rule-set
* policy-target-group
Furthermore, the CLI tests have been updated to test --shared.
As an extra, all (*_all_params) test methods updated with the
new option have also been re-checked for potentially lacking
options and, in that case, updated with the missing options.

Change-Id: Ie4d88c56a2d3e7abd8b063faeac5933a96e37dde
Closes-Bug: #1403417
2015-03-21 13:05:20 +00:00

110 lines
4.1 KiB
Python

# 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_create_l2_policy_with_all_params(self):
"""l2-policy-create with all params."""
resource = 'l2_policy'
cmd = gbp.CreateL2Policy(test_cli20.MyApp(sys.stdout), None)
my_id = 'my-id'
tenant_id = 'my-tenant'
name = 'my-name'
description = 'l2p description'
l3_policy_id = 'l3p'
shared = 'True'
args = [name,
'--tenant-id', tenant_id,
'--description', description,
'--l3-policy-id', l3_policy_id,
'--shared', shared]
position_names = ['name', 'description', 'l3_policy_id']
position_values = [name, description, l3_policy_id]
self._test_create_resource(resource, cmd, name, my_id, args,
position_names, position_values,
tenant_id=tenant_id, shared=True)
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_update_l2_policy_with_all_params(self):
"""l2-policy-update."""
resource = 'l2_policy'
cmd = gbp.UpdateL2Policy(test_cli20.MyApp(sys.stdout), None)
my_id = 'someid'
name = 'l2policy'
description = 'l2policy description'
l3_policy_id = 'l3p'
shared = 'True'
args = [my_id,
'--name', name,
'--description', description,
'--l3-policy-id', l3_policy_id,
'--shared', shared]
params = {
'name': name,
'description': description,
'l3_policy_id': l3_policy_id,
'shared': True
}
self._test_update_resource(resource, cmd, my_id, args, params)
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)