예제 #1
0
def test_validate_inquiry_multiple_invalid():
    inquiry = Inquiry(
        {"tasks": [{"source": "data/table.csv"}, {"source": "data/invalid.csv"}]},
    )
    report = inquiry.validate()
    assert report.flatten(["taskPosition", "rowPosition", "fieldPosition", "code"]) == [
        [2, None, 3, "blank-label"],
        [2, None, 4, "duplicate-label"],
        [2, 2, 3, "missing-cell"],
        [2, 2, 4, "missing-cell"],
        [2, 3, 3, "missing-cell"],
        [2, 3, 4, "missing-cell"],
        [2, 4, None, "blank-row"],
        [2, 5, 5, "extra-cell"],
    ]
예제 #2
0
def test_validate_inquiry_with_multiple_packages():
    inquiry = Inquiry(
        {
            "tasks": [
                {"source": "data/package/datapackage.json"},
                {"source": "data/invalid/datapackage.json"},
            ]
        },
    )
    report = inquiry.validate()
    assert report.flatten(["taskPosition", "rowPosition", "fieldPosition", "code"]) == [
        [3, 3, None, "blank-row"],
        [3, 3, None, "primary-key-error"],
        [4, 4, None, "blank-row"],
    ]
예제 #3
0
def test_validate_inquiry_multiple_invalid_limit_errors():
    inquiry = Inquiry(
        {
            "tasks": [
                {"source": "data/table.csv"},
                {"source": "data/invalid.csv", "limitErrors": 1},
            ]
        },
    )
    report = inquiry.validate()
    assert report.flatten(["taskPosition", "code", "note"]) == [
        [2, "blank-label", ""],
    ]
    assert report.tasks[0].flatten(["rowPosition", "fieldPosition", "code"]) == []
    assert report.tasks[1].flatten(["rowPosition", "fieldPosition", "code"]) == [
        [None, 3, "blank-label"],
    ]
예제 #4
0
def test_validate_inquiry_multiple_invalid_with_schema():
    inquiry = Inquiry(
        {
            "tasks": [
                {
                    "source": "data/table.csv",
                    "schema": {"fields": [{"name": "bad"}, {"name": "name"}]},
                },
                {"source": "data/invalid.csv"},
            ],
        },
    )
    report = inquiry.validate()
    assert report.flatten(["taskPosition", "rowPosition", "fieldPosition", "code"]) == [
        [1, None, 1, "incorrect-label"],
        [2, None, 3, "blank-label"],
        [2, None, 4, "duplicate-label"],
        [2, 2, 3, "missing-cell"],
        [2, 2, 4, "missing-cell"],
        [2, 3, 3, "missing-cell"],
        [2, 3, 4, "missing-cell"],
        [2, 4, None, "blank-row"],
        [2, 5, 5, "extra-cell"],
    ]
예제 #5
0
def test_validate_inquiry_with_one_package():
    inquiry = Inquiry(
        {"tasks": [{"source": "data/package/datapackage.json"}]},
    )
    report = inquiry.validate()
    assert report.valid
예제 #6
0
def test_validate_inquiry():
    inquiry = Inquiry({"tasks": [{"source": "data/table.csv"}]})
    report = inquiry.validate()
    assert report.valid
예제 #7
0
def test_validate_inquiry_multiple():
    inquiry = Inquiry(
        {"tasks": [{"source": "data/table.csv"}, {"source": "data/matrix.csv"}]},
    )
    report = inquiry.validate()
    assert report.valid