Skip to content

Commit

Permalink
fix: missing checklist argument for validating resource (#1677)
Browse files Browse the repository at this point in the history
Very important and simple fix to make sure the skip_errors, and overall
checklist are passed down to resource.validate calls

Fixes #1639

---------

Co-authored-by: Pierre Camilleri <[email protected]>
  • Loading branch information
adrienDog and pierrecamilleri authored Oct 11, 2024
1 parent e95321a commit 84c3ea0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions frictionless/validator/__spec__/package/test_checklist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json

from frictionless import Checklist, Package


def test_package_validate_with_skip_errors():
## Test runs on data with two blank-row errors, one primary-key error, see
# first test case
test_cases = [
{"ignore": [], "expect_errors": ["blank-row", "primary-key", "blank-row"]},
{"ignore": ["primary-key"], "expect_errors": ["blank-row", "blank-row"]},
{"ignore": ["blank-row"], "expect_errors": ["primary-key"]},
{"ignore": ["blank-row", "primary-key"], "expect_errors": []},
]

for tc in test_cases:
with open("data/invalid/datapackage.json") as file:
package = Package(json.load(file), basepath="data/invalid")
checklist = Checklist(skip_errors=tc["ignore"])

report = package.validate(checklist)

assert report.flatten(["type"]) == [[t] for t in tc["expect_errors"]]
1 change: 1 addition & 0 deletions frictionless/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def validate_package(
if not parallel or with_fks:
for resource in resources:
report = resource.validate(
checklist=checklist,
limit_errors=limit_errors,
limit_rows=limit_rows,
)
Expand Down

0 comments on commit 84c3ea0

Please sign in to comment.