diff --git a/cms/urls.py b/cms/urls.py index 089a49f0a6293661797130143754759ac14f7321..9c92ea0dde7f198a34e4560a42b0f44e5b575c3e 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -64,7 +64,6 @@ urlpatterns = [ # noop to squelch ajax errors url(r'^event$', contentstore.views.event, name='event'), url(r'^heartbeat', include('openedx.core.djangoapps.heartbeat.urls')), - url(r'^user_api/', include('openedx.core.djangoapps.user_api.legacy_urls')), url(r'^i18n/', include('django.conf.urls.i18n')), # User API endpoints diff --git a/lms/urls.py b/lms/urls.py index 0104f9152be0065684949cf2312bcf09366d0063..840956af5be1925fbcc1780b96de8eb3f05dee43 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -83,10 +83,6 @@ urlpatterns = [ url(r'^heartbeat', include('openedx.core.djangoapps.heartbeat.urls')), - # Note: these are older versions of the User API that will eventually be - # subsumed by api/user listed below. - url(r'^user_api/', include('openedx.core.djangoapps.user_api.legacy_urls')), - url(r'^notifier_api/', include('lms.djangoapps.discussion.notifier_api.urls')), url(r'^/api/notifier/', include('lms.djangoapps.discussion.notifier_api.urls')), @@ -106,6 +102,10 @@ urlpatterns = [ # User API endpoints url(r'^api/user/', include('openedx.core.djangoapps.user_api.urls')), + # Note: these are older versions of the User API that will eventually be + # subsumed by api/user listed above. + url(r'', include('openedx.core.djangoapps.user_api.legacy_urls')), + # Profile Images API endpoints url(r'^api/profile_images/', include('openedx.core.djangoapps.profile_images.urls')), diff --git a/openedx/core/djangoapps/user_api/legacy_urls.py b/openedx/core/djangoapps/user_api/legacy_urls.py index bcb1c5bdaf48c72a34bfde768978541ee5bff4c6..33beb1f7af30f979ac7e1c87d2a28863b1bc0506 100644 --- a/openedx/core/djangoapps/user_api/legacy_urls.py +++ b/openedx/core/djangoapps/user_api/legacy_urls.py @@ -9,6 +9,7 @@ from django.conf.urls import include, url from rest_framework import routers from . import views as user_api_views +from .accounts.settings_views import account_settings from .models import UserPreference USER_API_ROUTER = routers.DefaultRouter() @@ -16,23 +17,24 @@ USER_API_ROUTER.register(r'users', user_api_views.UserViewSet) USER_API_ROUTER.register(r'user_prefs', user_api_views.UserPreferenceViewSet) urlpatterns = [ - url(r'^v1/', include(USER_API_ROUTER.urls)), + url(r'^account/settings$', account_settings, name='account_settings'), + url(r'^user_api/v1/', include(USER_API_ROUTER.urls)), url( - r'^v1/preferences/(?P<pref_key>{})/users/$'.format(UserPreference.KEY_REGEX), + r'^user_api/v1/preferences/(?P<pref_key>{})/users/$'.format(UserPreference.KEY_REGEX), user_api_views.PreferenceUsersListView.as_view() ), url( - r'^v1/forum_roles/(?P<name>[a-zA-Z]+)/users/$', + r'^user_api/v1/forum_roles/(?P<name>[a-zA-Z]+)/users/$', user_api_views.ForumRoleUsersListView.as_view() ), url( - r'^v1/preferences/email_opt_in/$', + r'^user_api/v1/preferences/email_opt_in/$', user_api_views.UpdateEmailOptInPreference.as_view(), name="preferences_email_opt_in" ), url( - r'^v1/preferences/time_zones/$', + r'^user_api/v1/preferences/time_zones/$', user_api_views.CountryTimeZoneListView.as_view(), ), ] diff --git a/openedx/core/djangoapps/user_api/tests/test_views.py b/openedx/core/djangoapps/user_api/tests/test_views.py index ffdf91bc6db2b89bd6c0f2c6c5bbd390817f031d..a0c0c3b623d8f4b057d379170e7bfbcb6a08d2e8 100644 --- a/openedx/core/djangoapps/user_api/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/tests/test_views.py @@ -108,6 +108,7 @@ class UserAPITestCase(ApiTestCase): self.assertUserIsValid(pref["user"]) +@skip_unless_lms class EmptyUserTestCase(UserAPITestCase): """ Test that the endpoint supports empty user result sets @@ -120,6 +121,7 @@ class EmptyUserTestCase(UserAPITestCase): self.assertEqual(result["results"], []) +@skip_unless_lms class EmptyRoleTestCase(UserAPITestCase): """Test that the endpoint supports empty result sets""" course_id = CourseKey.from_string("org/course/run") @@ -154,6 +156,7 @@ class UserApiTestCase(UserAPITestCase): ] +@skip_unless_lms class RoleTestCase(UserApiTestCase): """ Test cases covering Role-related views and their behaviors @@ -243,6 +246,7 @@ class RoleTestCase(UserApiTestCase): self.assertEqual(len(set(all_user_uris)), 5) +@skip_unless_lms class UserViewSetTest(UserApiTestCase): """ Test cases covering the User DRF view set class and its various behaviors @@ -360,6 +364,7 @@ class UserViewSetTest(UserApiTestCase): ) +@skip_unless_lms class UserPreferenceViewSetTest(CacheIsolationTestCase, UserApiTestCase): """ Test cases covering the User Preference DRF view class and its various behaviors @@ -505,6 +510,7 @@ class UserPreferenceViewSetTest(CacheIsolationTestCase, UserApiTestCase): ) +@skip_unless_lms class PreferenceUsersListViewTest(UserApiTestCase): """ Test cases covering the list viewing behavior for user preferences @@ -666,6 +672,7 @@ class UpdateEmailOptInTestCase(UserAPITestCase, SharedModuleStoreTestCase): @ddt.ddt +@skip_unless_lms class CountryTimeZoneListViewTest(UserApiTestCase): """ Test cases covering the list viewing behavior for country time zones diff --git a/openedx/core/djangoapps/user_authn/tests/test_cookies.py b/openedx/core/djangoapps/user_authn/tests/test_cookies.py index c362b9e1b17f776dc0541b1d02a2ae23d4e92dff..73bdc4b5c2a0715f7f26ad6acfdf9d3dc2df96df 100644 --- a/openedx/core/djangoapps/user_authn/tests/test_cookies.py +++ b/openedx/core/djangoapps/user_authn/tests/test_cookies.py @@ -13,6 +13,7 @@ from mock import MagicMock, patch from openedx.core.djangoapps.user_api.accounts.utils import retrieve_last_sitewide_block_completed from openedx.core.djangoapps.user_authn import cookies as cookies_api from openedx.core.djangoapps.user_authn.tests.utils import setup_login_oauth_client +from openedx.core.djangolib.testing.utils import skip_unless_lms from student.models import CourseEnrollment from student.tests.factories import AnonymousUserFactory, UserFactory @@ -33,16 +34,11 @@ class CookieTests(TestCase): def _get_expected_header_urls(self): expected_header_urls = { 'logout': reverse('logout'), - 'resume_block': retrieve_last_sitewide_block_completed(self.user) + 'resume_block': retrieve_last_sitewide_block_completed(self.user), + 'account_settings': reverse('account_settings'), + 'learner_profile': reverse('learner_profile', kwargs={'username': self.user.username}), } - # Studio (CMS) does not have the URLs below - if settings.ROOT_URLCONF == 'lms.urls': - expected_header_urls.update({ - 'account_settings': reverse('account_settings'), - 'learner_profile': reverse('learner_profile', kwargs={'username': self.user.username}), - }) - # Convert relative URL paths to absolute URIs for url_name, url_path in six.iteritems(expected_header_urls): expected_header_urls[url_name] = self.request.build_absolute_uri(url_path) @@ -87,6 +83,7 @@ class CookieTests(TestCase): len(set([response.cookies[c]['expires'] for c in response.cookies])), ) + @skip_unless_lms def test_get_user_info_cookie_data(self): actual = cookies_api._get_user_info_cookie_data(self.request, self.user) # pylint: disable=protected-access diff --git a/openedx/core/djangoapps/user_authn/urls.py b/openedx/core/djangoapps/user_authn/urls.py index 5d7a4aece68f31f535223c4520cedbaac334b944..0a53adcb5e9a2645ae28b78d33d5c41cdd8662f7 100644 --- a/openedx/core/djangoapps/user_authn/urls.py +++ b/openedx/core/djangoapps/user_authn/urls.py @@ -4,14 +4,10 @@ from __future__ import absolute_import from django.conf import settings from django.conf.urls import include, url -from openedx.core.djangoapps.user_api.accounts import settings_views - from .views import login, login_form -urlpatterns = [ - # TODO this should really be declared in the user_api app - url(r'^account/settings$', settings_views.account_settings, name='account_settings'), +urlpatterns = [ # TODO move contents of urls_common here once CMS no longer has its own login url(r'', include('openedx.core.djangoapps.user_authn.urls_common')), url(r'^account/finish_auth$', login.finish_auth, name='finish_auth'),