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