diff --git a/common/djangoapps/student/tests/test_create_account.py b/common/djangoapps/student/tests/test_create_account.py index 2195970574..da11e8e1a6 100644 --- a/common/djangoapps/student/tests/test_create_account.py +++ b/common/djangoapps/student/tests/test_create_account.py @@ -22,7 +22,9 @@ from notification_prefs import NOTIFICATION_PREF_KEY from openedx.core.djangoapps.external_auth.models import ExternalAuthMap from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin -from openedx.core.djangoapps.user_api.accounts import USERNAME_INVALID_CHARS_ASCII, USERNAME_INVALID_CHARS_UNICODE +from openedx.core.djangoapps.user_api.accounts import ( + USERNAME_BAD_LENGTH_MSG, USERNAME_INVALID_CHARS_ASCII, USERNAME_INVALID_CHARS_UNICODE +) from openedx.core.djangoapps.user_api.preferences.api import get_user_preference from student.models import UserAttribute from student.views import REGISTRATION_AFFILIATE_ID, REGISTRATION_UTM_CREATED_AT, REGISTRATION_UTM_PARAMETERS @@ -476,16 +478,16 @@ class TestCreateAccountValidation(TestCase): # Missing del params["username"] - assert_username_error("Username must be minimum of two characters long") + assert_username_error(USERNAME_BAD_LENGTH_MSG) # Empty, too short for username in ["", "a"]: params["username"] = username - assert_username_error("Username must be minimum of two characters long") + assert_username_error(USERNAME_BAD_LENGTH_MSG) # Too long params["username"] = "this_username_has_31_characters" - assert_username_error("Username cannot be more than 30 characters long") + assert_username_error(USERNAME_BAD_LENGTH_MSG) # Invalid params["username"] = "invalid username" diff --git a/common/djangoapps/student/tests/test_long_username_email.py b/common/djangoapps/student/tests/test_long_username_email.py index b1e15adbbf..f949440ba2 100644 --- a/common/djangoapps/student/tests/test_long_username_email.py +++ b/common/djangoapps/student/tests/test_long_username_email.py @@ -5,6 +5,8 @@ import json from django.core.urlresolvers import reverse from django.test import TestCase +from openedx.core.djangoapps.user_api.accounts import USERNAME_BAD_LENGTH_MSG + class TestLongUsernameEmail(TestCase): @@ -34,7 +36,7 @@ class TestLongUsernameEmail(TestCase): obj = json.loads(response.content) self.assertEqual( obj['value'], - "Username cannot be more than 30 characters long", + USERNAME_BAD_LENGTH_MSG, ) def test_long_email(self): diff --git a/common/static/common/js/utils/edx.utils.validate.js b/common/static/common/js/utils/edx.utils.validate.js index a6af7aedff..57e7f84134 100644 --- a/common/static/common/js/utils/edx.utils.validate.js +++ b/common/static/common/js/utils/edx.utils.validate.js @@ -21,7 +21,7 @@ var _fn = { validate: { - template: _.template('