'Test whether LoncapaProblem._parse_score_msg correcly parses valid HTML5 html.'

def test_parse_score_msg_of_responder(self):

    valid_grader_msgs = [u'<span>MESSAGE</span>', textwrap.dedent('\n                                                                <div    class=\'matlabResponse\'><div    id=\'mwAudioPlaceHolder\'>\n                                                                <audio    controls    autobuffer    autoplay    src=\'data:audio/wav;base64=\'>Audio    is    not    supported    on    this    browser.</audio>\n                                                                <div>Right    click    <a    href=https://endpoint.mss-mathworks.com/media/filename.wav>here</a>    and    click    "Save    As"    to    download    the    file</div></div>\n                                                                <div    style=\'white-space:pre\'    class=\'commandWindowOutput\'></div><ul></ul></div>\n                                                ').replace('\n', ''), '<aaa></bbb>']
    invalid_grader_msgs = ['<audio', '<p>\x08</p>']
    answer_ids = sorted(self.problem.get_question_answers())
    old_cmap = CorrectMap()
    for (i, answer_id) in enumerate(answer_ids):
        queuekey = (1000 + i)
        queuestate = CodeResponseTest.make_queuestate(queuekey, datetime.now(UTC))
        old_cmap.update(CorrectMap(answer_id=answer_ids[i], queuestate=queuestate))
    for grader_msg in valid_grader_msgs:
        correct_score_msg = json.dumps({'correct': True, 'score': 1, 'msg': grader_msg})
        incorrect_score_msg = json.dumps({'correct': False, 'score': 0, 'msg': grader_msg})
        xserver_msgs = {'correct': correct_score_msg, 'incorrect': incorrect_score_msg}
        for (i, answer_id) in enumerate(answer_ids):
            self.problem.correct_map = CorrectMap()
            self.problem.correct_map.update(old_cmap)
            output = self.problem.update_score(xserver_msgs['correct'], queuekey=(1000 + i))
            self.assertEquals(output[answer_id]['msg'], grader_msg)
    for grader_msg in invalid_grader_msgs:
        correct_score_msg = json.dumps({'correct': True, 'score': 1, 'msg': grader_msg})
        incorrect_score_msg = json.dumps({'correct': False, 'score': 0, 'msg': grader_msg})
        xserver_msgs = {'correct': correct_score_msg, 'incorrect': incorrect_score_msg}
        for (i, answer_id) in enumerate(answer_ids):
            self.problem.correct_map = CorrectMap()
            self.problem.correct_map.update(old_cmap)
            output = self.problem.update_score(xserver_msgs['correct'], queuekey=(1000 + i))
            self.assertEquals(output[answer_id]['msg'], u'Invalid    grader    reply.    Please    contact    the    course    staff.')
