AA-177: Add masquerading for course home MFE
- Looks at masquerading config for dates, outline, metadata, and celebration APIs in course_home_api / courseware_api. - Consolidates and cleans up places we check whether masquerading gives us full access to a course.
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
Contains tests to verify correctness of course expiration functionality
|
||||
"""
|
||||
|
||||
|
||||
import json
|
||||
from datetime import timedelta
|
||||
|
||||
import ddt
|
||||
@@ -14,7 +12,6 @@ from django.urls import reverse
|
||||
from django.utils.timezone import now
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from experiments.models import ExperimentData
|
||||
from lms.djangoapps.courseware.tests.factories import (
|
||||
BetaTesterFactory,
|
||||
GlobalStaffFactory,
|
||||
@@ -23,6 +20,7 @@ from lms.djangoapps.courseware.tests.factories import (
|
||||
OrgStaffFactory,
|
||||
StaffFactory
|
||||
)
|
||||
from lms.djangoapps.courseware.tests.helpers import MasqueradeMixin
|
||||
from lms.djangoapps.discussion.django_comment_client.tests.factories import RoleFactory
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.course_date_signals.utils import MAX_DURATION, MIN_DURATION
|
||||
@@ -46,7 +44,7 @@ from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class CourseExpirationTestCase(ModuleStoreTestCase):
|
||||
class CourseExpirationTestCase(ModuleStoreTestCase, MasqueradeMixin):
|
||||
"""Tests to verify the get_user_course_expiration_date function is working correctly"""
|
||||
def setUp(self):
|
||||
super(CourseExpirationTestCase, self).setUp()
|
||||
@@ -57,7 +55,8 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
|
||||
self.THREE_YEARS_AGO = now() - timedelta(days=(365 * 3))
|
||||
|
||||
# Make this a verified course so we can test expiration date
|
||||
add_course_mode(self.course, upgrade_deadline_expired=False)
|
||||
add_course_mode(self.course, mode_slug=CourseMode.AUDIT)
|
||||
add_course_mode(self.course)
|
||||
|
||||
def tearDown(self):
|
||||
CourseEnrollment.unenroll(self.user, self.course.id)
|
||||
@@ -223,29 +222,6 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
|
||||
else:
|
||||
self.assertNotContains(response, banner_text)
|
||||
|
||||
def update_masquerade(self, role='student', group_id=None, username=None, user_partition_id=None):
|
||||
"""
|
||||
Toggle masquerade state.
|
||||
"""
|
||||
masquerade_url = reverse(
|
||||
'masquerade_update',
|
||||
kwargs={
|
||||
'course_key_string': six.text_type(self.course.id),
|
||||
}
|
||||
)
|
||||
response = self.client.post(
|
||||
masquerade_url,
|
||||
json.dumps({
|
||||
'role': role,
|
||||
'group_id': group_id,
|
||||
'user_name': username,
|
||||
'user_partition_id': user_partition_id,
|
||||
}),
|
||||
'application/json'
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
return response
|
||||
|
||||
@mock.patch("openedx.core.djangoapps.course_date_signals.utils.get_course_run_details")
|
||||
def test_masquerade_in_holdback(self, mock_get_course_run_details):
|
||||
mock_get_course_run_details.return_value = {'weeks_to_complete': 12}
|
||||
|
||||
@@ -74,13 +74,10 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase):
|
||||
user = self.user
|
||||
course_key = self.course_overview.id
|
||||
|
||||
query_count = 6
|
||||
query_count = 7
|
||||
|
||||
with self.assertNumQueries(query_count):
|
||||
enabled = CourseDurationLimitConfig.enabled_for_enrollment(
|
||||
user=user,
|
||||
course_key=course_key,
|
||||
)
|
||||
enabled = CourseDurationLimitConfig.enabled_for_enrollment(user, self.course_overview)
|
||||
self.assertEqual(not enrolled_before_enabled, enabled)
|
||||
|
||||
def test_enabled_for_enrollment_failure(self):
|
||||
|
||||
Reference in New Issue
Block a user