Skip to content

do not raise on offers that do not match the media type ABNF#372

Merged
digitalresistor merged 6 commits into
Pylons:masterfrom
mmerickel:ignore-invalid-offers
Sep 6, 2018
Merged

do not raise on offers that do not match the media type ABNF#372
digitalresistor merged 6 commits into
Pylons:masterfrom
mmerickel:ignore-invalid-offers

Conversation

@mmerickel
Copy link
Copy Markdown
Member

fixes #365

Copy link
Copy Markdown
Member

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Optional suggestion for changelog only.

Comment thread CHANGES.txt Outdated
@mmerickel mmerickel force-pushed the ignore-invalid-offers branch from 3a268b1 to 47aa53c Compare September 4, 2018 00:16
@mmerickel mmerickel force-pushed the ignore-invalid-offers branch from 47aa53c to a68637d Compare September 4, 2018 00:16
Comment thread CHANGES.txt Outdated
Comment thread src/webob/acceptparse.py Outdated
Comment thread src/webob/acceptparse.py
Comment thread src/webob/acceptparse.py Outdated
Comment thread src/webob/acceptparse.py Outdated
Comment thread src/webob/acceptparse.py
Comment thread src/webob/acceptparse.py
Comment thread src/webob/acceptparse.py
@digitalresistor digitalresistor merged commit 00c66f7 into Pylons:master Sep 6, 2018
Comment thread tests/test_acceptparse.py
AcceptNoHeader(),
['text/html', 'text/plain;p=1;q=0.5;e=1', 'foo'],
[('text/html', 1.0)],
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test is under the test class TestAcceptValidHeader — could the AcceptNoHeader and AcceptInvalidHeader tests be moved to their respective test classes? And if we create the header within the test as in the other tests, we can remove the header test parameter, save on repetition, and the AcceptNoHeader and AcceptInvalidHeader can then be tested with the exactly same four cases as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd be fine with moving the test to somewhere else but I want the examples kept together because the point of this test is to make sure that all 3 variants filter invalid offers in the same way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But we could say that about all the other tests in the module where the behaviour needs to be consistent across the three header classes, so all the tests would need to be bound together. If you want that to be changed for all the tests to make sure they don't go out-of-sync with each other, that can be done, but as things are right now this test stands out as completely different from how all the tests around it are done and organised, such that we (or anyone else) wouldn't know to look for the tests for AcceptInvalidHeader and AcceptNoHeader under TestAcceptValidHeader.

Or if this is uniquely important, I could submit a PR to move the tests to their own test class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it made sense to me to group them, but if it's inconsistent with your test suite then I think it's fine if you want to break them apart

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very much understand your reasoning, it's just that that's not how all the other tests are arranged. Will submit PR tomorrow - thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bertjwregeer But is that still binding the tests for AcceptValidHeader, AcceptNoHeader and AcceptInvalidHeader together in TestAcceptValidHeader? I was just going to place the tests in TestAcceptValidHeader, TestAcceptNoHeader and TestAcceptInvalidHeader, as has been done for all the other tests in the rest of the module. I understand the reasoning behind keeping the tests together to ensure a consistent API, but then we'd need to go through all the other tests for all the four headers and do the same?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's fine for now, but we may be able to have some tests that are collapsed so that we can make sure there are no regressions moving forward where someone accidentally changes something in 2 of the 3 for example.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I submitted the PR to move the tests into their separate test classes for now. Should we open an issue for binding the tests together? If you don't consider it urgent, I can work on it when I have time. I'm thinking move all Accept-header-related tests into one TestAccept class, and test 2 or 3 of the classes together where appropriate — is that what you have in mind?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the grouping on these few tests was just to ensure consistency on the same inputs being filtered the same way. I don't have a strong opinion on reorganizing the rest of the suite.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems like it'd be a good idea, as we need the api to be consistent across the three classes, and I think there are more methods like this one that would benefit from having the tests be grouped together. There are other, more urgent issues right now that I'd like to work on first, but I can submit a PR at some point so you can see if you think it helps.

@whiteroses
Copy link
Copy Markdown
Contributor

Thank you for fixing this @mmerickel!

digitalresistor added a commit that referenced this pull request Oct 15, 2018
do not raise on offers that do not match the media type ABNF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate media types consistently in acceptable_offers

4 participants