Beispiel #1
0
def test_invalid_2():
    doc = """
    date
    """
    val = "2017/03/99"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #2
0
def test_invalid_2c():
    doc = """
    time
    """
    val = "12:34:96"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #3
0
def test_make_valid():
    doc = """
    d_u:
        foo: string
        bar: number
    """
    t = make_type(doc)
Beispiel #4
0
def test_valid_1():
    doc = """
    time
    """
    val = "12:34:56.789"
    t = make_type(doc)
    assert t.valid(val)
Beispiel #5
0
def test_invalid_2a():
    doc = """
    time
    """
    val = "32:34:56"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #6
0
def test_valid_1b():
    doc = """
    regex: '[A-F][1-5]'
    """
    val = 'F5extra'
    t = make_type(doc)
    assert t.valid(val)
Beispiel #7
0
def test_invalid():
    doc = """
    string
    """
    val = 1
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #8
0
def test_invalid_0():
    doc = """
    tuple: [string, number, string]
    """
    val = 42
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #9
0
def test_invalid_1():
    doc = """
    tuple: [string, number, string]
    """
    val = ('foo', 'bar', 'baz')
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #10
0
def test_valid_2a():
    doc = """
    tuple: [string, number, list: string]
    """
    val = ['foo', 42, ['bar', 'baz']]
    t = make_type(doc)
    assert t.valid(val)
Beispiel #11
0
def test_valid_2b():
    doc = """
    tuple: [string, number, list: string]
    """
    val = ('foo', 42, ('bar', 'baz'))
    t = make_type(doc)
    assert t.valid(val)
Beispiel #12
0
def test_valid_1b():
    doc = """
    tuple: [string, number, string]
    """
    val = ('foo', 42, 'bar')
    t = make_type(doc)
    assert t.valid(val)
Beispiel #13
0
def test_valid():
    doc = """
    date
    """
    val = "2017/03/25"
    t = make_type(doc)
    assert t.valid(val)
Beispiel #14
0
def test_invalid_3():
    doc = """
    date
    """
    val = "2017/03/25extra"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #15
0
def test_invalid_1():
    doc = """
    oneof: [foo, bar, baz]
    """
    val = 'qux'
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #16
0
def test_valid_1():
    doc = """
    number
    """
    val = 20
    t = make_type(doc)
    assert t.valid(val)
Beispiel #17
0
def test_valid_1a():
    doc = """
    regex: '[A-F][1-5]'
    """
    val = 'A1'
    t = make_type(doc)
    assert t.valid(val)
Beispiel #18
0
def test_valid_2():
    doc = """
    number
    """
    val = 3.14
    t = make_type(doc)
    assert t.valid(val)
Beispiel #19
0
def test_invalid_1():
    doc = """
    regex: '[A-F][1-5]'
    """
    val = 'qux'
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #20
0
def test_valid_3a():
    doc = """
    number
    """
    val = "-12345"
    t = make_type(doc)
    assert t.valid(val)
Beispiel #21
0
def test_valid():
    doc = """
    string
    """
    val = "foo"
    t = make_type(doc)
    assert t.valid(val)
Beispiel #22
0
def test_valid_3c():
    doc = """
    number
    """
    val = "3.14e-2"
    t = make_type(doc)
    assert t.valid(val)
Beispiel #23
0
def test_invalid_1():
    doc = """
    time
    """
    val = "12"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #24
0
def test_invalid_0():
    doc = """
    number
    """
    val = "abc"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #25
0
def test_invalid_2b():
    doc = """
    time
    """
    val = "12:74:56"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #26
0
def test_invalid_1():
    doc = """
    number
    """
    val = ['foo', 'bar']
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #27
0
def test_invalid_3():
    doc = """
    time
    """
    val = "12:34:56extra"
    t = make_type(doc)
    assert not t.valid(val)
Beispiel #28
0
def test_valid_1b():
    doc = """
    oneof: [foo, bar, baz]
    """
    val = 'baz'
    t = make_type(doc)
    assert t.valid(val)
Beispiel #29
0
def test_make_valid():
    doc = """
    union:
    - string
    - number
    """
    t = make_type(doc)
Beispiel #30
0
def test_invalid_0():
    doc = """
    date
    """
    val = 1
    t = make_type(doc)
    assert not t.valid(val)