Example #1
0
def test_single_string_option():
    o = Option("t", short="-t", nargs=1)
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
Example #2
0
def test_list_option_rendering():
    o = Option("test", nargs="*")
    o.value = ["A", "B"]
    from jip.templates import render_template

    assert render_template("${o}", o=o) == "A B"
    assert render_template("${o|join(',')}", o=o) == "A,B"
Example #3
0
def test_single_string_option():
    o = Option("t", short="-t", nargs=1)
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
Example #4
0
def test_list_string_option():
    o = Option("t", short="-t", nargs="*")
    assert str(o) == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
    o.value = ["t1", "t2"]
    assert str(o) == "t1 t2"
    assert o.to_cmd() == "-t t1 t2"
Example #5
0
def test_boolean_option():
    o = Option("t", short="-t", default=False)
    assert o.name == "t"
    assert o.short == "-t"
    assert not o.default
    assert o.value == [False]
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = True
    assert str(o) == ""
    assert o.to_cmd() == "-t"
Example #6
0
def test_boolean_option():
    o = Option("t", short="-t", default=False)
    assert o.name == "t"
    assert o.short == "-t"
    assert not o.default
    assert o.value == [False]
    assert str(o) == ""
    assert o.to_cmd() == ""
    o.value = True
    assert str(o) == ""
    assert o.to_cmd() == "-t"
Example #7
0
def test_options_equality():
    string_opt = Option("test")
    assert string_opt == None
    string_opt.value = "TEST1"
    assert string_opt == "TEST1"
    string_opt.append("TEST2")
    assert string_opt != "TEST1"
    assert string_opt == ["TEST1", "TEST2"]
    assert string_opt
    string_opt.value = False
    assert not string_opt
Example #8
0
def test_list_string_option():
    o = Option("t", short="-t", nargs="*")
    assert str(o) == ""
    o.value = "test"
    assert str(o) == "test"
    assert o.to_cmd() == "-t test"
    o.value = ["t1", "t2"]
    assert str(o) == "t1 t2"
    assert o.to_cmd() == "-t t1 t2"
Example #9
0
def test_options_equality():
    string_opt = Option('test')
    assert string_opt == None
    string_opt.value = "TEST1"
    assert string_opt == "TEST1"
    string_opt.append("TEST2")
    assert string_opt != "TEST1"
    assert string_opt == ["TEST1", "TEST2"]
    assert string_opt
    string_opt.value = False
    assert not string_opt
Example #10
0
def test_option_expand_single():
    o = Option("test")
    o.set(1)
    assert o.expand() == [1]
Example #11
0
def test_option_is_stream_empty_value():
    o = Option("test")
    assert not o.is_stream()
Example #12
0
def test_option_expand_list():
    o = Option('test')
    o.set([1, 2, 3])
    assert o.expand() == [1, 2, 3]
Example #13
0
def test_hidden_option():
    o = Option("output", short="-o", hidden=True, value="Test")
    assert o.to_cmd() == "-o Test"
Example #14
0
def test_option_expand_single_embedded():
    o = Option("test")
    p = Option("embedded", default=1)
    o.set(p)
    assert o.expand() == [p]
Example #15
0
def test_list_option_rendering():
    o = Option('test', nargs="*")
    o.value = ["A", "B"]
    from jip.templates import render_template
    assert render_template("${o}", o=o) == 'A B'
    assert render_template("${o|join(',')}", o=o) == 'A,B'
Example #16
0
def test_option_expand_mixed_embedded():
    o = Option('test')
    p = Option('embedded', default=1)
    o.set([1, p, 2])
    assert o.expand() == [1, p, 2]
Example #17
0
def test_option_expand_list_embedded():
    o = Option('test')
    p = Option('embedded')
    p.set([1, 2, 3])
    o.set(p)
    assert o.expand() == [p, p, p]
Example #18
0
def test_hidden_option():
    o = Option("output", short="-o", hidden=True, value='Test')
    assert o.to_cmd() == '-o Test'
Example #19
0
def test_option_expand_single_embedded():
    o = Option('test')
    p = Option('embedded', default=1)
    o.set(p)
    assert o.expand() == [p]
Example #20
0
def test_option_expand_single_default():
    o = Option("test", default=1)
    assert o.expand() == [1]
Example #21
0
def test_option_expand_list():
    o = Option("test")
    o.set([1, 2, 3])
    assert o.expand() == [1, 2, 3]
Example #22
0
def test_option_expand_single_embedded():
    o = Option('test')
    p = Option('embedded', default=1)
    o.set(p)
    assert o.expand() == [p]
Example #23
0
def test_option_expand_list_embedded():
    o = Option("test")
    p = Option("embedded")
    p.set([1, 2, 3])
    o.set(p)
    assert o.expand() == [p, p, p]
Example #24
0
def test_option_expand_single():
    o = Option('test')
    o.set(1)
    assert o.expand() == [1]
Example #25
0
def test_option_expand_mixed_embedded():
    o = Option("test")
    p = Option("embedded", default=1)
    o.set([1, p, 2])
    assert o.expand() == [1, p, 2]
Example #26
0
def test_option_is_stream_empty_value():
    o = Option('test')
    assert not o.is_stream()
Example #27
0
def test_option_expand_mixed_embedded():
    o = Option('test')
    p = Option('embedded', default=1)
    o.set([1, p, 2])
    assert o.expand() == [1, p, 2]
Example #28
0
def test_option_expand_single_default():
    o = Option('test', default=1)
    assert o.expand() == [1]