Skip to content

Add __eq__ method for permissions.OperandHolder class#8710

Merged
lovelydinosaur merged 1 commit intoencode:masterfrom
janlis-ff:add-operand-holder-__eq__
Oct 17, 2022
Merged

Add __eq__ method for permissions.OperandHolder class#8710
lovelydinosaur merged 1 commit intoencode:masterfrom
janlis-ff:add-operand-holder-__eq__

Conversation

@janlis-ff
Copy link
Copy Markdown
Contributor

@janlis-ff janlis-ff commented Oct 16, 2022

The reason behind this proposal is to fully enable permission_classes comparison, e.g. in tests:

# myapp/views.py

from rest_framework.views import APIView
from rest_framework.permissions import IsAdminUser
from myapp.permissions import MyPermission


class MyView(APIView):
    permission_classes = [MyPermission | IsAdminUser]
    # ...
# myapp/tests/views/test_my_view.py

from myapp.views import MyView
from rest_framework.permissions import IsAdminUser
from myapp.permissions import MyPermission


def test__permission_classes():
    cls = MyView
    assert cls.permission_classes == [MyPermission | IsAdminUser]

I'd love to submit an actual test, but being a first-time contributor here I'm not sure where and how exactly would it fit in just by looking at tests/test_permissions.py.

Have a nice day!

@lovelydinosaur
Copy link
Copy Markdown
Contributor

🤷‍♂️. Okay.

@lovelydinosaur lovelydinosaur merged commit 0cb6937 into encode:master Oct 17, 2022
@janlis-ff janlis-ff deleted the add-operand-holder-__eq__ branch October 17, 2022 10:42
@djowett
Copy link
Copy Markdown

djowett commented Dec 3, 2024

Just a passing note while reviewing an upgrade: should this not also be added to SingleOperandHolder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants