示例#1
0
def test_default_is_scatter(validator: BaseDataValidator):
    val = [dict(mode='lines')]
    res = validator.validate_coerce(val)
    res_present = validator.present(res)

    assert isinstance(res, list)
    assert isinstance(res_present, tuple)
    assert isinstance(res_present[0], Scatter)
    assert res_present[0].type == 'scatter'
    assert res_present[0].mode == 'lines'
示例#2
0
def test_acceptance_dict(validator: BaseDataValidator):
    val = (dict(type='scatter',
                mode='lines'), dict(type='box', fillcolor='yellow'))
    res = validator.validate_coerce(val)
    res_present = validator.present(res)

    assert isinstance(res, list)
    assert isinstance(res_present, tuple)
    assert isinstance(res_present[0], Scatter)
    assert res_present[0].type == 'scatter'
    assert res_present[0].mode == 'lines'

    assert isinstance(res_present[1], Box)
    assert res_present[1].type == 'box'
    assert res_present[1].fillcolor == 'yellow'

    # Make sure UIDs are actually unique
    assert res_present[0].uid != res_present[1].uid