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

[dev] Add customize fingerprint #280

Merged
merged 6 commits into from
Jun 5, 2023

Conversation

LuckyPigeon
Copy link
Collaborator

@LuckyPigeon LuckyPigeon commented Jun 1, 2023

Description

request_fingerprint is deprecated in Scrapy, but new fingerprint function requires a lot of changes of our code. Thus we need a customize fingerprint implementation for our own.

Unittests are also implemented, there are three new unittests

  • test_request_seen with
    • same_request
    • diff_method
    • diff_url

Fixes #272

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • pytest

Test Configuration:

  • OS version: Windows10 & WSL

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@LuckyPigeon
Copy link
Collaborator Author

@rmax
Do we need a unit test for this implementation? This function might not be called by others, right?

@LuckyPigeon LuckyPigeon enabled auto-merge (squash) June 1, 2023 18:02
@LuckyPigeon LuckyPigeon requested a review from rmax June 2, 2023 04:09
@rmax
Copy link
Owner

rmax commented Jun 4, 2023

My suggestion would be to refactor the fingerprint method logic into a function and unit test the behavior of this function:

  • two calls to the same request returns the same fingerprint,
  • the fingerprint of two different requests are different (I.e.: same url but different http method)

@LuckyPigeon
Copy link
Collaborator Author

LuckyPigeon commented Jun 5, 2023

Sounds great.

@LuckyPigeon
Copy link
Collaborator Author

LuckyPigeon commented Jun 5, 2023

@rmax done!

Copy link
Owner

@rmax rmax left a comment

Choose a reason for hiding this comment

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

Good!

@LuckyPigeon LuckyPigeon merged commit 937c537 into rmax:master Jun 5, 2023
6 checks passed
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.

Scrapy 2.8.0 deprecated function scrapy.utils.request.request_fingerprint() warning
2 participants