-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Place Content-encoding header into response's flags is desired #1988 #4025
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4025 +/- ##
==========================================
+ Coverage 85.43% 85.69% +0.25%
==========================================
Files 167 165 -2
Lines 9732 9739 +7
Branches 1456 1464 +8
==========================================
+ Hits 8315 8346 +31
+ Misses 1159 1136 -23
+ Partials 258 257 -1
|
@Gallaecio I did some of the changes you recommended but wasn't sure which tests should get what parameters so this will fail the tests but wanted to see if I pulled the right parts out for a separate function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_spider_mw
looks fine to me. Maybe you could set default values for the two parameters, the values that are most common in the tests, so that you can write less code later.
Got defaults now. The header values are in bytes it looks like from the |
I have the if statement for putting in |
I think it’s on the same level, but I am not 100%, I’m not familiar with this part of the code base yet. In any case, tests (existing and new) should tell whether or not you made the right choice. |
Not sure where to remove or change things to test with different values testing with or without headers removed. |
I think the way to go now is to remove the
Then you can add new tests covering your changes that also call that function, but use parameter values different from the defaults when needed for your test cases. |
Okay I'll have to work on that a little bit at a time through out the week. |
Isn't setup function an inherited function from unittest that needs to be filled out for it to work? |
The setup method only needs to be defined to to set up stuff that is common to all tests in the class. This was the right way to define the spider and middleware, since the same spider and middleware was used in every test. Now that we want to add tests that use a different spider and middleware, you can remove that function and instead create a spider and a middleware in each test method. Alternatively, and to minimize changes, you could leave existing tests as they are and leave the setup method as is, and simply use a different spider and middleware in your new tests that require one. It will actually make for a cleaner patch, so it is probably a good idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments, but the key one is the last, about how you use create_spider_mw
in your new tests.
It has been a while, and I need to review my review 😅 This needs also a documentation change for the new setting, as well as taking into account backward compatibility for users subclassing the middleware. |
created #5290 |
Fixes #1988
Threw up some trash not completely knowing what I was doing but got help from some other contributors on this project and hope this will be acceptable.
I added the ability to keep the 'Content-Encoding' header value in a response as a member of the 'flag' attribute of a response.