-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
|
||
from dsp_permissions_scripts.models.groups import BuiltinGroup | ||
from dsp_permissions_scripts.models.scope import PermissionScope | ||
|
||
|
||
class TestScope(unittest.TestCase): | ||
|
||
def test_scope_validation_on_creation(self) -> None: | ||
with self.assertRaisesRegex(ValueError, "must not occur in more than one field"): | ||
PermissionScope( | ||
CR={BuiltinGroup.PROJECT_ADMIN}, | ||
D={BuiltinGroup.PROJECT_ADMIN}, | ||
V={BuiltinGroup.UNKNOWN_USER, BuiltinGroup.KNOWN_USER}, | ||
) | ||
|
||
def test_scope_validation_on_assignment(self) -> None: | ||
scope = PermissionScope( | ||
CR={BuiltinGroup.PROJECT_ADMIN}, | ||
V={BuiltinGroup.UNKNOWN_USER, BuiltinGroup.KNOWN_USER}, | ||
) | ||
with self.assertRaisesRegex(ValueError, "must not occur in more than one field"): | ||
scope.D = frozenset({BuiltinGroup.PROJECT_ADMIN}) | ||
|
||
# def test_scope_validation_on_update(self) -> None: | ||
# scope = PermissionScope( | ||
# CR={BuiltinGroup.PROJECT_ADMIN}, | ||
# V={BuiltinGroup.UNKNOWN_USER, BuiltinGroup.KNOWN_USER}, | ||
# ) | ||
# with self.assertRaisesRegex(ValueError, "must not occur in more than one field"): | ||
# scope.D.add(BuiltinGroup.PROJECT_ADMIN) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |