Exemple #1
0
    def test_form_cleaned_percent_raise(self):
        with mock.patch("course.page.base.HumanTextFeedbackForm.clean",
                        autospec=True) as mock_clean:
            mock_clean.side_effect = human_text_feedback_form_clean_side_effect
            form_data = {"grade_percent": 30, "grade_points": 2}
            form = HumanTextFeedbackForm(5, form_data)
            self.assertTrue(form.is_valid())

            with self.assertRaises(RuntimeError):
                form.cleaned_percent()
Exemple #2
0
    def test_form_cleaned_percent_raise(self):
        with mock.patch("course.page.base.HumanTextFeedbackForm.clean",
                        autospec=True) as mock_clean:
            mock_clean.side_effect = human_text_feedback_form_clean_side_effect
            form_data = {"grade_percent": 30, "grade_points": 2}
            form = HumanTextFeedbackForm(5, form_data)
            self.assertTrue(form.is_valid())

            with self.assertRaises(RuntimeError):
                form.cleaned_percent()
Exemple #3
0
 def test_form_point_value_none_cleaned_percentage(self):
     form_data = {"grade_percent": 30}
     form = HumanTextFeedbackForm(None, form_data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_percent(), 30)
Exemple #4
0
 def test_form_no_grade_percent(self):
     form_data = {"grade_points": 1.5}
     form = HumanTextFeedbackForm(5, form_data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_percent(), 30)
Exemple #5
0
 def test_form_points_percentage_valid(self):
     form_data = {"grade_percent": 30, "grade_points": 1.50001}
     form = HumanTextFeedbackForm(5, form_data)
     self.assertTrue(form.is_valid())
     self.assertTrue(form.cleaned_percent() - 30 < 0.001)
Exemple #6
0
 def test_form_point_value_none_cleaned_percentage(self):
     form_data = {"grade_percent": 30}
     form = HumanTextFeedbackForm(None, form_data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_percent(), 30)
Exemple #7
0
 def test_form_no_grade_percent(self):
     form_data = {"grade_points": 1.5}
     form = HumanTextFeedbackForm(5, form_data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_percent(), 30)
Exemple #8
0
 def test_form_points_percentage_valid(self):
     form_data = {"grade_percent": 30, "grade_points": 1.50001}
     form = HumanTextFeedbackForm(5, form_data)
     self.assertTrue(form.is_valid())
     self.assertTrue(form.cleaned_percent() - 30 < 0.001)