Refactor tests to no longer use templates

Add boilerplate option to ItemFactory
Minor start date fix to not use microsecs
This commit is contained in:
Don Mitchell
2013-07-16 16:00:28 -04:00
parent 92391a22fc
commit be4fbc562e
4 changed files with 48 additions and 37 deletions

View File

@@ -308,12 +308,14 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
CourseFactory.create(org='edX', course='999', display_name='Robot Super Course')
course_location = Location(['i4x', 'edX', '999', 'course', 'Robot_Super_Course', None])
ItemFactory.create(parent_location=course_location,
template="i4x://edx/templates/static_tab/Empty",
display_name="Static_1")
ItemFactory.create(parent_location=course_location,
template="i4x://edx/templates/static_tab/Empty",
display_name="Static_2")
ItemFactory.create(
parent_location=course_location,
category="static_tab",
display_name="Static_1")
ItemFactory.create(
parent_location=course_location,
category="static_tab",
display_name="Static_2")
course = module_store.get_item(Location(['i4x', 'edX', '999', 'course', 'Robot_Super_Course', None]))
@@ -370,7 +372,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
course_location = Location(['i4x', 'edX', '999', 'course', 'Robot_Super_Course', None])
chapterloc = ItemFactory.create(parent_location=course_location, display_name="Chapter").location
ItemFactory.create(parent_location=chapterloc, template='i4x://edx/templates/sequential/Empty', display_name="Sequential")
ItemFactory.create(parent_location=chapterloc, category='sequential', display_name="Sequential")
sequential = direct_store.get_item(Location(['i4x', 'edX', '999', 'sequential', 'Sequential', None]))
chapter = direct_store.get_item(Location(['i4x', 'edX', '999', 'chapter', 'Chapter', None]))
@@ -650,9 +652,9 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
vertical = module_store.get_item(Location(['i4x', 'edX', 'toy',
'vertical', 'vertical_test', None]), depth=1)
draft_store.clone_item(vertical.location, vertical.location)
draft_store.convert_to_draft(vertical.location)
for child in vertical.get_children():
draft_store.clone_item(child.location, child.location)
draft_store.convert_to_draft(child.location)
# delete the course
delete_course(module_store, content_store, location, commit=True)

View File

@@ -49,7 +49,7 @@ class TestCreateItem(CourseTestCase):
resp = self.client.post(
reverse('create_item'),
json.dumps({
'parent_location': self.course_location.url(),
'parent_location': self.course.location.url(),
'display_name': display_name,
'category': 'chapter'
}),
@@ -62,11 +62,11 @@ class TestCreateItem(CourseTestCase):
new_obj = modulestore().get_item(chap_location)
self.assertEqual(new_obj.category, 'chapter')
self.assertEqual(new_obj.display_name, display_name)
self.assertEqual(new_obj.location.org, self.course_location.org)
self.assertEqual(new_obj.location.course, self.course_location.course)
self.assertEqual(new_obj.location.org, self.course.location.org)
self.assertEqual(new_obj.location.course, self.course.location.course)
# get the course and ensure it now points to this one
course = modulestore().get_item(self.course_location)
course = modulestore().get_item(self.course.location)
self.assertIn(chap_location, course.children)
# use default display name
@@ -112,7 +112,7 @@ class TestCreateItem(CourseTestCase):
resp = self.client.post(
reverse('create_item'),
json.dumps(
{'parent_location': self.course_location.url(),
{'parent_location': self.course.location.url(),
'category': 'problem',
'boilerplate': 'nosuchboilerplate.yaml'
}),
@@ -140,7 +140,7 @@ class TestEditItem(CourseTestCase):
resp = self.client.post(
reverse('create_item'),
json.dumps(
{'parent_location': self.course_location.url(),
{'parent_location': self.course.location.url(),
'display_name': display_name,
'category': 'chapter'
}),
@@ -209,4 +209,4 @@ class TestEditItem(CourseTestCase):
content_type="application/json"
)
problem = modulestore('draft').get_item(self.problems[0])
self.assertIsNo/ne(problem.markdown)
self.assertIsNone(problem.markdown)