-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Fixed schema generation for filter backends #5613
Conversation
tests/test_schemas.py
Outdated
@@ -951,3 +953,36 @@ def custom_action(self, request, pk): | |||
|
|||
assert inspector.should_include_endpoint(path, callback) | |||
assert inspector.get_allowed_methods(callback) == ["GET"] | |||
|
|||
|
|||
@unittest.skipUnless(coreapi, 'coreapi is not installed') |
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.
The tests should probably use a builtin filter backend (eg, search or ordering), or skip the test if django_filters is not installed (especially since it's not a direct test dependency anymore).
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.
Fair enough. I sort of assumed it only breaks with DF, as described in the issue. I'll change that.
tests/test_schemas.py
Outdated
('foo', False), | ||
('FOO', False), | ||
] | ||
) |
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.
idk why parameterize is failing on py2k. I'd consider changing this to a class with a few test methods instead of parameterization.
tests/test_schemas.py
Outdated
) | ||
@modify_settings(INSTALLED_APPS={'append': 'django_filters'}) | ||
def test_auto_schema_allows_filters(method, expected): | ||
class AFilter(django_filters.FilterSet): |
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.
Minor nitpick: "A" and "An" prefixes don't help the understandability of the test objects. I'd probably just use Filter
and APIView
instead.
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.
I followed the pattern from that test file. There are classes like AViewSet
and AnAPIView
in the tests above.
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.
af5ec83
to
d0d51a1
Compare
Refactored the auto schema allows filters test. Removed an unused import. Removed another unused import.
d0d51a1
to
913ec16
Compare
@rpkilby I've refactored the test. The build is green now :) |
LGTM. Thanks again @D3X |
Description
This contains a test for #5594 as well as a fix for that issue.
Fixes: #5594