-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
60bf878
commit 25bebc1
Showing
1 changed file
with
33 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,33 @@ | ||
import pytest | ||
import ckan.model as model | ||
import ckan.tests.factories as factories | ||
from ckanext.keycloak import helpers as h | ||
|
||
|
||
def test_generate_password(): | ||
password = h.generate_password() | ||
assert len(password) >= 8 | ||
assert type(password) is str | ||
|
||
|
||
@pytest.mark.usefixtures(u'clean_db', u'clean_index') | ||
def test_activate_user_if_deleted(): | ||
user = factories.User() | ||
user = model.User.get(user[u'name']) | ||
user.delete() | ||
h.activate_user_if_deleted(user) | ||
assert not user.is_deleted() | ||
|
||
|
||
@pytest.mark.usefixtures(u'clean_db') | ||
def test_ensure_unique_user_name_existing_user(): | ||
|
||
user = factories.User( | ||
name='existing-user', | ||
email=u'[email protected]' | ||
) | ||
|
||
user_name = h.ensure_unique_username_from_email(user['email']) | ||
|
||
assert user_name != user['email'].split('@')[0] | ||
assert user_name.startswith(user['email'].split('@')[0]) |