Exemplo n.º 1
0
 def test_split_namespaces_with_group(self, _format_group, _list_opts):
     grp_obj = cfg.OptGroup('grp1')
     _list_opts.return_value = [
         ('namespace1', [(grp_obj, ['opt1'])]),
         ('namespace2', [('grp1', ['opt2'])]),
     ]
     list(
         sphinxext._format_option_help(
             app=None,
             namespaces=['namespace1', 'namespace2'],
             split_namespaces=True))
     print(_format_group.call_args_list)
     _format_group.assert_any_call(
         app=None,
         namespace='namespace1',
         group_name='grp1',
         group_obj=grp_obj,
         opt_list=['opt1'],
     )
     _format_group.assert_any_call(
         app=None,
         namespace='namespace2',
         group_name='grp1',
         group_obj=None,
         opt_list=['opt2'],
     )
Exemplo n.º 2
0
 def test_dont_split_namespaces_with_group(self, _format_group, _list_opts):
     grp_obj = cfg.OptGroup("grp1")
     _list_opts.return_value = [("namespace1", [(grp_obj, ["opt1"])]), ("namespace2", [("grp1", ["opt2"])])]
     list(sphinxext._format_option_help(app=None, namespaces=["namespace1", "namespace2"], split_namespaces=False))
     _format_group.assert_any_call(
         app=None, namespace=None, group_name="grp1", group_obj=grp_obj, opt_list=["opt1", "opt2"]
     )
Exemplo n.º 3
0
 def test_split_namespaces_with_group(self, _format_group, _list_opts):
     grp_obj = cfg.OptGroup('grp1')
     _list_opts.return_value = [
         ('namespace1', [(grp_obj, ['opt1'])]),
         ('namespace2', [('grp1', ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         app=None,
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=True))
     print(_format_group.call_args_list)
     _format_group.assert_any_call(
         app=None,
         namespace='namespace1',
         group_name='grp1',
         group_obj=grp_obj,
         opt_list=['opt1'],
     )
     _format_group.assert_any_call(
         app=None,
         namespace='namespace2',
         group_name='grp1',
         group_obj=None,
         opt_list=['opt2'],
     )
Exemplo n.º 4
0
 def test_split_namespaces(self, _format_group, _list_opts):
     _list_opts.return_value = [("namespace1", [(None, ["opt1"])]), ("namespace2", [(None, ["opt2"])])]
     list(sphinxext._format_option_help(app=None, namespaces=["namespace1", "namespace2"], split_namespaces=True))
     _format_group.assert_any_call(
         app=None, namespace="namespace1", group_name=None, group_obj=None, opt_list=["opt1"]
     )
     _format_group.assert_any_call(
         app=None, namespace="namespace2", group_name=None, group_obj=None, opt_list=["opt2"]
     )
Exemplo n.º 5
0
def _output_human_readable(namespaces, output_file):
    """Write an RST formated version of the docs for the options.

    :param groups: A list of the namespaces to use for discovery.
    :param output_file: A file-like object to which the data should be written.
    """
    try:
        from oslo_config import sphinxext
    except ImportError:
        raise RuntimeError(
            'Could not import sphinxext. '
            'Please install Sphinx and try again.', )
    output_data = list(sphinxext._format_option_help(LOG, namespaces, False))
    output_file.write('\n'.join(output_data))
Exemplo n.º 6
0
 def test_dont_split_namespaces(self, _format_group_opts, _list_opts):
     _list_opts.return_value = [
         ('namespace1', [(None, ['opt1'])]),
         ('namespace2', [(None, ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=False))
     _format_group_opts.assert_called_once_with(
         namespace=None,
         group_name='DEFAULT',
         group_obj=None,
         opt_list=['opt1', 'opt2'],
     )
 def test_dont_split_namespaces(self, _format_group_opts, _list_opts):
     _list_opts.return_value = [
         ('namespace1', [(None, ['opt1'])]),
         ('namespace2', [(None, ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=False))
     _format_group_opts.assert_called_once_with(
         namespace=None,
         group_name='DEFAULT',
         group_obj=None,
         opt_list=['opt1', 'opt2'],
     )
Exemplo n.º 8
0
def _output_human_readable(namespaces, output_file):
    """Write an RST formated version of the docs for the options.

    :param groups: A list of the namespaces to use for discovery.
    :param output_file: A file-like object to which the data should be written.
    """
    try:
        from oslo_config import sphinxext
    except ImportError:
        raise RuntimeError(
            'Could not import sphinxext. '
            'Please install Sphinx and try again.',
        )
    output_data = list(sphinxext._format_option_help(
        LOG, namespaces, False))
    output_file.write('\n'.join(output_data))
Exemplo n.º 9
0
 def test_dont_split_namespaces_with_group(self, _format_group_opts,
                                           _list_opts):
     grp_obj = cfg.OptGroup('grp1')
     _list_opts.return_value = [
         ('namespace1', [(grp_obj, ['opt1'])]),
         ('namespace2', [('grp1', ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=False))
     _format_group_opts.assert_any_call(
         namespace=None,
         group_name='grp1',
         group_obj=grp_obj,
         opt_list=['opt1', 'opt2'],
     )
Exemplo n.º 10
0
 def test_dont_split_namespaces_with_group(self, _format_group_opts,
                                           _list_opts):
     grp_obj = cfg.OptGroup('grp1')
     _list_opts.return_value = [
         ('namespace1', [(grp_obj, ['opt1'])]),
         ('namespace2', [('grp1', ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=False))
     _format_group_opts.assert_any_call(
         namespace=None,
         group_name='grp1',
         group_obj=grp_obj,
         opt_list=['opt1', 'opt2'],
     )
Exemplo n.º 11
0
 def test_split_namespaces(self, _format_group, _list_opts):
     _list_opts.return_value = [
         ('namespace1', [(None, ['opt1'])]),
         ('namespace2', [(None, ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         app=None,
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=True))
     _format_group.assert_any_call(
         app=None,
         namespace='namespace1',
         group_name=None,
         group_obj=None,
         opt_list=['opt1'],
     )
     _format_group.assert_any_call(
         app=None,
         namespace='namespace2',
         group_name=None,
         group_obj=None,
         opt_list=['opt2'],
     )
Exemplo n.º 12
0
 def test_split_namespaces(self, _format_group, _list_opts):
     _list_opts.return_value = [
         ('namespace1', [(None, ['opt1'])]),
         ('namespace2', [(None, ['opt2'])]),
     ]
     list(sphinxext._format_option_help(
         app=None,
         namespaces=['namespace1', 'namespace2'],
         split_namespaces=True))
     _format_group.assert_any_call(
         app=None,
         namespace='namespace1',
         group_name='DEFAULT',
         group_obj=None,
         opt_list=['opt1'],
     )
     _format_group.assert_any_call(
         app=None,
         namespace='namespace2',
         group_name='DEFAULT',
         group_obj=None,
         opt_list=['opt2'],
     )