diff --git a/oslo_policy/generator.py b/oslo_policy/generator.py index c4d4ee39..c1df6255 100644 --- a/oslo_policy/generator.py +++ b/oslo_policy/generator.py @@ -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 diff --git a/oslo_policy/tests/test_generator.py b/oslo_policy/tests/test_generator.py index 0ae61be3..6316d2cf 100644 --- a/oslo_policy/tests/test_generator.py +++ b/oslo_policy/tests/test_generator.py @@ -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',