Beispiel #1
0
    def test_parse_matcher_string_deprecated(self):
        s = "plain:half"
        with mock.patch("course.validation.ValidationContext.add_warning",
                        autospec=True) as mock_vctx_add_warning:
            mock_vctx_add_warning.return_value = None
            result = parse_matcher_string(None, "", s)
            self.assertEqual(mock_vctx_add_warning.call_count, 0)
            self.assertTrue(isinstance(result, PlainMatcher))
            self.assertEqual(result.correct_answer_text(), "half")

        mock_vctx = mock.MagicMock()
        expected_warning = "uses deprecated 'matcher:answer' style"

        result = parse_matcher_string(mock_vctx, "some_where", s)
        self.assertIn(expected_warning, mock_vctx.add_warning.call_args[0])
        self.assertTrue(isinstance(result, PlainMatcher))
        self.assertEqual(result.correct_answer_text(), "half")
Beispiel #2
0
    def test_parse_matcher_string_deprecated(self):
        s = "plain:half"
        with mock.patch("course.validation.ValidationContext.add_warning",
                        autospec=True) as mock_vctx_add_warning:
            mock_vctx_add_warning.return_value = None
            result = parse_matcher_string(None, "", s)
            self.assertEqual(mock_vctx_add_warning.call_count, 0)
            self.assertTrue(isinstance(result, PlainMatcher))
            self.assertEqual(result.correct_answer_text(), "half")

        mock_vctx = mock.MagicMock()
        expected_warning = "uses deprecated 'matcher:answer' style"

        result = parse_matcher_string(mock_vctx, "some_where", s)
        self.assertIn(expected_warning, mock_vctx.add_warning.call_args[0])
        self.assertTrue(isinstance(result, PlainMatcher))
        self.assertEqual(result.correct_answer_text(), "half")
Beispiel #3
0
 def test_parse_matcher_string_no_match(self):
     s = "<plain:half"
     with self.assertRaises(ValidationError) as cm:
         parse_matcher_string(None, "some where", s)
     self.assertIn("some where: does not specify match type",
                   str(cm.exception))
Beispiel #4
0
 def test_parse_matcher_string(self):
     s = "<plain>half"
     result = parse_matcher_string(None, "", s)
     self.assertTrue(isinstance(result, PlainMatcher))
     self.assertEqual(result.correct_answer_text(), "half")
Beispiel #5
0
 def test_parse_matcher_string_no_match(self):
     s = "<plain:half"
     with self.assertRaises(ValidationError) as cm:
         parse_matcher_string(None, "some where", s)
     self.assertIn("some where: does not specify match type",
                   str(cm.exception))
Beispiel #6
0
 def test_parse_matcher_string(self):
     s = "<plain>half"
     result = parse_matcher_string(None, "", s)
     self.assertTrue(isinstance(result, PlainMatcher))
     self.assertEqual(result.correct_answer_text(), "half")