Exemple #1
0
def test_merge():
    merged = util.merge({'a': 1, 'b': {'c': 3}, 'd': 8}, {'a': 1, 'b': {'d': 7}, 'e': 9})
    assert merged == {
        'a': 1,
        'b': {
            'c': 3,
            'd': 7
        },
        'd': 8,
        'e': 9
    }
lines = """
Plugin reference
================

This document lists all plugins in order of execution.

""".splitlines()[1:]

classes = plugins.Plugin.load_plugins()
classes['base'] = plugins.base.BasePlugin
schema = {}
for name, plugin_cls in sorted(classes.items(), key=lambda x: x[1].ORDER or 0):
    title = plugin_cls.__name__
    lines.extend([title, '-' * len(title), ''])
    lines.extend([textwrap.dedent(plugin_cls.__doc__), ''])

    tree = list(build_property_tree(plugin_cls.SCHEMA))
    if tree:
        lines.extend(['Properties', '~~~~~~~~~~', ''])
        lines.extend(tree)
    lines.append('')
    schema = util.merge(schema, plugin_cls.SCHEMA)

dirname = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(dirname, 'plugin_reference.rst'), 'w') as fp:
    fp.write("\n".join(lines))

with open(os.path.join(dirname, 'schema.json'), 'w') as fp:
    json.dump(schema, fp, indent=4)
Exemple #3
0
def test_merge_conflict():
    with pytest.raises(ValueError):
        util.merge({'a': 1}, {'a': 2})