Commit dc965428 by Don Mitchell

Fix unit tests for generated

course ids.
parent 8fe55c9a
......@@ -1184,7 +1184,7 @@ class ContentStoreTest(ContentStoreTestCase):
def test_course_index_view_with_course(self):
"""Test viewing the index page with an existing course"""
CourseFactory.create(, display_name='Robot Super Educational Course')
CourseFactory.create(display_name='Robot Super Educational Course')
resp = self.client.get_html('/course/')
self.assertContains(
resp,
......@@ -1195,8 +1195,7 @@ class ContentStoreTest(ContentStoreTestCase):
def test_course_overview_view_with_course(self):
"""Test viewing the course overview page with an existing course"""
course_cat_num = self.random_course_name()
course = CourseFactory.create(org='MITx', course=course_cat_num, display_name='Robot Super Course')
course = CourseFactory.create()
resp = self._show_course_overview(course.id)
self.assertContains(
resp,
......@@ -1210,7 +1209,7 @@ class ContentStoreTest(ContentStoreTestCase):
def test_create_item(self):
"""Test creating a new xblock instance."""
course = CourseFactory.create()()
course = CourseFactory.create()
section_data = {
'parent_locator': unicode(course.location),
......@@ -1227,7 +1226,7 @@ class ContentStoreTest(ContentStoreTestCase):
def test_capa_module(self):
"""Test that a problem treats markdown specially."""
course = CourseFactory.create()()
course = CourseFactory.create()
problem_data = {
'parent_locator': unicode(course.location),
......
......@@ -30,6 +30,7 @@ from courseware.tests.helpers import LoginEnrollmentTestCase
from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
from lms.lib.xblock.runtime import quote_slashes
from student.tests.factories import UserFactory
from student.models import anonymous_id_for_user
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
......@@ -101,9 +102,7 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase):
problem_location = self.problem_location(problem_url_name)
modx_url = self.modx_url(problem_location, 'problem_check')
answer_key_prefix = 'input_i4x-{}-{}-problem-{}_'.format(
self.course.org, self.course.id.course, problem_url_name
)
answer_key_prefix = 'input_{}_'.format(problem_location.html_id())
# format the response dictionary to be sent in the post request by adding the above prefix to each key
response_dict = {(answer_key_prefix + k): v for k, v in responses.items()}
......@@ -319,8 +318,8 @@ class TestCourseGrader(TestSubmittingProblems):
"weight": 1.0
}],
"GRADE_CUTOFFS": {
'A': .9,
'B': .33
'A': .9,
'B': .33
}
}
self.add_grading_policy(grading_policy)
......@@ -515,7 +514,8 @@ class TestCourseGrader(TestSubmittingProblems):
# Verify that the submissions API was sent an anonymized student ID
mock_get_scores.assert_called_with(
self.course.id.to_deprecated_string(), '99ac6730dc5f900d69fd735975243b31'
self.course.id.to_deprecated_string(),
anonymous_id_for_user(self.student_user, self.course.id)
)
def test_weighted_homework(self):
......@@ -905,9 +905,9 @@ class TestAnswerDistributions(TestSubmittingProblems):
super(TestAnswerDistributions, self).setUp()
self.homework = self.add_graded_section_to_course('homework')
self.add_dropdown_to_section(self.homework.location, 'p1', 1)
self.add_dropdown_to_section(self.homework.location, 'p2', 1)
self.add_dropdown_to_section(self.homework.location, 'p3', 1)
self.p1_html_id = self.add_dropdown_to_section(self.homework.location, 'p1', 1).location.html_id()
self.p2_html_id = self.add_dropdown_to_section(self.homework.location, 'p2', 1).location.html_id()
self.p3_html_id = self.add_dropdown_to_section(self.homework.location, 'p3', 1).location.html_id()
self.refresh_course()
def test_empty(self):
......@@ -926,10 +926,10 @@ class TestAnswerDistributions(TestSubmittingProblems):
self.assertEqual(
distributions,
{
('p1', 'p1', 'i4x-MITx-100-problem-p1_2_1'): {
('p1', 'p1', '{}_2_1'.format(self.p1_html_id)): {
u'ⓤⓝⓘⓒⓞⓓⓔ': 1
},
('p2', 'p2', 'i4x-MITx-100-problem-p2_2_1'): {
('p2', 'p2', '{}_2_1'.format(self.p2_html_id)): {
'Correct': 1
}
}
......@@ -961,14 +961,14 @@ class TestAnswerDistributions(TestSubmittingProblems):
self.assertEqual(
grades.answer_distributions(self.course.id),
{
('p1', 'p1', 'i4x-MITx-100-problem-p1_2_1'): {
('p1', 'p1', '{}_2_1'.format(self.p1_html_id)): {
'Correct': 2
},
('p2', 'p2', 'i4x-MITx-100-problem-p2_2_1'): {
('p2', 'p2', '{}_2_1'.format(self.p2_html_id)): {
'Correct': 1,
'Incorrect': 1
},
('p3', 'p3', 'i4x-MITx-100-problem-p3_2_1'): {
('p3', 'p3', '{}_2_1'.format(self.p3_html_id)): {
'Correct': 1
}
}
......@@ -987,14 +987,14 @@ class TestAnswerDistributions(TestSubmittingProblems):
)
for val in ('Correct', True, False, 0, 0.0, 1, 1.0, None):
state = json.loads(student_module.state)
state["student_answers"]['i4x-MITx-100-problem-p1_2_1'] = val
state["student_answers"]['{}_2_1'.format(self.p1_html_id)] = val
student_module.state = json.dumps(state)
student_module.save()
self.assertEqual(
grades.answer_distributions(self.course.id),
{
('p1', 'p1', 'i4x-MITx-100-problem-p1_2_1'): {
('p1', 'p1', '{}_2_1'.format(self.p1_html_id)): {
str(val): 1
},
}
......@@ -1045,7 +1045,7 @@ class TestAnswerDistributions(TestSubmittingProblems):
self.assertEqual(
grades.answer_distributions(self.course.id),
{
('p2', 'p2', 'i4x-MITx-100-problem-p2_2_1'): {
('p2', 'p2', '{}_2_1'.format(self.p2_html_id)): {
'Incorrect': 1
},
}
......
......@@ -72,7 +72,7 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
urls.extend([
reverse('book', kwargs={'course_id': course.id.to_deprecated_string(),
'book_index': index})
for index, book in enumerate(course.textbooks)
for index, __ in enumerate(course.textbooks)
])
for url in urls:
self.assert_request_status_code(404, url)
......@@ -132,7 +132,7 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
self.course = modulestore().get_course(self.course.id)
self.test_course = CourseFactory.create(number='666', display_name='Robot_Sub_Course')
self.test_course = CourseFactory.create(org=self.course.id.org)
self.other_org_course = CourseFactory.create(org='Other_Org_Course')
self.sub_courseware_chapter = ItemFactory.create(
parent_location=self.test_course.location,
......
......@@ -305,8 +305,8 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
'SITE_NAME',
settings.SITE_NAME
)
self.about_path = '/courses/MITx/999/Robot_Super_Course/about'
self.course_path = '/courses/MITx/999/Robot_Super_Course/'
self.about_path = '/courses/{}/about'.format(self.course.id)
self.course_path = '/courses/{}/'.format(self.course.id)
# uncomment to enable enable printing of large diffs
# from failed assertions in the event of a test failure.
......@@ -653,7 +653,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
'You have been un-enrolled from {}'.format(display_name=self.course.display_name,)
'You have been un-enrolled from {display_name}'.format(display_name=self.course.display_name,)
)
self.assertEqual(
mail.outbox[0].body,
......@@ -702,7 +702,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
'You have been un-enrolled from {}'.format(display_name=self.course.display_name,)
'You have been un-enrolled from {display_name}'.format(display_name=self.course.display_name,)
)
self.assertEqual(
mail.outbox[0].body,
......@@ -728,7 +728,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
'You have been invited to register for {}'.format(display_name=self.course.display_name,)
'You have been invited to register for {display_name}'.format(display_name=self.course.display_name,)
)
self.assertEqual(
......@@ -757,7 +757,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
mail.outbox[0].body,
"Dear student,\n\nYou have been invited to join {} at edx.org by a member of the course staff.\n\n----\n"
"This email was automatically sent from edx.org to robot-not-an-email-yet@robot.org".format(
display_name=self.course.display_name,
self.course.display_name,
)
)
......@@ -778,7 +778,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
'You have been invited to register for {}'.format(display_name=self.course.display_name,)
'You have been invited to register for {display_name}'.format(display_name=self.course.display_name,)
)
self.assertEqual(
......@@ -823,8 +823,8 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
'SITE_NAME',
settings.SITE_NAME
)
self.about_path = '/courses/MITx/999/Robot_Super_Course/about'
self.course_path = '/courses/MITx/999/Robot_Super_Course/'
self.about_path = '/courses/{}/about'.format(self.course.id)
self.course_path = '/courses/{}/'.format(self.course.id)
# uncomment to enable enable printing of large diffs
# from failed assertions in the event of a test failure.
......@@ -926,7 +926,7 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
'You have been invited to a beta test for {}'.format(display_name=self.course.display_name,)
'You have been invited to a beta test for {display_name}'.format(display_name=self.course.display_name,)
)
self.assertEqual(
......@@ -973,7 +973,7 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
'You have been invited to a beta test for {}'.format(display_name=self.course.display_name)
'You have been invited to a beta test for {display_name}'.format(display_name=self.course.display_name)
)
self.assertEqual(
......@@ -1089,7 +1089,7 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject,
u'You have been removed from a beta test for {}'.format(display_name=self.course.display_name,)
u'You have been removed from a beta test for {display_name}'.format(display_name=self.course.display_name,)
)
self.assertEqual(
mail.outbox[0].body,
......
......@@ -32,8 +32,8 @@ class OrderTest(ModuleStoreTestCase):
course = CourseFactory.create()
self.course_key = course.id
self.other_course_keys = []
for i in xrange(1, 5):
self.other_course_keys.append(CourseFactory.create())
for __ in xrange(1, 5):
self.other_course_keys.append(CourseFactory.create().id)
self.cost = 40
def test_get_cart_for_user(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment