Switch to SharedModuleStoreTestCase in the 'courseware' app where possible.
This commit is contained in:
@@ -41,29 +41,34 @@ SHIB_ERROR_STR = "The currently logged-in user account does not have permission
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, EventTrackingTestCase, MilestonesTestCaseMixin):
|
||||
class AboutTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase, EventTrackingTestCase, MilestonesTestCaseMixin):
|
||||
"""
|
||||
Tests about xblock.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(AboutTestCase, self).setUp()
|
||||
self.course = CourseFactory.create()
|
||||
self.about = ItemFactory.create(
|
||||
category="about", parent_location=self.course.location,
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AboutTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.course_without_about = CourseFactory.create(catalog_visibility=CATALOG_VISIBILITY_NONE)
|
||||
cls.course_with_about = CourseFactory.create(catalog_visibility=CATALOG_VISIBILITY_ABOUT)
|
||||
cls.purchase_course = CourseFactory.create(org='MITx', number='buyme', display_name='Course To Buy')
|
||||
cls.about = ItemFactory.create(
|
||||
category="about", parent_location=cls.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="overview"
|
||||
)
|
||||
self.course_without_about = CourseFactory.create(catalog_visibility=CATALOG_VISIBILITY_NONE)
|
||||
self.about = ItemFactory.create(
|
||||
category="about", parent_location=self.course_without_about.location,
|
||||
cls.about = ItemFactory.create(
|
||||
category="about", parent_location=cls.course_without_about.location,
|
||||
data="WITHOUT ABOUT", display_name="overview"
|
||||
)
|
||||
self.course_with_about = CourseFactory.create(catalog_visibility=CATALOG_VISIBILITY_ABOUT)
|
||||
self.about = ItemFactory.create(
|
||||
category="about", parent_location=self.course_with_about.location,
|
||||
cls.about = ItemFactory.create(
|
||||
category="about", parent_location=cls.course_with_about.location,
|
||||
data="WITH ABOUT", display_name="overview"
|
||||
)
|
||||
|
||||
self.purchase_course = CourseFactory.create(org='MITx', number='buyme', display_name='Course To Buy')
|
||||
def setUp(self):
|
||||
super(AboutTestCase, self).setUp()
|
||||
|
||||
self.course_mode = CourseMode(
|
||||
course_id=self.purchase_course.id,
|
||||
mode_slug=CourseMode.DEFAULT_MODE_SLUG,
|
||||
@@ -152,7 +157,7 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, EventTrackingT
|
||||
def test_about_page_unfulfilled_prereqs(self):
|
||||
pre_requisite_course = CourseFactory.create(
|
||||
org='edX',
|
||||
course='900',
|
||||
course='901',
|
||||
display_name='pre requisite course',
|
||||
)
|
||||
|
||||
@@ -222,21 +227,24 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""
|
||||
This test case will check the About page when a course has a capped enrollment
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AboutWithCappedEnrollmentsTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(metadata={"max_student_enrollments_allowed": 1})
|
||||
cls.about = ItemFactory.create(
|
||||
category="about", parent_location=cls.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="overview"
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the tests
|
||||
"""
|
||||
super(AboutWithCappedEnrollmentsTestCase, self).setUp()
|
||||
self.course = CourseFactory.create(metadata={"max_student_enrollments_allowed": 1})
|
||||
|
||||
self.about = ItemFactory.create(
|
||||
category="about", parent_location=self.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="overview"
|
||||
)
|
||||
|
||||
def test_enrollment_cap(self):
|
||||
"""
|
||||
@@ -272,20 +280,22 @@ class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, ModuleStoreTes
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class AboutWithInvitationOnly(ModuleStoreTestCase):
|
||||
class AboutWithInvitationOnly(SharedModuleStoreTestCase):
|
||||
"""
|
||||
This test case will check the About page when a course is invitation only.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(AboutWithInvitationOnly, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create(metadata={"invitation_only": True})
|
||||
|
||||
self.about = ItemFactory.create(
|
||||
category="about", parent_location=self.course.location,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AboutWithInvitationOnly, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(metadata={"invitation_only": True})
|
||||
cls.about = ItemFactory.create(
|
||||
category="about", parent_location=cls.course.location,
|
||||
display_name="overview"
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(AboutWithInvitationOnly, self).setUp()
|
||||
|
||||
def test_invitation_only(self):
|
||||
"""
|
||||
Test for user not logged in, invitation only course.
|
||||
@@ -320,19 +330,22 @@ class AboutWithInvitationOnly(ModuleStoreTestCase):
|
||||
|
||||
@attr('shard_1')
|
||||
@patch.dict(settings.FEATURES, {'RESTRICT_ENROLL_BY_REG_METHOD': True})
|
||||
class AboutTestCaseShibCourse(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class AboutTestCaseShibCourse(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""
|
||||
Test cases covering about page behavior for courses that use shib enrollment domain ("shib courses")
|
||||
"""
|
||||
def setUp(self):
|
||||
super(AboutTestCaseShibCourse, self).setUp()
|
||||
self.course = CourseFactory.create(enrollment_domain="shib:https://idp.stanford.edu/")
|
||||
|
||||
self.about = ItemFactory.create(
|
||||
category="about", parent_location=self.course.location,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AboutTestCaseShibCourse, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(enrollment_domain="shib:https://idp.stanford.edu/")
|
||||
cls.about = ItemFactory.create(
|
||||
category="about", parent_location=cls.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="overview"
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(AboutTestCaseShibCourse, self).setUp()
|
||||
|
||||
def test_logged_in_shib_course(self):
|
||||
"""
|
||||
For shib courses, logged in users will see the enroll button, but get rejected once they click there
|
||||
@@ -366,8 +379,8 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
|
||||
set but it is currently outside of that period.
|
||||
"""
|
||||
def setUp(self):
|
||||
|
||||
super(AboutWithClosedEnrollment, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create(metadata={"invitation_only": False})
|
||||
|
||||
# Setup enrollment period to be in future
|
||||
@@ -385,7 +398,6 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
|
||||
)
|
||||
|
||||
def test_closed_enrollmement(self):
|
||||
|
||||
url = reverse('about_course', args=[self.course.id.to_deprecated_string()])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
@@ -406,15 +418,32 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
|
||||
@attr('shard_1')
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_SHOPPING_CART': True})
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_PAID_COURSE_REGISTRATION': True})
|
||||
class AboutPurchaseCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class AboutPurchaseCourseTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""
|
||||
This test class runs through a suite of verifications regarding
|
||||
purchaseable courses
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AboutPurchaseCourseTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(org='MITx', number='buyme', display_name='Course To Buy')
|
||||
|
||||
now = datetime.datetime.now(pytz.UTC)
|
||||
tomorrow = now + datetime.timedelta(days=1)
|
||||
nextday = tomorrow + datetime.timedelta(days=1)
|
||||
|
||||
cls.closed_course = CourseFactory.create(
|
||||
org='MITx',
|
||||
number='closed',
|
||||
display_name='Closed Course To Buy',
|
||||
enrollment_start = tomorrow,
|
||||
enrollment_end = nextday
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(AboutPurchaseCourseTestCase, self).setUp()
|
||||
self.course = CourseFactory.create(org='MITx', number='buyme', display_name='Course To Buy')
|
||||
self._set_ecomm(self.course)
|
||||
self._set_ecomm(self.closed_course)
|
||||
|
||||
def _set_ecomm(self, course):
|
||||
"""
|
||||
@@ -487,19 +516,12 @@ class AboutPurchaseCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
window
|
||||
"""
|
||||
self.setup_user()
|
||||
now = datetime.datetime.now(pytz.UTC)
|
||||
tomorrow = now + datetime.timedelta(days=1)
|
||||
nextday = tomorrow + datetime.timedelta(days=1)
|
||||
|
||||
self.course.enrollment_start = tomorrow
|
||||
self.course.enrollment_end = nextday
|
||||
self.course = self.update_course(self.course, self.user.id)
|
||||
|
||||
url = reverse('about_course', args=[self.course.id.to_deprecated_string()])
|
||||
url = reverse('about_course', args=[self.closed_course.id.to_deprecated_string()])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn("Enrollment is Closed", resp.content)
|
||||
self.assertNotIn("Add buyme to Cart <span>($10 USD)</span>", resp.content)
|
||||
self.assertNotIn("Add closed to Cart <span>($10 USD)</span>", resp.content)
|
||||
|
||||
# course price is visible ihe course_about page when the course
|
||||
# mode is set to honor and it's price is set
|
||||
|
||||
@@ -30,18 +30,22 @@ from lms.djangoapps.ccx.tests.factories import CcxFactory
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class CourseInfoTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class CourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""
|
||||
Tests for the Course Info page
|
||||
"""
|
||||
def setUp(self):
|
||||
super(CourseInfoTestCase, self).setUp()
|
||||
self.course = CourseFactory.create()
|
||||
self.page = ItemFactory.create(
|
||||
category="course_info", parent_location=self.course.location,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(CourseInfoTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.page = ItemFactory.create(
|
||||
category="course_info", parent_location=cls.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="updates"
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(CourseInfoTestCase, self).setUp()
|
||||
|
||||
def test_logged_in_unenrolled(self):
|
||||
self.setup_user()
|
||||
url = reverse('info', args=[self.course.id.to_deprecated_string()])
|
||||
@@ -203,11 +207,15 @@ class SelfPacedCourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTest
|
||||
Tests for the info page of self-paced courses.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SelfPacedCourseInfoTestCase, cls).setUpClass()
|
||||
cls.instructor_paced_course = CourseFactory.create(self_paced=False)
|
||||
cls.self_paced_course = CourseFactory.create(self_paced=True)
|
||||
|
||||
def setUp(self):
|
||||
SelfPacedConfiguration(enabled=True).save()
|
||||
super(SelfPacedCourseInfoTestCase, self).setUp()
|
||||
self.instructor_paced_course = CourseFactory.create(self_paced=False)
|
||||
self.self_paced_course = CourseFactory.create(self_paced=True)
|
||||
self.setup_user()
|
||||
|
||||
def fetch_course_info_with_queries(self, course, sql_queries, mongo_queries):
|
||||
|
||||
@@ -13,27 +13,42 @@ from survey.models import SurveyForm, SurveyAnswer
|
||||
|
||||
from common.test.utils import XssTestMixin
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from courseware.tests.helpers import LoginEnrollmentTestCase
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class SurveyViewsTests(LoginEnrollmentTestCase, ModuleStoreTestCase, XssTestMixin):
|
||||
class SurveyViewsTests(LoginEnrollmentTestCase, SharedModuleStoreTestCase, XssTestMixin):
|
||||
"""
|
||||
All tests for the views.py file
|
||||
"""
|
||||
|
||||
STUDENT_INFO = [('view@test.com', 'foo')]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SurveyViewsTests, cls).setUpClass()
|
||||
cls.test_survey_name = 'TestSurvey'
|
||||
cls.course = CourseFactory.create(
|
||||
display_name='<script>alert("XSS")</script>',
|
||||
course_survey_required=True,
|
||||
course_survey_name=cls.test_survey_name
|
||||
)
|
||||
|
||||
cls.course_with_bogus_survey = CourseFactory.create(
|
||||
course_survey_required=True,
|
||||
course_survey_name="DoesNotExist"
|
||||
)
|
||||
|
||||
cls.course_without_survey = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the test data used in the specific tests
|
||||
"""
|
||||
super(SurveyViewsTests, self).setUp()
|
||||
|
||||
self.test_survey_name = 'TestSurvey'
|
||||
self.test_form = '<input name="field1"></input>'
|
||||
|
||||
self.survey = SurveyForm.create(self.test_survey_name, self.test_form)
|
||||
|
||||
self.student_answers = OrderedDict({
|
||||
@@ -41,19 +56,6 @@ class SurveyViewsTests(LoginEnrollmentTestCase, ModuleStoreTestCase, XssTestMixi
|
||||
u'field2': u'value2',
|
||||
})
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
display_name='<script>alert("XSS")</script>',
|
||||
course_survey_required=True,
|
||||
course_survey_name=self.test_survey_name
|
||||
)
|
||||
|
||||
self.course_with_bogus_survey = CourseFactory.create(
|
||||
course_survey_required=True,
|
||||
course_survey_name="DoesNotExist"
|
||||
)
|
||||
|
||||
self.course_without_survey = CourseFactory.create()
|
||||
|
||||
# Create student accounts and activate them.
|
||||
for i in range(len(self.STUDENT_INFO)):
|
||||
email, password = self.STUDENT_INFO[i]
|
||||
|
||||
@@ -11,7 +11,7 @@ from pytz import UTC
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from student.tests.factories import UserFactory, CourseEnrollmentFactory
|
||||
from util.date_utils import get_time_display, DEFAULT_SHORT_DATE_FORMAT
|
||||
@@ -23,7 +23,7 @@ from openedx.core.djangoapps.credit.models import CreditCourse
|
||||
|
||||
@patch.dict(settings.FEATURES, {"ENABLE_CREDIT_ELIGIBILITY": True})
|
||||
@ddt.ddt
|
||||
class ProgressPageCreditRequirementsTest(ModuleStoreTestCase):
|
||||
class ProgressPageCreditRequirementsTest(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Tests for credit requirement display on the progress page.
|
||||
"""
|
||||
@@ -35,11 +35,15 @@ class ProgressPageCreditRequirementsTest(ModuleStoreTestCase):
|
||||
MIN_GRADE_REQ_DISPLAY = "Final Grade Credit Requirement"
|
||||
VERIFICATION_REQ_DISPLAY = "Midterm Exam Credit Requirement"
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(ProgressPageCreditRequirementsTest, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(ProgressPageCreditRequirementsTest, self).setUp()
|
||||
|
||||
# Create a course and configure it as a credit course
|
||||
self.course = CourseFactory.create()
|
||||
# Configure course as a credit course
|
||||
CreditCourse.objects.create(course_key=self.course.id, enabled=True)
|
||||
|
||||
# Configure credit requirements (passing grade and in-course reverification)
|
||||
|
||||
@@ -9,7 +9,7 @@ from xblock.field_data import DictFieldData
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import (
|
||||
ModuleStoreTestCase,
|
||||
)
|
||||
SharedModuleStoreTestCase)
|
||||
|
||||
from ..field_overrides import (
|
||||
disable_overrides,
|
||||
|
||||
@@ -28,7 +28,7 @@ from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
|
||||
from student.tests.factories import UserFactory
|
||||
from student.models import CourseEnrollment
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
|
||||
|
||||
def _grade_with_errors(student, request, course, keep_raw_scores=False):
|
||||
@@ -46,23 +46,27 @@ def _grade_with_errors(student, request, course, keep_raw_scores=False):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TestGradeIteration(ModuleStoreTestCase):
|
||||
class TestGradeIteration(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Test iteration through student gradesets.
|
||||
"""
|
||||
COURSE_NUM = "1000"
|
||||
COURSE_NAME = "grading_test_course"
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestGradeIteration, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(
|
||||
display_name=cls.COURSE_NAME,
|
||||
number=cls.COURSE_NUM
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create a course and a handful of users to assign grades
|
||||
"""
|
||||
super(TestGradeIteration, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
display_name=self.COURSE_NAME,
|
||||
number=self.COURSE_NUM
|
||||
)
|
||||
self.students = [
|
||||
UserFactory.create(username='student1'),
|
||||
UserFactory.create(username='student2'),
|
||||
@@ -142,19 +146,24 @@ class TestGradeIteration(ModuleStoreTestCase):
|
||||
return students_to_gradesets, students_to_errors
|
||||
|
||||
|
||||
class TestMaxScoresCache(ModuleStoreTestCase):
|
||||
class TestMaxScoresCache(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Tests for the MaxScoresCache
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestMaxScoresCache, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.problems = []
|
||||
for _ in xrange(3):
|
||||
cls.problems.append(
|
||||
ItemFactory.create(category='problem', parent=cls.course)
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestMaxScoresCache, self).setUp()
|
||||
self.student = UserFactory.create()
|
||||
self.course = CourseFactory.create()
|
||||
self.problems = []
|
||||
for _ in xrange(3):
|
||||
self.problems.append(
|
||||
ItemFactory.create(category='problem', parent=self.course)
|
||||
)
|
||||
|
||||
CourseEnrollment.enroll(self.student, self.course.id)
|
||||
self.request = RequestFactory().get('/')
|
||||
@@ -183,16 +192,16 @@ class TestMaxScoresCache(ModuleStoreTestCase):
|
||||
self.assertEqual(max_scores_cache.num_cached_from_remote(), 1)
|
||||
|
||||
|
||||
class TestFieldDataCacheScorableLocations(ModuleStoreTestCase):
|
||||
class TestFieldDataCacheScorableLocations(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Make sure we can filter the locations we pull back student state for via
|
||||
the FieldDataCache.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestFieldDataCacheScorableLocations, self).setUp()
|
||||
self.student = UserFactory.create()
|
||||
self.course = CourseFactory.create()
|
||||
chapter = ItemFactory.create(category='chapter', parent=self.course)
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestFieldDataCacheScorableLocations, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
chapter = ItemFactory.create(category='chapter', parent=cls.course)
|
||||
sequential = ItemFactory.create(category='sequential', parent=chapter)
|
||||
vertical = ItemFactory.create(category='vertical', parent=sequential)
|
||||
ItemFactory.create(category='video', parent=vertical)
|
||||
@@ -200,6 +209,10 @@ class TestFieldDataCacheScorableLocations(ModuleStoreTestCase):
|
||||
ItemFactory.create(category='discussion', parent=vertical)
|
||||
ItemFactory.create(category='problem', parent=vertical)
|
||||
|
||||
def setUp(self):
|
||||
super(TestFieldDataCacheScorableLocations, self).setUp()
|
||||
self.student = UserFactory.create()
|
||||
|
||||
CourseEnrollment.enroll(self.student, self.course.id)
|
||||
|
||||
def test_field_data_cache_scorable_locations(self):
|
||||
@@ -334,45 +347,43 @@ class TestProgressSummary(TestCase):
|
||||
self.assertEqual(possible, 0)
|
||||
|
||||
|
||||
class TestGetModuleScore(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""
|
||||
Test get_module_score
|
||||
"""
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up test course
|
||||
"""
|
||||
super(TestGetModuleScore, self).setUp()
|
||||
self.course = CourseFactory.create()
|
||||
self.chapter = ItemFactory.create(
|
||||
parent=self.course,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestGetModuleScore, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.chapter = ItemFactory.create(
|
||||
parent=cls.course,
|
||||
category="chapter",
|
||||
display_name="Test Chapter"
|
||||
)
|
||||
self.seq1 = ItemFactory.create(
|
||||
parent=self.chapter,
|
||||
cls.seq1 = ItemFactory.create(
|
||||
parent=cls.chapter,
|
||||
category='sequential',
|
||||
display_name="Test Sequential",
|
||||
graded=True
|
||||
)
|
||||
self.seq2 = ItemFactory.create(
|
||||
parent=self.chapter,
|
||||
cls.seq2 = ItemFactory.create(
|
||||
parent=cls.chapter,
|
||||
category='sequential',
|
||||
display_name="Test Sequential",
|
||||
graded=True
|
||||
)
|
||||
self.vert1 = ItemFactory.create(
|
||||
parent=self.seq1,
|
||||
cls.vert1 = ItemFactory.create(
|
||||
parent=cls.seq1,
|
||||
category='vertical',
|
||||
display_name='Test Vertical 1'
|
||||
)
|
||||
self.vert2 = ItemFactory.create(
|
||||
parent=self.seq2,
|
||||
cls.vert2 = ItemFactory.create(
|
||||
parent=cls.seq2,
|
||||
category='vertical',
|
||||
display_name='Test Vertical 2'
|
||||
)
|
||||
self.randomize = ItemFactory.create(
|
||||
parent=self.vert2,
|
||||
cls.randomize = ItemFactory.create(
|
||||
parent=cls.vert2,
|
||||
category='randomize',
|
||||
display_name='Test Randomize'
|
||||
)
|
||||
@@ -381,31 +392,37 @@ class TestGetModuleScore(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
choices=[False, False, True, False],
|
||||
choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3']
|
||||
)
|
||||
self.problem1 = ItemFactory.create(
|
||||
parent=self.vert1,
|
||||
cls.problem1 = ItemFactory.create(
|
||||
parent=cls.vert1,
|
||||
category="problem",
|
||||
display_name="Test Problem 1",
|
||||
data=problem_xml
|
||||
)
|
||||
self.problem2 = ItemFactory.create(
|
||||
parent=self.vert1,
|
||||
cls.problem2 = ItemFactory.create(
|
||||
parent=cls.vert1,
|
||||
category="problem",
|
||||
display_name="Test Problem 2",
|
||||
data=problem_xml
|
||||
)
|
||||
self.problem3 = ItemFactory.create(
|
||||
parent=self.randomize,
|
||||
cls.problem3 = ItemFactory.create(
|
||||
parent=cls.randomize,
|
||||
category="problem",
|
||||
display_name="Test Problem 3",
|
||||
data=problem_xml
|
||||
)
|
||||
self.problem4 = ItemFactory.create(
|
||||
parent=self.randomize,
|
||||
cls.problem4 = ItemFactory.create(
|
||||
parent=cls.randomize,
|
||||
category="problem",
|
||||
display_name="Test Problem 4",
|
||||
data=problem_xml
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up test course
|
||||
"""
|
||||
super(TestGetModuleScore, self).setUp()
|
||||
|
||||
self.request = get_request_for_user(UserFactory())
|
||||
self.client.login(username=self.request.user.username, password="test")
|
||||
CourseEnrollment.enroll(self.request.user, self.course.id)
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.core.urlresolvers import reverse
|
||||
from courseware.tests import BaseTestXmodule
|
||||
from courseware.views import get_course_lti_endpoints
|
||||
from lms.djangoapps.lms_xblock.runtime import quote_slashes
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.x_module import STUDENT_VIEW
|
||||
|
||||
@@ -125,7 +125,7 @@ class TestLTI(BaseTestXmodule):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TestLTIModuleListing(ModuleStoreTestCase):
|
||||
class TestLTIModuleListing(SharedModuleStoreTestCase):
|
||||
"""
|
||||
a test for the rest endpoint that lists LTI modules in a course
|
||||
"""
|
||||
@@ -133,42 +133,46 @@ class TestLTIModuleListing(ModuleStoreTestCase):
|
||||
COURSE_SLUG = "100"
|
||||
COURSE_NAME = "test_course"
|
||||
|
||||
def setUp(self):
|
||||
"""Create course, 2 chapters, 2 sections"""
|
||||
super(TestLTIModuleListing, self).setUp()
|
||||
self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)
|
||||
self.chapter1 = ItemFactory.create(
|
||||
parent_location=self.course.location,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestLTIModuleListing, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(display_name=cls.COURSE_NAME, number=cls.COURSE_SLUG)
|
||||
cls.chapter1 = ItemFactory.create(
|
||||
parent_location=cls.course.location,
|
||||
display_name="chapter1",
|
||||
category='chapter')
|
||||
self.section1 = ItemFactory.create(
|
||||
parent_location=self.chapter1.location,
|
||||
cls.section1 = ItemFactory.create(
|
||||
parent_location=cls.chapter1.location,
|
||||
display_name="section1",
|
||||
category='sequential')
|
||||
self.chapter2 = ItemFactory.create(
|
||||
parent_location=self.course.location,
|
||||
cls.chapter2 = ItemFactory.create(
|
||||
parent_location=cls.course.location,
|
||||
display_name="chapter2",
|
||||
category='chapter')
|
||||
self.section2 = ItemFactory.create(
|
||||
parent_location=self.chapter2.location,
|
||||
cls.section2 = ItemFactory.create(
|
||||
parent_location=cls.chapter2.location,
|
||||
display_name="section2",
|
||||
category='sequential')
|
||||
|
||||
# creates one draft and one published lti module, in different sections
|
||||
self.lti_published = ItemFactory.create(
|
||||
parent_location=self.section1.location,
|
||||
cls.lti_published = ItemFactory.create(
|
||||
parent_location=cls.section1.location,
|
||||
display_name="lti published",
|
||||
category="lti",
|
||||
location=self.course.id.make_usage_key('lti', 'lti_published'),
|
||||
location=cls.course.id.make_usage_key('lti', 'lti_published'),
|
||||
)
|
||||
self.lti_draft = ItemFactory.create(
|
||||
parent_location=self.section2.location,
|
||||
cls.lti_draft = ItemFactory.create(
|
||||
parent_location=cls.section2.location,
|
||||
display_name="lti draft",
|
||||
category="lti",
|
||||
location=self.course.id.make_usage_key('lti', 'lti_draft'),
|
||||
location=cls.course.id.make_usage_key('lti', 'lti_draft'),
|
||||
publish_item=False,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
"""Create course, 2 chapters, 2 sections"""
|
||||
super(TestLTIModuleListing, self).setUp()
|
||||
|
||||
def expected_handler_url(self, handler):
|
||||
"""convenience method to get the reversed handler urls"""
|
||||
return "https://{}{}".format(settings.SITE_NAME, reverse(
|
||||
|
||||
@@ -25,40 +25,36 @@ from courseware.tests.test_submitting_problems import ProblemSubmissionTestMixin
|
||||
from student.tests.factories import UserFactory
|
||||
from xblock.runtime import DictKeyValueStore
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory
|
||||
from xmodule.partitions.partitions import Group, UserPartition
|
||||
|
||||
|
||||
class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Base class for masquerade tests that sets up a test course and enrolls a user in the course.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(MasqueradeTestCase, self).setUp()
|
||||
|
||||
# By default, tests run with DISABLE_START_DATES=True. To test that masquerading as a student is
|
||||
# working properly, we must use start dates and set a start date in the past (otherwise the access
|
||||
# checks exist prematurely).
|
||||
self.course = CourseFactory.create(number='masquerade-test', metadata={'start': datetime.now(UTC())})
|
||||
# Creates info page and puts random data in it for specific student info page test
|
||||
self.info_page = ItemFactory.create(
|
||||
category="course_info", parent_location=self.course.location,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(MasqueradeTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(number='masquerade-test', metadata={'start': datetime.now(UTC())})
|
||||
cls.info_page = ItemFactory.create(
|
||||
category="course_info", parent_location=cls.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="updates"
|
||||
)
|
||||
self.chapter = ItemFactory.create(
|
||||
parent_location=self.course.location,
|
||||
cls.chapter = ItemFactory.create(
|
||||
parent_location=cls.course.location,
|
||||
category="chapter",
|
||||
display_name="Test Section",
|
||||
)
|
||||
self.sequential_display_name = "Test Masquerade Subsection"
|
||||
self.sequential = ItemFactory.create(
|
||||
parent_location=self.chapter.location,
|
||||
cls.sequential_display_name = "Test Masquerade Subsection"
|
||||
cls.sequential = ItemFactory.create(
|
||||
parent_location=cls.chapter.location,
|
||||
category="sequential",
|
||||
display_name=self.sequential_display_name,
|
||||
display_name=cls.sequential_display_name,
|
||||
)
|
||||
self.vertical = ItemFactory.create(
|
||||
parent_location=self.sequential.location,
|
||||
cls.vertical = ItemFactory.create(
|
||||
parent_location=cls.sequential.location,
|
||||
category="vertical",
|
||||
display_name="Test Unit",
|
||||
)
|
||||
@@ -69,13 +65,17 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
options=['Correct', 'Incorrect'],
|
||||
correct_option='Correct'
|
||||
)
|
||||
self.problem_display_name = "TestMasqueradeProblem"
|
||||
self.problem = ItemFactory.create(
|
||||
parent_location=self.vertical.location,
|
||||
cls.problem_display_name = "TestMasqueradeProblem"
|
||||
cls.problem = ItemFactory.create(
|
||||
parent_location=cls.vertical.location,
|
||||
category='problem',
|
||||
data=problem_xml,
|
||||
display_name=self.problem_display_name
|
||||
display_name=cls.problem_display_name
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(MasqueradeTestCase, self).setUp()
|
||||
|
||||
self.test_user = self.create_user()
|
||||
self.login(self.test_user.email, 'test')
|
||||
self.enroll(self.course, True)
|
||||
|
||||
@@ -11,51 +11,42 @@ from course_modes.models import CourseMode
|
||||
from xmodule.course_module import (
|
||||
CATALOG_VISIBILITY_CATALOG_AND_ABOUT, CATALOG_VISIBILITY_NONE)
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
class TestMicrosites(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
This is testing of the Microsite feature
|
||||
"""
|
||||
|
||||
STUDENT_INFO = [('view@test.com', 'foo'), ('view2@test.com', 'foo')]
|
||||
|
||||
def setUp(self):
|
||||
super(TestMicrosites, self).setUp()
|
||||
|
||||
# use a different hostname to test Microsites since they are
|
||||
# triggered on subdomain mappings
|
||||
#
|
||||
# NOTE: The Microsite Configuration is in lms/envs/test.py. The content for the Test Microsite is in
|
||||
# test_microsites/test_microsite.
|
||||
#
|
||||
# IMPORTANT: For these tests to work, this domain must be defined via
|
||||
# DNS configuration (either local or published)
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestMicrosites, cls).setUpClass()
|
||||
cls.course = CourseFactory.create(
|
||||
display_name='Robot_Super_Course',
|
||||
org='TestMicrositeX',
|
||||
emit_signals=True,
|
||||
)
|
||||
self.chapter0 = ItemFactory.create(parent_location=self.course.location,
|
||||
cls.chapter0 = ItemFactory.create(parent_location=cls.course.location,
|
||||
display_name='Overview')
|
||||
self.chapter9 = ItemFactory.create(parent_location=self.course.location,
|
||||
cls.chapter9 = ItemFactory.create(parent_location=cls.course.location,
|
||||
display_name='factory_chapter')
|
||||
self.section0 = ItemFactory.create(parent_location=self.chapter0.location,
|
||||
cls.section0 = ItemFactory.create(parent_location=cls.chapter0.location,
|
||||
display_name='Welcome')
|
||||
self.section9 = ItemFactory.create(parent_location=self.chapter9.location,
|
||||
cls.section9 = ItemFactory.create(parent_location=cls.chapter9.location,
|
||||
display_name='factory_section')
|
||||
|
||||
self.course_outside_microsite = CourseFactory.create(
|
||||
cls.course_outside_microsite = CourseFactory.create(
|
||||
display_name='Robot_Course_Outside_Microsite',
|
||||
org='FooX',
|
||||
emit_signals=True,
|
||||
)
|
||||
|
||||
# have a course which explicitly sets visibility in catalog to False
|
||||
self.course_hidden_visibility = CourseFactory.create(
|
||||
cls.course_hidden_visibility = CourseFactory.create(
|
||||
display_name='Hidden_course',
|
||||
org='TestMicrositeX',
|
||||
catalog_visibility=CATALOG_VISIBILITY_NONE,
|
||||
@@ -63,7 +54,7 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
)
|
||||
|
||||
# have a course which explicitly sets visibility in catalog and about to true
|
||||
self.course_with_visibility = CourseFactory.create(
|
||||
cls.course_with_visibility = CourseFactory.create(
|
||||
display_name='visible_course',
|
||||
org='TestMicrositeX',
|
||||
course="foo",
|
||||
@@ -71,6 +62,9 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
emit_signals=True,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestMicrosites, self).setUp()
|
||||
|
||||
def setup_users(self):
|
||||
# Create student accounts and activate them.
|
||||
for i in range(len(self.STUDENT_INFO)):
|
||||
|
||||
@@ -10,19 +10,22 @@ from nose.plugins.attrib import attr
|
||||
|
||||
import courseware.courses as courses
|
||||
from courseware.middleware import RedirectUnenrolledMiddleware
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class CoursewareMiddlewareTestCase(ModuleStoreTestCase):
|
||||
class CoursewareMiddlewareTestCase(SharedModuleStoreTestCase):
|
||||
"""Tests that courseware middleware is correctly redirected"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(CoursewareMiddlewareTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(CoursewareMiddlewareTestCase, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
def check_user_not_enrolled_redirect(self):
|
||||
"""A UserNotEnrolled exception should trigger a redirect"""
|
||||
request = RequestFactory().get("dummy_url")
|
||||
|
||||
@@ -45,7 +45,7 @@ from student.models import anonymous_id_for_user
|
||||
from xmodule.modulestore.tests.django_utils import (
|
||||
TEST_DATA_MIXED_TOY_MODULESTORE,
|
||||
TEST_DATA_XML_MODULESTORE,
|
||||
)
|
||||
SharedModuleStoreTestCase)
|
||||
from xmodule.lti_module import LTIDescriptor
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -121,10 +121,17 @@ class GradedStatelessXBlock(XBlock):
|
||||
|
||||
@attr('shard_1')
|
||||
@ddt.ddt
|
||||
class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
class ModuleRenderTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Tests of courseware.module_render
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(ModuleRenderTestCase, cls).setUpClass()
|
||||
cls.course_key = ToyCourseFactory.create().id
|
||||
cls.toy_course = modulestore().get_course(cls.course_key)
|
||||
|
||||
# TODO: this test relies on the specific setup of the toy course.
|
||||
# It should be rewritten to build the course it needs and then test that.
|
||||
def setUp(self):
|
||||
@@ -133,8 +140,6 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
super(ModuleRenderTestCase, self).setUp()
|
||||
|
||||
self.course_key = ToyCourseFactory.create().id
|
||||
self.toy_course = modulestore().get_course(self.course_key)
|
||||
self.mock_user = UserFactory()
|
||||
self.mock_user.id = 1
|
||||
self.request_factory = RequestFactory()
|
||||
@@ -401,17 +406,20 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TestHandleXBlockCallback(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
class TestHandleXBlockCallback(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Test the handle_xblock_callback function
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestHandleXBlockCallback, cls).setUpClass()
|
||||
cls.course_key = ToyCourseFactory.create().id
|
||||
cls.toy_course = modulestore().get_course(cls.course_key)
|
||||
|
||||
def setUp(self):
|
||||
super(TestHandleXBlockCallback, self).setUp()
|
||||
|
||||
self.course_key = ToyCourseFactory.create().id
|
||||
self.location = self.course_key.make_usage_key('chapter', 'Overview')
|
||||
self.toy_course = modulestore().get_course(self.course_key)
|
||||
self.mock_user = UserFactory.create()
|
||||
self.request_factory = RequestFactory()
|
||||
|
||||
@@ -709,19 +717,24 @@ class TestTOC(ModuleStoreTestCase):
|
||||
@attr('shard_1')
|
||||
@ddt.ddt
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_SPECIAL_EXAMS': True})
|
||||
class TestProctoringRendering(ModuleStoreTestCase):
|
||||
class TestProctoringRendering(SharedModuleStoreTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestProctoringRendering, cls).setUpClass()
|
||||
cls.course_key = ToyCourseFactory.create().id
|
||||
|
||||
"""Check the Table of Contents for a course"""
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the initial mongo datastores
|
||||
"""
|
||||
super(TestProctoringRendering, self).setUp()
|
||||
self.course_key = ToyCourseFactory.create().id
|
||||
self.chapter = 'Overview'
|
||||
chapter_url = '%s/%s/%s' % ('/courses', self.course_key, self.chapter)
|
||||
factory = RequestFactory()
|
||||
self.request = factory.get(chapter_url)
|
||||
self.request.user = UserFactory()
|
||||
self.request.user = UserFactory.create()
|
||||
self.user = UserFactory.create()
|
||||
self.modulestore = self.store._get_modulestore_for_courselike(self.course_key) # pylint: disable=protected-access
|
||||
with self.modulestore.bulk_operations(self.course_key):
|
||||
self.toy_course = self.store.get_course(self.course_key, depth=2)
|
||||
@@ -1028,7 +1041,15 @@ class TestProctoringRendering(ModuleStoreTestCase):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TestGatedSubsectionRendering(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
class TestGatedSubsectionRendering(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestGatedSubsectionRendering, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.course.enable_subsection_gating = True
|
||||
cls.course.save()
|
||||
cls.store.update_item(cls.course, 0)
|
||||
|
||||
"""
|
||||
Test the toc for a course is rendered correctly when there is gated content
|
||||
"""
|
||||
@@ -1038,10 +1059,6 @@ class TestGatedSubsectionRendering(ModuleStoreTestCase, MilestonesTestCaseMixin)
|
||||
"""
|
||||
super(TestGatedSubsectionRendering, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
self.course.enable_subsection_gating = True
|
||||
self.course.save()
|
||||
self.store.update_item(self.course, 0)
|
||||
self.chapter = ItemFactory.create(
|
||||
parent=self.course,
|
||||
category="chapter",
|
||||
@@ -1113,11 +1130,10 @@ class TestHtmlModifiers(ModuleStoreTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestHtmlModifiers, self).setUp()
|
||||
self.user = UserFactory.create()
|
||||
self.course = CourseFactory.create()
|
||||
self.request = RequestFactory().get('/')
|
||||
self.request.user = self.user
|
||||
self.request.session = {}
|
||||
self.course = CourseFactory.create()
|
||||
self.content_string = '<p>This is the content<p>'
|
||||
self.rewrite_link = '<a href="/static/foo/content">Test rewrite</a>'
|
||||
self.rewrite_bad_link = '<img src="/static//file.jpg" />'
|
||||
@@ -1447,16 +1463,20 @@ class DetachedXBlock(XBlock):
|
||||
@attr('shard_1')
|
||||
@patch.dict('django.conf.settings.FEATURES', {'DISPLAY_DEBUG_INFO_TO_STAFF': True, 'DISPLAY_HISTOGRAMS_TO_STAFF': True})
|
||||
@patch('courseware.module_render.has_access', Mock(return_value=True, autospec=True))
|
||||
class TestStaffDebugInfo(ModuleStoreTestCase):
|
||||
class TestStaffDebugInfo(SharedModuleStoreTestCase):
|
||||
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestStaffDebugInfo, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(TestStaffDebugInfo, self).setUp()
|
||||
self.user = UserFactory.create()
|
||||
self.request = RequestFactory().get('/')
|
||||
self.request.user = self.user
|
||||
self.request.session = {}
|
||||
self.course = CourseFactory.create()
|
||||
|
||||
problem_xml = OptionResponseXMLFactory().build_xml(
|
||||
question_text='The correct answer is Correct',
|
||||
@@ -1589,16 +1609,20 @@ PER_STUDENT_ANONYMIZED_DESCRIPTORS = set(
|
||||
|
||||
@attr('shard_1')
|
||||
@ddt.ddt
|
||||
class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
class TestAnonymousStudentId(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Test that anonymous_student_id is set correctly across a variety of XBlock types
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAnonymousStudentId, cls).setUpClass()
|
||||
cls.course_key = ToyCourseFactory.create().id
|
||||
cls.course = modulestore().get_course(cls.course_key)
|
||||
|
||||
def setUp(self):
|
||||
super(TestAnonymousStudentId, self).setUp(create_user=False)
|
||||
super(TestAnonymousStudentId, self).setUp()
|
||||
self.user = UserFactory()
|
||||
self.course_key = ToyCourseFactory.create().id
|
||||
self.course = modulestore().get_course(self.course_key)
|
||||
|
||||
@patch('courseware.module_render.has_access', Mock(return_value=True, autospec=True))
|
||||
def _get_anonymous_id(self, course_id, xblock_class):
|
||||
@@ -1668,11 +1692,16 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
|
||||
@attr('shard_1')
|
||||
@patch('track.views.tracker', autospec=True)
|
||||
class TestModuleTrackingContext(ModuleStoreTestCase):
|
||||
class TestModuleTrackingContext(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Ensure correct tracking information is included in events emitted during XBlock callback handling.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestModuleTrackingContext, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(TestModuleTrackingContext, self).setUp()
|
||||
|
||||
@@ -1926,10 +1955,16 @@ class TestEventPublishing(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
|
||||
@attr('shard_1')
|
||||
@ddt.ddt
|
||||
class LMSXBlockServiceBindingTest(ModuleStoreTestCase):
|
||||
class LMSXBlockServiceBindingTest(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Tests that the LMS Module System (XBlock Runtime) provides an expected set of services.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(LMSXBlockServiceBindingTest, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the user and other fields that will be used to instantiate the runtime.
|
||||
@@ -1937,7 +1972,6 @@ class LMSXBlockServiceBindingTest(ModuleStoreTestCase):
|
||||
super(LMSXBlockServiceBindingTest, self).setUp()
|
||||
self.user = UserFactory()
|
||||
self.student_data = Mock()
|
||||
self.course = CourseFactory.create()
|
||||
self.track_function = Mock()
|
||||
self.xqueue_callback_url_prefix = Mock()
|
||||
self.request_token = Mock()
|
||||
@@ -2012,16 +2046,21 @@ USER_NUMBERS = range(2)
|
||||
|
||||
@attr('shard_1')
|
||||
@ddt.ddt
|
||||
class TestFilteredChildren(ModuleStoreTestCase):
|
||||
class TestFilteredChildren(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Tests that verify access to XBlock/XModule children work correctly
|
||||
even when those children are filtered by the runtime when loaded.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestFilteredChildren, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init, no-member
|
||||
def setUp(self):
|
||||
super(TestFilteredChildren, self).setUp()
|
||||
self.users = {number: UserFactory() for number in USER_NUMBERS}
|
||||
self.course = CourseFactory()
|
||||
|
||||
self._old_has_access = render.has_access
|
||||
patcher = patch('courseware.module_render.has_access', self._has_access)
|
||||
|
||||
@@ -11,56 +11,60 @@ from django.test.utils import override_settings
|
||||
|
||||
from courseware.tests.helpers import LoginEnrollmentTestCase
|
||||
from courseware.tests.factories import GlobalStaffFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TestNavigation(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
class TestNavigation(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Check that navigation state is saved properly.
|
||||
"""
|
||||
|
||||
STUDENT_INFO = [('view@test.com', 'foo'), ('view2@test.com', 'foo')]
|
||||
|
||||
def setUp(self):
|
||||
super(TestNavigation, self).setUp()
|
||||
self.test_course = CourseFactory.create()
|
||||
self.course = CourseFactory.create()
|
||||
self.chapter0 = ItemFactory.create(parent=self.course,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestNavigation, cls).setUpClass()
|
||||
cls.test_course = CourseFactory.create()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.chapter0 = ItemFactory.create(parent=cls.course,
|
||||
display_name='Overview')
|
||||
self.chapter9 = ItemFactory.create(parent=self.course,
|
||||
cls.chapter9 = ItemFactory.create(parent=cls.course,
|
||||
display_name='factory_chapter')
|
||||
self.section0 = ItemFactory.create(parent=self.chapter0,
|
||||
cls.section0 = ItemFactory.create(parent=cls.chapter0,
|
||||
display_name='Welcome')
|
||||
self.section9 = ItemFactory.create(parent=self.chapter9,
|
||||
cls.section9 = ItemFactory.create(parent=cls.chapter9,
|
||||
display_name='factory_section')
|
||||
self.unit0 = ItemFactory.create(parent=self.section0,
|
||||
cls.unit0 = ItemFactory.create(parent=cls.section0,
|
||||
display_name='New Unit')
|
||||
|
||||
self.chapterchrome = ItemFactory.create(parent=self.course,
|
||||
cls.chapterchrome = ItemFactory.create(parent=cls.course,
|
||||
display_name='Chrome')
|
||||
self.chromelesssection = ItemFactory.create(parent=self.chapterchrome,
|
||||
cls.chromelesssection = ItemFactory.create(parent=cls.chapterchrome,
|
||||
display_name='chromeless',
|
||||
chrome='none')
|
||||
self.accordionsection = ItemFactory.create(parent=self.chapterchrome,
|
||||
cls.accordionsection = ItemFactory.create(parent=cls.chapterchrome,
|
||||
display_name='accordion',
|
||||
chrome='accordion')
|
||||
self.tabssection = ItemFactory.create(parent=self.chapterchrome,
|
||||
cls.tabssection = ItemFactory.create(parent=cls.chapterchrome,
|
||||
display_name='tabs',
|
||||
chrome='tabs')
|
||||
self.defaultchromesection = ItemFactory.create(
|
||||
parent=self.chapterchrome,
|
||||
cls.defaultchromesection = ItemFactory.create(
|
||||
parent=cls.chapterchrome,
|
||||
display_name='defaultchrome',
|
||||
)
|
||||
self.fullchromesection = ItemFactory.create(parent=self.chapterchrome,
|
||||
cls.fullchromesection = ItemFactory.create(parent=cls.chapterchrome,
|
||||
display_name='fullchrome',
|
||||
chrome='accordion,tabs')
|
||||
self.tabtest = ItemFactory.create(parent=self.chapterchrome,
|
||||
cls.tabtest = ItemFactory.create(parent=cls.chapterchrome,
|
||||
display_name='progress_tab',
|
||||
default_tab='progress')
|
||||
|
||||
def setUp(self):
|
||||
super(TestNavigation, self).setUp()
|
||||
|
||||
# Create student accounts and activate them.
|
||||
for i in range(len(self.STUDENT_INFO)):
|
||||
email, password = self.STUDENT_INFO[i]
|
||||
|
||||
@@ -9,13 +9,13 @@ from courseware.module_render import get_module_for_descriptor
|
||||
from courseware.model_data import FieldDataCache
|
||||
from student.tests.factories import UserFactory, CourseEnrollmentFactory
|
||||
from xmodule.modulestore.tests.factories import ItemFactory, CourseFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.partitions.partitions import Group, UserPartition
|
||||
from openedx.core.djangoapps.user_api.tests.factories import UserCourseTagFactory
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class SplitTestBase(ModuleStoreTestCase):
|
||||
class SplitTestBase(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Sets up a basic course and user for split test testing.
|
||||
Also provides tests of rendered HTML for two user_tag conditions, 0 and 1.
|
||||
@@ -27,9 +27,10 @@ class SplitTestBase(ModuleStoreTestCase):
|
||||
HIDDEN_CONTENT = None
|
||||
VISIBLE_CONTENT = None
|
||||
|
||||
def setUp(self):
|
||||
super(SplitTestBase, self).setUp()
|
||||
self.partition = UserPartition(
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SplitTestBase, cls).setUpClass()
|
||||
cls.partition = UserPartition(
|
||||
0,
|
||||
'first_partition',
|
||||
'First Partition',
|
||||
@@ -39,22 +40,25 @@ class SplitTestBase(ModuleStoreTestCase):
|
||||
]
|
||||
)
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
number=self.COURSE_NUMBER,
|
||||
user_partitions=[self.partition]
|
||||
cls.course = CourseFactory.create(
|
||||
number=cls.COURSE_NUMBER,
|
||||
user_partitions=[cls.partition]
|
||||
)
|
||||
|
||||
self.chapter = ItemFactory.create(
|
||||
parent_location=self.course.location,
|
||||
cls.chapter = ItemFactory.create(
|
||||
parent_location=cls.course.location,
|
||||
category="chapter",
|
||||
display_name="test chapter",
|
||||
)
|
||||
self.sequential = ItemFactory.create(
|
||||
parent_location=self.chapter.location,
|
||||
cls.sequential = ItemFactory.create(
|
||||
parent_location=cls.chapter.location,
|
||||
category="sequential",
|
||||
display_name="Split Test Tests",
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(SplitTestBase, self).setUp()
|
||||
|
||||
self.student = UserFactory.create()
|
||||
CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
|
||||
self.client.login(username=self.student.username, password='test')
|
||||
@@ -269,14 +273,14 @@ class TestSplitTestVert(SplitTestBase):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class SplitTestPosition(ModuleStoreTestCase):
|
||||
class SplitTestPosition(SharedModuleStoreTestCase):
|
||||
"""
|
||||
Check that we can change positions in a course with partitions defined
|
||||
"""
|
||||
def setUp(self):
|
||||
super(SplitTestPosition, self).setUp()
|
||||
|
||||
self.partition = UserPartition(
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SplitTestPosition, cls).setUpClass()
|
||||
cls.partition = UserPartition(
|
||||
0,
|
||||
'first_partition',
|
||||
'First Partition',
|
||||
@@ -286,16 +290,19 @@ class SplitTestPosition(ModuleStoreTestCase):
|
||||
]
|
||||
)
|
||||
|
||||
self.course = CourseFactory.create(
|
||||
user_partitions=[self.partition]
|
||||
cls.course = CourseFactory.create(
|
||||
user_partitions=[cls.partition]
|
||||
)
|
||||
|
||||
self.chapter = ItemFactory.create(
|
||||
parent_location=self.course.location,
|
||||
cls.chapter = ItemFactory.create(
|
||||
parent_location=cls.course.location,
|
||||
category="chapter",
|
||||
display_name="test chapter",
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(SplitTestPosition, self).setUp()
|
||||
|
||||
self.student = UserFactory.create()
|
||||
CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
|
||||
self.client.login(username=self.student.username, password='test')
|
||||
|
||||
@@ -24,7 +24,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase
|
||||
from lms.djangoapps.lms_xblock.runtime import quote_slashes
|
||||
from student.tests.factories import UserFactory
|
||||
from student.models import anonymous_id_for_user
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.partitions.partitions import Group, UserPartition
|
||||
from openedx.core.djangoapps.credit.api import (
|
||||
@@ -126,13 +126,10 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
|
||||
COURSE_NAME = "test_course"
|
||||
|
||||
def setUp(self):
|
||||
|
||||
super(TestSubmittingProblems, self).setUp(create_user=False)
|
||||
# Create course
|
||||
self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)
|
||||
assert self.course, "Couldn't load course %r" % self.COURSE_NAME
|
||||
super(TestSubmittingProblems, self).setUp()
|
||||
|
||||
# create a test student
|
||||
self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)
|
||||
self.student = 'view@test.com'
|
||||
self.password = 'foo'
|
||||
self.create_account('u1', self.student, self.password)
|
||||
|
||||
@@ -28,21 +28,25 @@ from util.milestones_helpers import (
|
||||
from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from xmodule import tabs as xmodule_tabs
|
||||
from xmodule.modulestore.tests.django_utils import (
|
||||
TEST_DATA_MIXED_TOY_MODULESTORE, TEST_DATA_MIXED_CLOSED_MODULESTORE
|
||||
)
|
||||
TEST_DATA_MIXED_TOY_MODULESTORE, TEST_DATA_MIXED_CLOSED_MODULESTORE,
|
||||
SharedModuleStoreTestCase)
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
|
||||
|
||||
class TabTestCase(ModuleStoreTestCase):
|
||||
class TabTestCase(SharedModuleStoreTestCase):
|
||||
"""Base class for Tab-related test cases."""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TabTestCase, cls).setUpClass()
|
||||
|
||||
cls.course = CourseFactory.create(org='edX', course='toy', run='2012_Fall')
|
||||
cls.fake_dict_tab = {'fake_key': 'fake_value'}
|
||||
cls.books = None
|
||||
|
||||
def setUp(self):
|
||||
super(TabTestCase, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create(org='edX', course='toy', run='2012_Fall')
|
||||
self.fake_dict_tab = {'fake_key': 'fake_value'}
|
||||
self.reverse = lambda name, args: "name/{0}/args/{1}".format(name, ",".join(str(a) for a in args))
|
||||
self.books = None
|
||||
|
||||
def create_mock_user(self, is_authenticated=True, is_staff=True, is_enrolled=True):
|
||||
"""
|
||||
@@ -219,21 +223,25 @@ class TextbooksTestCase(TabTestCase):
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class StaticTabDateTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class StaticTabDateTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""Test cases for Static Tab Dates."""
|
||||
|
||||
MODULESTORE = TEST_DATA_MIXED_TOY_MODULESTORE
|
||||
|
||||
def setUp(self):
|
||||
super(StaticTabDateTestCase, self).setUp()
|
||||
self.course = CourseFactory.create()
|
||||
self.page = ItemFactory.create(
|
||||
category="static_tab", parent_location=self.course.location,
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(StaticTabDateTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
cls.page = ItemFactory.create(
|
||||
category="static_tab", parent_location=cls.course.location,
|
||||
data="OOGIE BLOOGIE", display_name="new_tab"
|
||||
)
|
||||
self.course.tabs.append(xmodule_tabs.CourseTab.load('static_tab', name='New Tab', url_slug='new_tab'))
|
||||
self.course.save()
|
||||
self.toy_course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
|
||||
cls.course.tabs.append(xmodule_tabs.CourseTab.load('static_tab', name='New Tab', url_slug='new_tab'))
|
||||
cls.course.save()
|
||||
cls.toy_course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
|
||||
|
||||
def setUp(self):
|
||||
super(StaticTabDateTestCase, self).setUp()
|
||||
|
||||
def test_logged_in(self):
|
||||
self.setup_user()
|
||||
@@ -417,16 +425,20 @@ class EntranceExamsTabsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, Mi
|
||||
|
||||
|
||||
@attr('shard_1')
|
||||
class TextBookCourseViewsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
class TextBookCourseViewsTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
"""
|
||||
Validate tab behavior when dealing with textbooks.
|
||||
"""
|
||||
MODULESTORE = TEST_DATA_MIXED_TOY_MODULESTORE
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TextBookCourseViewsTestCase, cls).setUpClass()
|
||||
cls.course = CourseFactory.create()
|
||||
|
||||
def setUp(self):
|
||||
super(TextBookCourseViewsTestCase, self).setUp()
|
||||
|
||||
self.course = CourseFactory.create()
|
||||
self.set_up_books(2)
|
||||
self.setup_user()
|
||||
self.enroll(self.course)
|
||||
|
||||
Reference in New Issue
Block a user