Commit 9c533fa8 by Calen Pennington

Add a test of module_render_code

parent 48ba871c
...@@ -279,10 +279,9 @@ def _get_module(user, request, location, student_module_cache, course_id, positi ...@@ -279,10 +279,9 @@ def _get_module(user, request, location, student_module_cache, course_id, positi
shared_module.state = module.get_shared_state() shared_module.state = module.get_shared_state()
shared_module.save() shared_module.save()
return module return module
# TODO (vshnayder): Rename this? It's very confusing.
def get_or_create_student_module(course_id, user, descriptor, student_module_cache, module=None): def get_or_create_student_module(course_id, user, descriptor, student_module_cache, module=None):
""" """
Returns the StudentModule specific to this module for this student, Returns the StudentModule specific to this module for this student,
...@@ -483,7 +482,7 @@ def modx_dispatch(request, dispatch, location, course_id): ...@@ -483,7 +482,7 @@ def modx_dispatch(request, dispatch, location, course_id):
student_module_cache, student_module_cache,
instance instance
) )
shared_module = get_shared_instance_module(course_id, request.user, instance, student_module_cache) shared_module = get_or_create_shared_student_module(course_id, request.user, instance, student_module_cache)
# Don't track state for anonymous users (who don't have student modules) # Don't track state for anonymous users (who don't have student modules)
if instance_module is not None: if instance_module is not None:
......
from mock import Mock
from unittest import TestSuite
class TestStudentModule(TestSuite):
def setUp(self):
self.anon_user = Mock()
self.anon_user.is_authenticated.return_value = True
def anonymous_user(self):
self.assert_equals(None, get_or_create_student_module('course_id', self.anon_user, None, None, None))
\ No newline at end of file
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