From 84c3ea0d1c4d498db67a38e89ea9e55af2377dba Mon Sep 17 00:00:00 2001 From: Adrien Vaschalde Date: Fri, 11 Oct 2024 14:41:50 +0200 Subject: [PATCH] fix: missing checklist argument for validating resource (#1677) 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 <22995923+pierrecamilleri@users.noreply.github.com> --- .../__spec__/package/test_checklist.py | 23 +++++++++++++++++++ frictionless/validator/validator.py | 1 + 2 files changed, 24 insertions(+) create mode 100644 frictionless/validator/__spec__/package/test_checklist.py diff --git a/frictionless/validator/__spec__/package/test_checklist.py b/frictionless/validator/__spec__/package/test_checklist.py new file mode 100644 index 0000000000..db25ec888d --- /dev/null +++ b/frictionless/validator/__spec__/package/test_checklist.py @@ -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"]] diff --git a/frictionless/validator/validator.py b/frictionless/validator/validator.py index 4657c9f758..523143cdbc 100644 --- a/frictionless/validator/validator.py +++ b/frictionless/validator/validator.py @@ -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, )