Esempio n. 1
0
def test_validates_optional_schema():
    df = pd.DataFrame({'a': [0], 'b': [0]})

    with pytest.raises(AssertionError):
        data_frame_validator(
            df,
            [validate_schema(schema={'a': 'int64'}, optional={'b': 'object'})])
Esempio n. 2
0
def test_raises_on_unexpected_columns():
    df = pd.DataFrame({'a': [0], 'b': [0]})

    with pytest.raises(AssertionError):
        data_frame_validator(
            df,
            [
                validate_schema(schema={'a': 'int64'},
                                on_unexpected_cols='raise')
            ],
        )
Esempio n. 3
0
def test_warns_on_unexpected_columns():
    df = pd.DataFrame({'a': [0], 'b': [0]})

    with pytest.warns(UserWarning):
        data_frame_validator(
            df,
            [
                validate_schema(schema={'a': 'int64'},
                                on_unexpected_cols='warn')
            ],
        )
Esempio n. 4
0
def test_ignores_dtype_validation_if_none():
    df = pd.DataFrame({'a': [0], 'b': [0]})

    data_frame_validator(
        df, [validate_schema(schema={'a': None}, optional={'b': None})])
Esempio n. 5
0
def test_allows_optional_columns():
    df = pd.DataFrame({'a': [0], 'b': [0]})

    assert data_frame_validator(
        df, [validate_schema(schema={'a': 'int64'}, optional=['b'])])