def container(): """Sample container""" container = Statement(None, None, None, 'container', 'outer') id_ = Statement(None, container, None, 'leaf', 'id') type_ = Statement(None, id_, None, 'type', 'int32') id_.substmts = [type_] name = Statement(None, container, None, 'leaf', 'name') type_ = Statement(None, name, None, 'type', 'string') name.substmts = [type_] container.substmts = [id_, name] return container
def module(): """Sample container""" module = Statement(None, None, None, 'module', 'fixture-test') namespace = Statement(module, module, None, 'namespace', 'urn:yang:test') prefix = Statement(module, module, None, 'prefix', 'test') container = Statement(module, module, None, 'container', 'outer') id_ = Statement(module, container, None, 'leaf', 'id') type_ = Statement(module, id_, None, 'type', 'int32') id_.substmts = [type_] name = Statement(module, container, None, 'leaf', 'name') type_ = Statement(module, name, None, 'type', 'string') name.substmts = [type_] container.substmts = [id_, name] module.substmts = [namespace, prefix, container] return module
def test_dump(): """ dump should correctly print headless pyang.statements.Statement dump should correctly print nested pyang.statements.Statement """ prefix = Statement(None, None, None, 'prefix', 'test') assert dump(prefix).strip() == 'prefix test;' namespace = Statement(None, None, None, 'namespace', 'urn:yang:test') module = Statement(None, None, None, 'module', 'test') module.substmts = [namespace, prefix] assert dump(module).strip() == ( 'module test {\n' ' namespace "urn:yang:test";\n' ' prefix test;\n' '}' )