From 84d91a7901d75f9197969436aac3d2ad3cb7fc42 Mon Sep 17 00:00:00 2001 From: cahrens Date: Tue, 3 Mar 2015 16:16:20 -0500 Subject: [PATCH 1/2] Correctly point to MAX_LENGTH instead of MIN_LENGTH. Bug introduced in recent commit. --- openedx/core/djangoapps/user_api/api/profile.py | 5 +++++ openedx/core/djangoapps/user_api/tests/test_views.py | 5 ++--- openedx/core/djangoapps/user_api/views.py | 4 +--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/openedx/core/djangoapps/user_api/api/profile.py b/openedx/core/djangoapps/user_api/api/profile.py index 28de57068c..371e4a4186 100644 --- a/openedx/core/djangoapps/user_api/api/profile.py +++ b/openedx/core/djangoapps/user_api/api/profile.py @@ -14,6 +14,7 @@ from pytz import UTC import analytics from eventtracking import tracker +from ..accounts import NAME_MIN_LENGTH from ..accounts.views import AccountView from ..models import User, UserPreference, UserOrgTag from ..helpers import intercept_errors @@ -36,6 +37,10 @@ class ProfileInternalError(Exception): pass +FULL_NAME_MAX_LENGTH = 255 +FULL_NAME_MIN_LENGTH = NAME_MIN_LENGTH + + @intercept_errors(ProfileInternalError, ignore_errors=[ProfileRequestError]) def preference_info(username): """Retrieve information about a user's preferences. diff --git a/openedx/core/djangoapps/user_api/tests/test_views.py b/openedx/core/djangoapps/user_api/tests/test_views.py index c9c841527e..3d11542e38 100644 --- a/openedx/core/djangoapps/user_api/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/tests/test_views.py @@ -28,7 +28,6 @@ from ..api import account as account_api, profile as profile_api from ..models import UserOrgTag from ..tests.factories import UserPreferenceFactory from ..tests.test_constants import SORTED_COUNTRIES -from openedx.core.djangoapps.user_api.accounts import NAME_MIN_LENGTH TEST_API_KEY = "test_api_key" @@ -842,7 +841,7 @@ class RegistrationViewTest(ApiTestCase): u"label": u"Full name", u"instructions": u"The name that will appear on your certificates", u"restrictions": { - "max_length": NAME_MIN_LENGTH, + "max_length": profile_api.FULL_NAME_MAX_LENGTH, }, } ) @@ -922,7 +921,7 @@ class RegistrationViewTest(ApiTestCase): u"label": u"Full name", u"instructions": u"The name that will appear on your certificates", u"restrictions": { - "max_length": NAME_MIN_LENGTH + "max_length": profile_api.FULL_NAME_MAX_LENGTH, } } ) diff --git a/openedx/core/djangoapps/user_api/views.py b/openedx/core/djangoapps/user_api/views.py index 0a93898c5a..929c7133d1 100644 --- a/openedx/core/djangoapps/user_api/views.py +++ b/openedx/core/djangoapps/user_api/views.py @@ -33,8 +33,6 @@ from .helpers import FormDescription, shim_student_view, require_post_params from .models import UserPreference, UserProfile from .serializers import UserSerializer, UserPreferenceSerializer -from openedx.core.djangoapps.user_api.accounts import NAME_MIN_LENGTH - class LoginSessionView(APIView): """HTTP end-points for logging in users. """ @@ -352,7 +350,7 @@ class RegistrationView(APIView): label=name_label, instructions=name_instructions, restrictions={ - "max_length": NAME_MIN_LENGTH, + "max_length": profile_api.FULL_NAME_MAX_LENGTH, }, required=required ) From 167bd05ac823a3f495bebc282ac67e055a6304c6 Mon Sep 17 00:00:00 2001 From: cahrens Date: Tue, 3 Mar 2015 17:16:47 -0500 Subject: [PATCH 2/2] Add bok choy coverage for correctly displayed name and email address. --- common/test/acceptance/pages/lms/dashboard.py | 15 +++++++++++++++ common/test/acceptance/tests/lms/test_lms.py | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/common/test/acceptance/pages/lms/dashboard.py b/common/test/acceptance/pages/lms/dashboard.py index 4404a8f7ad..9aaeee09e8 100644 --- a/common/test/acceptance/pages/lms/dashboard.py +++ b/common/test/acceptance/pages/lms/dashboard.py @@ -51,6 +51,21 @@ class DashboardPage(PageObject): return self.q(css='section.info > hgroup > h3 > a').map(_get_course_name).results + @property + def full_name(self): + """Return the displayed value for the user's full name""" + return self.q(css='li.info--username .data').text[0] + + @property + def email(self): + """Return the displayed value for the user's email address""" + return self.q(css='li.info--email .data').text[0] + + @property + def username(self): + """Return the displayed value for the user's username""" + return self.q(css='h1.user-name').text[0] + def get_enrollment_mode(self, course_name): """Get the enrollment mode for a given course on the dashboard. diff --git a/common/test/acceptance/tests/lms/test_lms.py b/common/test/acceptance/tests/lms/test_lms.py index 567efc79ed..9d1a33ac33 100644 --- a/common/test/acceptance/tests/lms/test_lms.py +++ b/common/test/acceptance/tests/lms/test_lms.py @@ -170,6 +170,10 @@ class RegisterFromCombinedPageTest(UniqueCourseTest): course_names = self.dashboard_page.wait_for_page().available_courses self.assertIn(self.course_info["display_name"], course_names) + self.assertEqual("Test User", self.dashboard_page.full_name) + self.assertEqual(email, self.dashboard_page.email) + self.assertEqual(username, self.dashboard_page.username) + def test_register_failure(self): # Navigate to the registration page self.register_page.visit()