From 6f118a3d8fdf645329984063cf2a1cabc334493e Mon Sep 17 00:00:00 2001 From: Andy Armstrong Date: Tue, 3 Mar 2015 15:58:21 -0500 Subject: [PATCH] Default profile visibility to off for now --- lms/envs/common.py | 2 +- .../user_api/profiles/tests/test_views.py | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 5b40e63693..c933ef9e44 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2056,7 +2056,7 @@ SEARCH_RESULT_PROCESSOR = "lms.lib.courseware_search.lms_result_processor.LmsSea PROFILE_CONFIGURATION = { # Default visibility level for accounts without a specified value # The value is one of: 'all_users', 'private' - "default_visibility": 'all_users', + "default_visibility": "private", # The list of all fields that can be shown on a learner's profile "all_fields": [ diff --git a/openedx/core/djangoapps/user_api/profiles/tests/test_views.py b/openedx/core/djangoapps/user_api/profiles/tests/test_views.py index 8341988d74..28e4377861 100644 --- a/openedx/core/djangoapps/user_api/profiles/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/profiles/tests/test_views.py @@ -7,6 +7,7 @@ import unittest from django.conf import settings from django.core.urlresolvers import reverse +from mock import patch from openedx.core.djangoapps.user_api.accounts.tests.test_views import UserAPITestCase from openedx.core.djangoapps.user_api.models import UserPreference @@ -59,6 +60,10 @@ class TestProfileAPI(UserAPITestCase): ("staff_client", "staff_user"), ) @ddt.unpack + # Note: using getattr so that the patching works even if there is no configuration. + # This is needed when testing CMS as the patching is still executed even though the + # suite is skipped. + @patch.dict(getattr(settings, "PROFILE_CONFIGURATION", {}), {"default_visibility": "all_users"}) def test_get_default_profile(self, api_client, username): """ Test that any logged in user can get the main test user's public profile information. @@ -68,6 +73,26 @@ class TestProfileAPI(UserAPITestCase): response = self.send_get(client) self._verify_full_profile_response(response) + @ddt.data( + ("client", "user"), + ("different_client", "different_user"), + ("staff_client", "staff_user"), + ) + @ddt.unpack + # Note: using getattr so that the patching works even if there is no configuration. + # This is needed when testing CMS as the patching is still executed even though the + # suite is skipped. + @patch.dict(getattr(settings, "PROFILE_CONFIGURATION", {}), {"default_visibility": "private"}) + def test_get_default_private_profile(self, api_client, username): + """ + Test that any logged in user gets only the public fields for a profile + if the default visibility is 'private'. + """ + client = self.login_client(api_client, username) + self.create_mock_profile(self.user) + response = self.send_get(client) + self._verify_private_profile_response(response) + @ddt.data( ("client", "user"), ("different_client", "different_user"),