Esempio n. 1
0
 def test_models_course_field_duration_display_request(self):
     """
     When used in the `render_model` template tag, it should not break when passed a
     request argument (the DjangoCMS frontend editing does it).
     """
     course = CourseFactory(duration=[1, "week"])
     request = RequestFactory().get("/")
     self.assertEqual(course.get_duration_display(request), "1 week")
Esempio n. 2
0
 def test_models_course_field_duration_display_singular(self):
     """Validate that a value of 1 time unit is displayed as expected."""
     course = CourseFactory(duration=[1, "day"])
     self.assertEqual(course.get_duration_display(), "1 day")
Esempio n. 3
0
 def test_models_course_field_duration_display_plural(self):
     """Validate that a plural number of time units is displayed as expected."""
     course = CourseFactory(duration=[2, "day"])
     self.assertEqual(course.get_duration_display(), "2 days")
Esempio n. 4
0
 def test_models_course_field_duration_null(self):
     """The duration field can be null."""
     course = CourseFactory(duration=None)
     self.assertIsNone(course.duration)
     self.assertEqual(course.get_duration_display(), "")