Add in xqueue submission tests
This commit is contained in:
@@ -243,7 +243,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
|
||||
})
|
||||
|
||||
# Submit request. When successful, 'msg' is the prior length of the queue
|
||||
(error, msg) = qinterface.send_to_queue(header=xheader,
|
||||
qinterface.send_to_queue(header=xheader,
|
||||
body=json.dumps(contents))
|
||||
|
||||
# State associated with the queueing request
|
||||
|
||||
@@ -52,7 +52,7 @@ def test_system():
|
||||
user=Mock(is_staff=False),
|
||||
filestore=Mock(),
|
||||
debug=True,
|
||||
xqueue={'interface': None, 'callback_url': '/', 'default_queuename': 'testqueue', 'waittime': 10},
|
||||
xqueue={'interface': None, 'callback_url': '/', 'default_queuename': 'testqueue', 'waittime': 10, 'construct_callback' : Mock(side_effect="/")},
|
||||
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
|
||||
xblock_model_data=lambda descriptor: descriptor._model_data,
|
||||
anonymous_student_id='student',
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
from threading import Thread
|
||||
import socket
|
||||
import threading
|
||||
|
||||
import SimpleHTTPServer
|
||||
import SocketServer
|
||||
|
||||
class ThreadedRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
def handle(self):
|
||||
data = self.request.recv(1024)
|
||||
cur_thread = threading.current_thread()
|
||||
response = "{}: {}".format(cur_thread.name, data)
|
||||
self.request.sendall(response)
|
||||
return
|
||||
|
||||
class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
||||
pass
|
||||
|
||||
def create_server(host,port):
|
||||
"""
|
||||
Mock a server to be used for the open ended grading tests
|
||||
@param host: the hostname ie "localhost" or "127.0.0.1"
|
||||
@param port: the integer of the port to open a connection on
|
||||
@return: The created server object
|
||||
"""
|
||||
server = ThreadedTCPServer((host,port), ThreadedRequestHandler)
|
||||
|
||||
# Start a thread with the server -- that thread will then start one
|
||||
# more thread for each request
|
||||
server_thread = threading.Thread(target=server.serve_forever)
|
||||
# Exit the server thread when the main thread terminates
|
||||
server_thread.daemon = True
|
||||
server_thread.start()
|
||||
return server
|
||||
@@ -8,6 +8,7 @@ from mock import patch
|
||||
from xmodule.open_ended_grading_classes.openendedchild import OpenEndedChild
|
||||
from xmodule.open_ended_grading_classes.open_ended_module import OpenEndedModule
|
||||
from xmodule.open_ended_grading_classes.combined_open_ended_modulev1 import CombinedOpenEndedV1Module
|
||||
from xmodule.open_ended_grading_classes.grading_service_module import GradingServiceError
|
||||
from xmodule.combined_open_ended_module import CombinedOpenEndedModule
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore import Location
|
||||
@@ -520,9 +521,11 @@ class OpenEndedModuleXmlTest(unittest.TestCase):
|
||||
answer = "blah blah"
|
||||
assessment = [0,1]
|
||||
hint = "blah"
|
||||
test_server = create_server("127.0.0.1", 3034)
|
||||
def setUp(self):
|
||||
self.test_system = test_system()
|
||||
self.test_system.xqueue['interface'] = Mock(
|
||||
send_to_queue = Mock(side_effect=[1,"queued"])
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_import_system(load_error_modules=True):
|
||||
@@ -592,6 +595,16 @@ class OpenEndedModuleXmlTest(unittest.TestCase):
|
||||
module.handle_ajax("get_status", {})
|
||||
|
||||
#Move to the next step in the problem
|
||||
module.handle_ajax("next_problem", {})
|
||||
module.get_html()
|
||||
module.handle_ajax("get_combined_rubric", {})
|
||||
try:
|
||||
module.handle_ajax("next_problem", {})
|
||||
except GradingServiceError:
|
||||
#This error is okay. We don't have a grading service to connect to!
|
||||
pass
|
||||
#Move to the next step in the problem
|
||||
try:
|
||||
module.get_html()
|
||||
except GradingServiceError:
|
||||
#This error is okay. We don't have a grading service to connect to!
|
||||
pass
|
||||
|
||||
module.handle_ajax("get_combined_rubric", {})
|
||||
|
||||
Reference in New Issue
Block a user