示例#1
0
def roundtrip(cli,
              debug=False,
              expected=None,
              format_mode=-1,
              strip_color=False):
    parse.validator = MockValidation()
    node, _, _ = cibconfig.parse_cli_to_xml(cli)
    assert_is_not_none(node)
    obj = factory.find_object(node.get("id"))
    if obj:
        factory.delete(node.get("id"))
    obj = factory.create_from_node(node)
    assert_is_not_none(obj)
    obj.nocli = True
    xml = obj.repr_cli(format_mode=format_mode)
    print(xml)
    obj.nocli = False
    s = obj.repr_cli(format_mode=format_mode)
    if strip_color:
        import re
        s = re.sub(r"\$\{[^}]+\}", "", s)
    if (s != cli) or debug:
        print("GOT:", s)
        print("EXP:", cli)
    assert obj.cli_use_validate()
    if expected is not None:
        assert expected == s
    else:
        assert cli == s
    assert not debug
示例#2
0
def roundtrip(cli, debug=False, expected=None, format_mode=-1, strip_color=False):
    parse.validator = MockValidation()
    node, _, _ = cibconfig.parse_cli_to_xml(cli)
    assert_is_not_none(node)
    obj = factory.find_object(node.get("id"))
    if obj:
        factory.delete(node.get("id"))
    obj = factory.create_from_node(node)
    assert_is_not_none(obj)
    obj.nocli = True
    xml = obj.repr_cli(format_mode=format_mode)
    print xml
    obj.nocli = False
    s = obj.repr_cli(format_mode=format_mode)
    if strip_color:
        import re
        s = re.sub(r"\$\{[^}]+\}", "", s)
    if (s != cli) or debug:
        print "GOT:", s
        print "EXP:", cli
    assert obj.cli_use_validate()
    if expected is not None:
        eq_(expected, s)
    else:
        eq_(cli, s)
    assert not debug
示例#3
0
def roundtrip(cli, debug=False, expected=None):
    node, _, _ = cibconfig.parse_cli_to_xml(cli, validation=MockValidation())
    assert_is_not_none(node)
    obj = factory.create_from_node(node)
    assert_is_not_none(obj)
    obj.nocli = True
    xml = obj.repr_cli(format=-1)
    print xml
    obj.nocli = False
    s = obj.repr_cli(format=-1)
    if (s != cli) or debug:
        print "GOT:", s
        print "EXP:", cli
    assert obj.cli_use_validate()
    if expected is not None:
        eq_(expected, s)
    else:
        eq_(cli, s)
    assert not debug
示例#4
0
def roundtrip(cli, debug=False, expected=None):
    node, _, _ = cibconfig.parse_cli_to_xml(cli, validation=MockValidation())
    assert_is_not_none(node)
    obj = factory.create_from_node(node)
    assert_is_not_none(obj)
    obj.nocli = True
    xml = obj.repr_cli(format=-1)
    print xml
    obj.nocli = False
    s = obj.repr_cli(format=-1)
    if (s != cli) or debug:
        print "GOT:", s
        print "EXP:", cli
    assert obj.cli_use_validate()
    if expected is not None:
        eq_(expected, s)
    else:
        eq_(cli, s)
    assert not debug