Пример #1
0
def test_validate_table_dimensions_num_fields():
    report = validate(
        "data/table-limits.csv",
        checks=[checks.table_dimensions(num_fields=42)],
    )
    assert report.flatten(["limits", "code"]) == [[{
        "requiredNumFields": 42,
        "numberFields": 4
    }, "table-dimensions-error"]]
Пример #2
0
def test_validate_table_dimensions_max_rows():
    report = validate(
        "data/table-limits.csv",
        checks=[checks.table_dimensions(max_rows=2)],
    )
    assert report.flatten(["limits", "code"]) == [[{
        "maxRows": 2,
        "numberRows": 3
    }, "table-dimensions-error"]]
Пример #3
0
def test_validate_table_dimensions_min_fields_max_rows_wrong():
    report = validate(
        "data/table-limits.csv",
        checks=[checks.table_dimensions(min_fields=5, max_rows=2)],
    )
    assert report.flatten(["limits", "code"]) == [
        [{
            "minFields": 5,
            "numberFields": 4
        }, "table-dimensions-error"],
        [{
            "maxRows": 2,
            "numberRows": 3
        }, "table-dimensions-error"],
    ]
Пример #4
0
def test_validate_table_dimensions_num_fields_num_rows_wrong():
    report = validate(
        "data/table-limits.csv",
        checks=[checks.table_dimensions(num_fields=3, num_rows=2)],
    )
    assert report.flatten(["limits", "code"]) == [
        [{
            "requiredNumFields": 3,
            "numberFields": 4
        }, "table-dimensions-error"],
        [{
            "requiredNumRows": 2,
            "numberRows": 3
        }, "table-dimensions-error"],
    ]
Пример #5
0
def test_validate_table_dimensions_min_fields_max_rows_correct():
    report = validate(
        "data/table-limits.csv",
        checks=[checks.table_dimensions(min_fields=4, max_rows=3)],
    )
    assert report.flatten(["limits", "code"]) == []
Пример #6
0
def test_validate_table_dimensions_no_limits():
    report = validate(
        "data/table-limits.csv",
        checks=[checks.table_dimensions()],
    )
    assert report.flatten(["limits", "code"]) == []