Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LinksSpiderError and update tests #425

Merged
merged 5 commits into from
Jun 24, 2020
Merged

Conversation

aguilerapy
Copy link
Contributor

closes #412

@aguilerapy aguilerapy requested a review from jpmckinney June 23, 2020 20:31
@aguilerapy aguilerapy marked this pull request as draft June 23, 2020 20:32
@aguilerapy aguilerapy removed the request for review from jpmckinney June 23, 2020 20:32
@aguilerapy aguilerapy changed the title Add LinksSpiderError Add LinksSpiderError and update tests Jun 23, 2020
@aguilerapy aguilerapy marked this pull request as ready for review June 23, 2020 22:00
@aguilerapy aguilerapy requested a review from jpmckinney June 23, 2020 22:00
Comment on lines 17 to 18
class LinksSpiderError(KingfisherScrapyError):
"""Raised when a next link is invalid in LinksSpider"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a more descriptive class name, since it's possible the LinksSpider will implement other exceptions in the future:

Suggested change
class LinksSpiderError(KingfisherScrapyError):
"""Raised when a next link is invalid in LinksSpider"""
class MissingNextLinkError(KingfisherScrapyError):
"""Raised when a next link is not found on the first page of results"""


with pytest.raises(KingfisherScrapyError) as e:
assert spider.next_link(response_fixture(body='{"links": {"next": ""}}'))
meta = {'file_name': 'test', 'depth': 0}
assert spider.next_link(response_fixture(meta=meta, body=body))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the assert here.

@aguilerapy aguilerapy requested a review from jpmckinney June 23, 2020 22:26
@yolile yolile merged commit 929dee2 into master Jun 24, 2020
@yolile yolile deleted the 412-update-links-spider branch June 24, 2020 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change LinksSpider to error if the next link isn't found on the first page
3 participants