-
Notifications
You must be signed in to change notification settings - Fork 1
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
990a16a
commit d3669cf
Showing
23 changed files
with
1,232 additions
and
573 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 |
---|---|---|
|
@@ -56,6 +56,5 @@ docs/_build/ | |
.pytest_cache | ||
coverage.xml | ||
|
||
Pipfile | ||
Pipfile.lock | ||
celerybeat.pid | ||
celerybeat.pid | ||
.cache |
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
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
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 |
---|---|---|
|
@@ -90,9 +90,11 @@ | |
AUTH_USER_MODEL = "demo.User" | ||
|
||
CONSTANCE_CONFIG = { | ||
"DEFAULT_GROUP": ("", "test_grp"), | ||
"DEFAULT_GROUP": ("test_grp", "Test Group"), | ||
} | ||
|
||
CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend" | ||
|
||
LOGOUT_URL = "/" | ||
|
||
ADMINS = (("Me", "[email protected]"),) |
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,7 +1,63 @@ | ||
from django.urls import reverse | ||
from mock import patch | ||
import pytest | ||
|
||
from demo.admin import UserPlus | ||
from demo.models import User | ||
from unicef_security.admin import UNICEFUserFilter | ||
from .factories import UserFactory | ||
|
||
def test_changelist(django_app, admin_user): | ||
url = reverse("admin:demo_user_changelist") | ||
res = django_app.get(url, user=admin_user) | ||
|
||
@pytest.mark.django_db | ||
@patch("unicef_security.admin.Synchronizer.get_token") | ||
@patch("unicef_security.admin.Synchronizer.get_user") | ||
@patch("unicef_security.admin.Synchronizer.sync_user") | ||
@patch("unicef_security.admin.Synchronizer.search_users") | ||
def test_link_user_data(patch1, patch2, patch3, patch4, app): | ||
user = UserFactory() | ||
url = reverse("admin:demo_user_link_user_data", args=[user.pk]) | ||
res = app.post(url) | ||
assert res.status_code == 200 | ||
|
||
|
||
@pytest.mark.django_db | ||
@patch("unicef_security.admin.Synchronizer.get_token") | ||
@patch("unicef_security.admin.Synchronizer.fetch_users") | ||
def test_link_load(patch1, patch2, app): | ||
url = reverse("admin:demo_user_load") | ||
res = app.post(url) | ||
assert res.status_code == 200 | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_unicef_admin_filter(): | ||
UserFactory(email="[email protected]", username="[email protected]") | ||
UserFactory(email="[email protected]", username="[email protected]") | ||
qs = User.objects.all() | ||
assert qs.count() == 2 | ||
|
||
filters = UNICEFUserFilter( | ||
None, | ||
{ | ||
"email": [ | ||
"unicef", | ||
] | ||
}, | ||
User, | ||
UserPlus, | ||
) | ||
unicef_records = filters.queryset(None, qs) | ||
assert unicef_records.count() == 1 | ||
|
||
filters = UNICEFUserFilter( | ||
None, | ||
{ | ||
"email": [ | ||
"external", | ||
] | ||
}, | ||
User, | ||
UserPlus, | ||
) | ||
external_records = filters.queryset(None, qs) | ||
assert external_records.count() == 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
Oops, something went wrong.