-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add endpoints to viewsets #163
Conversation
Not sure who I should mark as reviewers so I just marked you @sergei-maertens but feel free to add others and/or remove yourself :) |
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.
Please review the remaining tests with the remarks so that they are corrected everywhere.
In short - you seem to be doing quite a lot "manually" in the code that is actually (mostly) handled by the frameworks and libraries already - use that to do more with less code!
Additionally, the way of writing tests deserves some more attention.
def create(self, validated_data): | ||
validated_data["form"] = get_object_or_404( | ||
Form, uuid=self.context["view"].kwargs["form_uuid"] | ||
) |
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.
If the Form
doesn't exist when trying to create a FormStep
then this code would be reached since there didn't seem to be anywhere that validates a Form
exists for a given uuid. This seemed the best place to raise a 404 in that case though I'm happy to hear other options. :)
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.
yeah, it seems to be a limitation of the nested viewset library used in this project. Perhaps we should replace it with the one used in Open Zaak, that one seems to be more feature complete. So we can keep this for now.
It's just very nasty in this particular case (not your fault) that the serializer has to be aware of the view's URL keywords, that's violating two abstraction levels.
6c4dcec
to
956f3c4
Compare
# TODO: Axes requires HttpRequest, should we have that in the API at all? | ||
assert self.client.login( | ||
request=HttpRequest(), username=self.user.username, password="secret" | ||
) |
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.
you can use self.client.force_authenticate
to simplify this, we don't actually care about the particular credentials here
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.
Ah, good to remember for the future :)
Implements the API points of https://github.com/maykinmedia/open-forms/issues/138. The front end points will be done in a separate pull request.