manager: test user free search for local and e164 phones (#69907)
gitea/authentic/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Paul Marillonnet 2022-10-17 15:18:15 +02:00
parent 3e53e2ecf8
commit 5fd1c9d2f4
1 changed files with 34 additions and 0 deletions

View File

@ -306,6 +306,40 @@ def test_search_by_attribute(app, simple_user, admin):
assert visible_users(response) == set()
def test_search_by_phone_local_number(app, simple_user, admin, settings):
settings.DEFAULT_COUNTRY_CODE = '33'
Attribute.objects.create(
kind='phone_number', name='phone', label='Phone', required=False, searchable=True
)
simple_user.attributes.phone = '+33612345678'
simple_user.save()
response = login(app, admin, '/manage/users/')
# all users are visible
assert visible_users(response) == {simple_user.username, admin.username}
response.form['search-text'] = '9876543210'
response = response.form.submit()
# now all users are hidden
assert not visible_users(response) & {simple_user.username, admin.username}
response.form['search-text'] = '0612345678'
response = response.form.submit()
# now we see only simple_user
assert visible_users(response) == {simple_user.username}
response.form['search-text'] = '+33612345678'
response = response.form.submit()
assert visible_users(response) == {simple_user.username}
simple_user.delete()
response.form['search-text'] = '0612345678'
response = response.form.submit()
assert visible_users(response) == set()
def test_export_csv(settings, app, superuser, django_assert_num_queries):
AT_COUNT = 30
USER_COUNT = 2000