-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test create user and group with minted IDs
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright©2021, Regents of the University of California | ||
# http://creativecommons.org/licenses/BSD | ||
|
||
"""Test the minter data modle | ||
""" | ||
import pytest | ||
import logging | ||
from django.core.exceptions import ValidationError | ||
|
||
import django.conf | ||
import ezidapp.models.group | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class TestGropu: | ||
def test_1_create_group(self, caplog): | ||
"""test - Create group with group ID minted on Agent shoulder""" | ||
caplog.set_level(logging.INFO) | ||
|
||
next_spin = '154dv8s' | ||
expected_pid = f'{django.conf.settings.SHOULDERS_AGENT}{next_spin}' | ||
|
||
assert not ezidapp.models.group.Group.objects.filter( | ||
pid=expected_pid | ||
).exists() | ||
|
||
group = ezidapp.models.group.Group( | ||
groupname='testgroup', | ||
organizationName = "Test Group", | ||
realm_id = 1, | ||
) | ||
with pytest.raises(ValidationError) as exc_info: | ||
group.full_clean() | ||
|
||
group.save() | ||
|
||
assert ezidapp.models.group.Group.objects.filter( | ||
pid=expected_pid | ||
).exists() | ||
|
||
group = ezidapp.models.group.Group.objects.get(pid=expected_pid) | ||
|
||
assert group.pid == expected_pid | ||
assert group.groupname == 'testgroup' | ||
assert group.organizationName == 'Test Group' | ||
assert group.realm_id == 1 | ||
|
||
|
||
|
||
|
||
|
||
|
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,56 @@ | ||
# Copyright©2021, Regents of the University of California | ||
# http://creativecommons.org/licenses/BSD | ||
|
||
"""Test the minter data modle | ||
""" | ||
import pytest | ||
import logging | ||
from django.core.exceptions import ValidationError | ||
|
||
import django.conf | ||
import ezidapp.models.user | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class TestUser: | ||
def test_1_create_user(self, caplog): | ||
"""test - Create user with user ID minted on Agent shoulder""" | ||
caplog.set_level(logging.INFO) | ||
|
||
next_spin = '154dv8s' | ||
expected_pid = f'{django.conf.settings.SHOULDERS_AGENT}{next_spin}' | ||
|
||
assert not ezidapp.models.user.User.objects.filter( | ||
pid=expected_pid | ||
).exists() | ||
|
||
user = ezidapp.models.user.User( | ||
username='testuser', | ||
displayName = "Test User", | ||
group_id = 2, | ||
realm_id = 1, | ||
) | ||
with pytest.raises(ValidationError) as exc_info: | ||
user.full_clean() | ||
|
||
user.save() | ||
|
||
assert ezidapp.models.user.User.objects.filter( | ||
pid=expected_pid | ||
).exists() | ||
|
||
user = ezidapp.models.user.User.objects.get(pid=expected_pid) | ||
|
||
assert user.pid == expected_pid | ||
assert user.username == 'testuser' | ||
assert user.displayName == 'Test User' | ||
assert user.group_id == 2 | ||
assert user.realm_id == 1 | ||
assert user.accountEmail == '' | ||
assert user.password != '' | ||
|
||
|
||
|
||
|
||
|
||
|