Skip to content

Commit

Permalink
pipelines: Don't test class internals. Add whitespace between asserti…
Browse files Browse the repository at this point in the history
…ons and other code.
  • Loading branch information
jpmckinney committed Jun 23, 2020
1 parent abff011 commit f0e6006
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_process_item_error():
pipeline.process_item(item, None)


def test_duplicated_filename(caplog):
def test_duplicate_file(caplog):
pipeline = Validate()
spider = spider_with_crawler()
item = File({
Expand All @@ -35,17 +35,18 @@ def test_duplicated_filename(caplog):
'data_type': '',
'url': '',
})
assert pipeline.process_item(item, spider) == item

pipeline.process_item(item, spider)
pipeline.process_item(item, spider)
assert caplog.messages[0] == 'Duplicated filename: test1'
assert len(pipeline.file_names) == 1
item2 = item.copy()
item2['file_name'] = 'file2'
pipeline.process_item(item2, spider)
assert len(pipeline.file_names) == 2

assert len(caplog.messages) == 1
assert caplog.messages[0] == "Duplicate File: 'test1'"


def test_duplicated_fileitem(caplog):
def test_duplicate_file_item(caplog):
pipeline = Validate()
spider = spider_with_crawler()
item = FileItem({
Expand All @@ -55,11 +56,12 @@ def test_duplicated_fileitem(caplog):
'url': '',
'number': 1
})
assert pipeline.process_item(item, spider) == item

pipeline.process_item(item, spider)
pipeline.process_item(item, spider)
assert caplog.messages[0] == 'Duplicated filename and number pair: test1-1'
assert len(pipeline.file_items) == 1
item2 = item.copy()
item2['number'] = 2
pipeline.process_item(item2, spider)
assert len(pipeline.file_items) == 2

assert len(caplog.messages) == 1
assert caplog.messages[0] == "Duplicate FileItem: ('test1', 1)"

0 comments on commit f0e6006

Please sign in to comment.