-
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
4 changed files
with
195 additions
and
180 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 |
---|---|---|
@@ -1,38 +1,35 @@ | ||
import unittest | ||
import pytest | ||
|
||
from dsp_permissions_scripts.models import group | ||
from dsp_permissions_scripts.utils.helpers import sort_groups | ||
|
||
# ruff: noqa: PT009 (pytest-unittest-assertion) (remove this line when pytest is used instead of unittest) | ||
|
||
|
||
class TestHelpers(unittest.TestCase): | ||
def test_sort_groups(self) -> None: | ||
groups_original = [ | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#C_CustomGroup"), | ||
group.UNKNOWN_USER, | ||
group.PROJECT_ADMIN, | ||
group.PROJECT_MEMBER, | ||
group.CREATOR, | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#A_CustomGroup"), | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#B_CustomGroup"), | ||
group.KNOWN_USER, | ||
group.SYSTEM_ADMIN, | ||
] | ||
groups_expected = [ | ||
group.SYSTEM_ADMIN, | ||
group.CREATOR, | ||
group.PROJECT_ADMIN, | ||
group.PROJECT_MEMBER, | ||
group.KNOWN_USER, | ||
group.UNKNOWN_USER, | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#A_CustomGroup"), | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#B_CustomGroup"), | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#C_CustomGroup"), | ||
] | ||
groups_returned = sort_groups(groups_original) | ||
self.assertEqual(groups_returned, groups_expected) | ||
def test_sort_groups() -> None: | ||
groups_original = [ | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#C_CustomGroup"), | ||
group.UNKNOWN_USER, | ||
group.PROJECT_ADMIN, | ||
group.PROJECT_MEMBER, | ||
group.CREATOR, | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#A_CustomGroup"), | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#B_CustomGroup"), | ||
group.KNOWN_USER, | ||
group.SYSTEM_ADMIN, | ||
] | ||
groups_expected = [ | ||
group.SYSTEM_ADMIN, | ||
group.CREATOR, | ||
group.PROJECT_ADMIN, | ||
group.PROJECT_MEMBER, | ||
group.KNOWN_USER, | ||
group.UNKNOWN_USER, | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#A_CustomGroup"), | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#B_CustomGroup"), | ||
group.Group(val="http://www.knora.org/ontology/knora-admin#C_CustomGroup"), | ||
] | ||
groups_returned = sort_groups(groups_original) | ||
assert groups_returned == groups_expected | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
pytest.main([__file__]) |
Oops, something went wrong.