Skip to content

Commit

Permalink
test: Update test for recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Apr 10, 2024
1 parent af221ca commit a55017d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/pipelines/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,23 @@ def test_process_item_with_duplicate_file_item(caplog):
assert str(excinfo.value) == "Duplicate FileItem: ('test1', 1)"


@pytest.mark.parametrize('klass, message', [(File, "'test.json'"), (FileItem, "('test.json', 1)")])
def test_process_item_with_invalid_json(klass, message):
spider = spider_with_crawler()
@pytest.mark.parametrize('klass', [File, FileItem])
def test_process_item_with_invalid_json(klass):
pipeline = Validate()
spider = spider_with_crawler()

kwargs = {'number': 1} if klass is FileItem else {}

item = klass(
file_name='test.json',
url='http://test.com',
data_type='release_package',
data='{"key": "value"}',
data='{',
invalid_json=True,
**kwargs
)

with pytest.raises(DropItem) as excinfo:
pipeline.process_item(item, spider)

assert str(excinfo.value) == f"Invalid {klass.__name__} data: {message}"
assert str(excinfo.value) == f"Invalid JSON data"

0 comments on commit a55017d

Please sign in to comment.