Browse Source
fix: correct regression w/ PermissionValue accepted values
pull/144/head
Andrei
6 years ago
No known key found for this signature in database
GPG Key ID: 4D2A02C7D500E9D9
2 changed files with
17 additions and
0 deletions
-
disco/types/permissions.py
-
tests/types/permissions.py
|
|
@ -40,6 +40,9 @@ class PermissionValue(object): |
|
|
|
__slots__ = ['value'] |
|
|
|
|
|
|
|
def __init__(self, value=0): |
|
|
|
if isinstance(value, PermissionValue): |
|
|
|
value = value.value |
|
|
|
|
|
|
|
self.value = value |
|
|
|
|
|
|
|
def can(self, *perms): |
|
|
|
|
|
@ -26,3 +26,17 @@ def test_permission_value_mutation(): |
|
|
|
|
|
|
|
no_perms.send_messages = True |
|
|
|
assert no_perms.can(Permissions.SEND_MESSAGES) |
|
|
|
|
|
|
|
|
|
|
|
def test_permission_value_accepts_permission_value(): |
|
|
|
perms = PermissionValue(Permissions.ADMINISTRATOR) |
|
|
|
|
|
|
|
new_perms = PermissionValue(perms) |
|
|
|
assert new_perms.administrator |
|
|
|
|
|
|
|
assert not new_perms.manage_channels |
|
|
|
new_perms.add(PermissionValue(Permissions.MANAGE_CHANNELS)) |
|
|
|
assert new_perms.manage_channels |
|
|
|
|
|
|
|
new_perms.sub(PermissionValue(Permissions.MANAGE_CHANNELS)) |
|
|
|
assert not new_perms.manage_channels |
|
|
|