Skip to content

Commit

Permalink
Add helpers testst
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Feb 28, 2024
1 parent 60bf878 commit 25bebc1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ckanext/keycloak/tests/test_helpers.py
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])

0 comments on commit 25bebc1

Please sign in to comment.