Skip to content

Commit

Permalink
Add test case to check when validation field is None
Browse files Browse the repository at this point in the history
  • Loading branch information
VMRuiz committed Aug 30, 2023
1 parent e581dc8 commit bb16665
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/contrib/validation/test_item_validation_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ def test_validation_errors_field(dummy_schema):
"SPIDERMON_VALIDATION_ERRORS_FIELD": "custom_validation_field",
}

item = {"no": "schema"}

crawler = get_crawler(settings_dict=settings)
pipeline = ItemValidationPipeline.from_crawler(crawler)

# Instantiate validation field if not defined
item = {"no": "schema"}
item = pipeline.process_item(item, None)
assert "custom_validation_field" in item

# Instantiate validation field if None
item = {"no": "schema", "custom_validation_field": None}
item = pipeline.process_item(item, None)
assert item["custom_validation_field"] is not None


def test_add_error_to_items_undefined_validation_field(dummy_schema):
settings = {
Expand Down

0 comments on commit bb16665

Please sign in to comment.