Files
edx-platform/common/djangoapps/third_party_auth/tests/test_utils.py
Brittney Exline 550d2616b5 ENT-1500 Update third_party_auth pipeline to override get_username
We are doing this for two reasons:
1. We suspect that the get_username function in social_core is performing a case-sensitive
username check which is breaking when we try to create the user with a duplicate username.
This version ensures we perform a case insensitive check.

2. If it's not that, we want more logging information in order to debug the issue.
2019-03-19 17:01:29 -04:00

38 lines
1.1 KiB
Python

"""
Tests for third_party_auth utility functions.
"""
import unittest
from django.conf import settings
from third_party_auth.tests.testutil import TestCase
from third_party_auth.utils import user_exists
from student.tests.factories import UserFactory
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class TestUtils(TestCase):
"""
Test the utility functions.
"""
def test_user_exists(self):
"""
Verify that user_exists function returns correct response.
"""
# Create users from factory
UserFactory(username='test_user', email='test_user@example.com')
self.assertTrue(
user_exists({'username': 'test_user', 'email': 'test_user@example.com'}),
)
self.assertTrue(
user_exists({'username': 'test_user'}),
)
self.assertTrue(
user_exists({'email': 'test_user@example.com'}),
)
self.assertFalse(
user_exists({'username': 'invalid_user'}),
)
self.assertTrue(
user_exists({'username': 'TesT_User'})
)