Seperate each policy rule with new line

Changed generator code to add new line at the end of each policy,
so that it would be easier to read. This change is required for
implementing this spec https://review.openstack.org/#/c/433010/

blueprint policy-docs
Change-Id: Ie85516b2741c94bab6e9bcd65f92ce38cb250fc6
This commit is contained in:
Anusha Unnam 2017-03-08 17:04:04 +00:00
parent 8ca44b38bd
commit d071de9c2b
2 changed files with 10 additions and 1 deletions

View File

@ -110,7 +110,7 @@ def _format_rule_default_yaml(default, include_help=True):
{'name': default.name,
'check_str': default.check_str})
if include_help:
text = ('%(help)s\n%(text)s' %
text = ('%(help)s\n%(text)s\n' %
{'help': _format_help_text(default.description),
'text': text})
return text

View File

@ -88,13 +88,17 @@ class GenerateSampleTestCase(base.PolicyBaseTestCase):
expected = '''# Basic admin check
"admin": "is_admin:True"
# This is a long description to check that line wrapping functions
# properly
"owner": "project_id:%(project_id)s"
#
"shared": "field:networks:shared=True"
#
"admin_or_owner": "rule:admin or rule:owner"
'''
output_file = self.get_config_file_fullname('policy.yaml')
with mock.patch('stevedore.named.NamedExtensionManager',
@ -121,13 +125,17 @@ class GenerateSampleTestCase(base.PolicyBaseTestCase):
expected = '''# Basic admin check
"admin": "is_admin:True"
# This is a long description to check that line wrapping functions
# properly
"owner": "project_id:%(project_id)s"
#
"shared": "field:networks:shared=True"
#
"admin_or_owner": "rule:admin or rule:owner"
'''
stdout = self._capture_stdout()
with mock.patch('stevedore.named.NamedExtensionManager',
@ -159,6 +167,7 @@ class GenerateSampleTestCase(base.PolicyBaseTestCase):
#
# This is a description to check that empty line has no white spaces.
"admin": "is_admin:True"
'''
output_file = self.get_config_file_fullname('policy.yaml')
with mock.patch('stevedore.named.NamedExtensionManager',