Commit badd3a8d by Vik Paruchuri

Properly stub out the controller_qs variable in the tested module. Test times out without this.

parent aae3380a
...@@ -85,7 +85,7 @@ class MockControllerQueryService(object): ...@@ -85,7 +85,7 @@ class MockControllerQueryService(object):
def __init__(self, config, system): def __init__(self, config, system):
pass pass
def check_if_name_is_unique(self, **params): def check_if_name_is_unique(self, *args, **kwargs):
""" """
Mock later if needed. Stub function for now. Mock later if needed. Stub function for now.
@param params: @param params:
...@@ -93,7 +93,7 @@ class MockControllerQueryService(object): ...@@ -93,7 +93,7 @@ class MockControllerQueryService(object):
""" """
pass pass
def check_for_eta(self, **params): def check_for_eta(self, *args, **kwargs):
""" """
Mock later if needed. Stub function for now. Mock later if needed. Stub function for now.
@param params: @param params:
...@@ -101,19 +101,19 @@ class MockControllerQueryService(object): ...@@ -101,19 +101,19 @@ class MockControllerQueryService(object):
""" """
pass pass
def check_combined_notifications(self, **params): def check_combined_notifications(self, *args, **kwargs):
combined_notifications = '{"flagged_submissions_exist": false, "version": 1, "new_student_grading_to_view": false, "success": true, "staff_needs_to_grade": false, "student_needs_to_peer_grade": true, "overall_need_to_check": true}' combined_notifications = '{"flagged_submissions_exist": false, "version": 1, "new_student_grading_to_view": false, "success": true, "staff_needs_to_grade": false, "student_needs_to_peer_grade": true, "overall_need_to_check": true}'
return combined_notifications return combined_notifications
def get_grading_status_list(self, **params): def get_grading_status_list(self, *args, **kwargs):
grading_status_list = '{"version": 1, "problem_list": [{"problem_name": "Science Question -- Machine Assessed", "grader_type": "NA", "eta_available": true, "state": "Waiting to be Graded", "eta": 259200, "location": "i4x://MITx/oe101x/combinedopenended/Science_SA_ML"}, {"problem_name": "Humanities Question -- Peer Assessed", "grader_type": "NA", "eta_available": true, "state": "Waiting to be Graded", "eta": 259200, "location": "i4x://MITx/oe101x/combinedopenended/Humanities_SA_Peer"}], "success": true}' grading_status_list = '{"version": 1, "problem_list": [{"problem_name": "Science Question -- Machine Assessed", "grader_type": "NA", "eta_available": true, "state": "Waiting to be Graded", "eta": 259200, "location": "i4x://MITx/oe101x/combinedopenended/Science_SA_ML"}, {"problem_name": "Humanities Question -- Peer Assessed", "grader_type": "NA", "eta_available": true, "state": "Waiting to be Graded", "eta": 259200, "location": "i4x://MITx/oe101x/combinedopenended/Humanities_SA_Peer"}], "success": true}'
return grading_status_list return grading_status_list
def get_flagged_problem_list(self, **params): def get_flagged_problem_list(self, *args, **kwargs):
flagged_problem_list = '{"version": 1, "success": false, "error": "No flagged submissions exist for course: MITx/oe101x/2012_Fall"}' flagged_problem_list = '{"version": 1, "success": false, "error": "No flagged submissions exist for course: MITx/oe101x/2012_Fall"}'
return flagged_problem_list return flagged_problem_list
def take_action_on_flags(self, **params): def take_action_on_flags(self, *args, **kwargs):
""" """
Mock later if needed. Stub function for now. Mock later if needed. Stub function for now.
@param params: @param params:
......
...@@ -10,6 +10,7 @@ from mock import MagicMock, patch, Mock ...@@ -10,6 +10,7 @@ from mock import MagicMock, patch, Mock
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.http import HttpResponse from django.http import HttpResponse
from django.conf import settings
from mitxmako.shortcuts import render_to_string from mitxmako.shortcuts import render_to_string
from xmodule.open_ended_grading_classes import peer_grading_service, controller_query_service from xmodule.open_ended_grading_classes import peer_grading_service, controller_query_service
...@@ -31,7 +32,6 @@ from xmodule.tests import test_util_open_ended ...@@ -31,7 +32,6 @@ from xmodule.tests import test_util_open_ended
from courseware.tests import factories from courseware.tests import factories
@override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE)
class TestStaffGradingService(LoginEnrollmentTestCase): class TestStaffGradingService(LoginEnrollmentTestCase):
''' '''
...@@ -310,8 +310,7 @@ class TestPanel(LoginEnrollmentTestCase): ...@@ -310,8 +310,7 @@ class TestPanel(LoginEnrollmentTestCase):
found_module, peer_grading_module = views.find_peer_grading_module(self.course) found_module, peer_grading_module = views.find_peer_grading_module(self.course)
self.assertTrue(found_module) self.assertTrue(found_module)
@patch('xmodule.open_ended_grading_classes.controller_query_service.ControllerQueryService', @patch('open_ended_grading.views.controller_qs', controller_query_service.MockControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, views.system))
controller_query_service.MockControllerQueryService)
def test_problem_list(self): def test_problem_list(self):
""" """
Ensure that the problem list from the grading controller server can be rendered properly locally Ensure that the problem list from the grading controller server can be rendered properly locally
...@@ -319,4 +318,4 @@ class TestPanel(LoginEnrollmentTestCase): ...@@ -319,4 +318,4 @@ class TestPanel(LoginEnrollmentTestCase):
""" """
request = Mock(user=self.user) request = Mock(user=self.user)
response = views.student_problem_list(request, self.course.id) response = views.student_problem_list(request, self.course.id)
self.assertTrue(isinstance(response, HttpResponse)) self.assertRegexpMatches(response.content, "Here are a list of open ended problems for this course.")
...@@ -36,6 +36,7 @@ system = ModuleSystem( ...@@ -36,6 +36,7 @@ system = ModuleSystem(
replace_urls=None, replace_urls=None,
xblock_model_data={} xblock_model_data={}
) )
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, system) controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, system)
""" """
......
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