Merge "Add --comment argument to policy creation command"
This commit is contained in:
commit
46e276766d
|
@ -72,6 +72,9 @@ class CreatePolicyRule(show.ShowOne):
|
|||
parser.add_argument(
|
||||
'--name', dest="rule_name",
|
||||
help="Name of the policy rule")
|
||||
parser.add_argument(
|
||||
'--comment', dest="comment",
|
||||
help="Comment about policy rule")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -80,6 +83,8 @@ class CreatePolicyRule(show.ShowOne):
|
|||
body = {'rule': parsed_args.rule}
|
||||
if parsed_args.rule_name:
|
||||
body['name'] = parsed_args.rule_name
|
||||
if parsed_args.comment:
|
||||
body['comment'] = parsed_args.comment
|
||||
data = client.create_policy_rule(parsed_args.policy_name, body)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ class TestCreatePolicyRule(common.TestCongressBase):
|
|||
def test_create_policy_rule(self):
|
||||
policy_name = 'classification'
|
||||
rule = "p(x) :- q(x)"
|
||||
response = {"comment": "None",
|
||||
response = {"comment": "Comment",
|
||||
"id": "e531f2b3-3d97-42c0-b3b5-b7b6ab532018",
|
||||
"rule": rule}
|
||||
|
||||
|
@ -121,7 +121,7 @@ class TestCreatePolicyRule(common.TestCongressBase):
|
|||
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
||||
result = list(cmd.take_action(parsed_args))
|
||||
filtered = [('comment', 'id', 'rule'),
|
||||
('None', 'e531f2b3-3d97-42c0-b3b5-b7b6ab532018', rule)]
|
||||
('Comment', 'e531f2b3-3d97-42c0-b3b5-b7b6ab532018', rule)]
|
||||
self.assertEqual(filtered, result)
|
||||
|
||||
def test_create_policy_rule_with_name(self):
|
||||
|
|
Loading…
Reference in New Issue