-
-
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
Using ViewSet.as_view() in test results in AttributeError #2171
Comments
Have you tried something like: view = MyViewSet.as_view({'get': 'retrieve'})
uri = reverse(...)
request = my_APIFactory.get(uri)
response = view(request) The viewset docs might be helpful too. |
Surprised it actually worked at all without following @Ian-Foote's suggestion... May be that we should ensure |
@tomchristie agree with you. |
Sorry to confuse: it doesn't work, at all, without passing the action mapping directly. However, doing so makes it easy for the test to diverge from the reality of the routed view. So I've taken to using Is it just me, or does the view-calling testing strategy seem rather clunky? I end up passing args/kwargs to |
What do you get then, in this case? |
The |
@tdavis , Actually, the examples that you posted was told in the document of
you can use Here is a list of mapping relationship by default:
You can custom the mapping by overwriting The
Is it clear for you now? link: |
Thanks for the report, now resolved as #2175. |
I feel like I must be doing something stupid since this is all over the documentation, but it has never worked for me:
This test (with zero-argument call to
as_view()
) always fails with the TB:I mean, this makes sense looking at the code: the
actions
argument defaults toNone
but gets no other value, anditems()
is eventually called on it. What am I missing? How canactions
be optional?The text was updated successfully, but these errors were encountered: