Exemplo n.º 1
0
def test_validator_rejection_number3_length(
        val, first_invalid_ind, validator_number3: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3.validate_coerce(val)

    assert ('The prop[%d] property of parent must be in the range [0, 1]' %
            first_invalid_ind in str(validation_failure.value))
Exemplo n.º 2
0
def test_validator_rejection_number3_length(
        val, validator_number3: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3.validate_coerce(val)

    assert 'must be a list or tuple of length 3.' in str(
        validation_failure.value)
Exemplo n.º 3
0
def test_validator_rejection_number3_length(
        val, first_invalid_ind, validator_number3_free: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3_free.validate_coerce(val)

    assert (
        "Invalid value of type {typ} received for the 'prop[{first_invalid_ind}]' property of parent"
        .format(typ=type_str(val[first_invalid_ind]),
                first_invalid_ind=first_invalid_ind)) in str(
                    validation_failure.value)
Exemplo n.º 4
0
def validator_any2():
    return InfoArrayValidator('prop',
                              'parent',
                              items=[{
                                  'valType': 'any'
                              }, {
                                  'valType': 'any'
                              }])
Exemplo n.º 5
0
def validator_number_free_1d():
    return InfoArrayValidator('prop',
                              'parent',
                              items={
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              },
                              free_length=True,
                              dimensions=1)
Exemplo n.º 6
0
def validator_number2_12d():
    return InfoArrayValidator('prop',
                              'parent',
                              items=[{
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }, {
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }],
                              free_length=True,
                              dimensions='1-2')
Exemplo n.º 7
0
def validator_number3():
    return InfoArrayValidator('prop',
                              'parent',
                              items=[{
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }, {
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }, {
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }])
Exemplo n.º 8
0
def validator_number3_free():
    return InfoArrayValidator('prop',
                              'parent',
                              items=[{
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }, {
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }, {
                                  'valType': 'number',
                                  'min': 0,
                                  'max': 1
                              }],
                              free_length=True)
Exemplo n.º 9
0
def test_validator_acceptance_number3(val,
                                      validator_number3: InfoArrayValidator):
    coerce_val = validator_number3.validate_coerce(val)
    assert coerce_val == list(val)
    assert validator_number3.present(coerce_val) == tuple(val)
Exemplo n.º 10
0
def test_validator_rejection_any2_length(val,
                                         validator_any2: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_any2.validate_coerce(val)

    assert 'Invalid value' in str(validation_failure.value)
Exemplo n.º 11
0
def test_validator_rejection_any2_type(val,
                                       validator_any2: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_any2.validate_coerce(val)

    assert 'must be a list or tuple.' in str(validation_failure.value)
Exemplo n.º 12
0
def test_validator_acceptance_any2(val, validator_any2: InfoArrayValidator):
    coerce_val = validator_any2.validate_coerce(val)
    assert coerce_val == list(val)
    assert validator_any2.present(coerce_val) == tuple(val)
Exemplo n.º 13
0
def test_validator_rejection_any2_type(
        val, validator_number3_free: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3_free.validate_coerce(val)

    assert 'Invalid value' in str(validation_failure.value)
Exemplo n.º 14
0
def validator_any3_free():
    return InfoArrayValidator('prop', 'parent', items=[
        {'valType': 'any'},
        {'valType': 'any'},
        {'valType': 'any'}], free_length=True)