Esempio n. 1
0
    def test_get_cosmetic_display_price(self):
        """
        Check that get_cosmetic_display_price() returns the correct price given its inputs.
        """
        course = CourseFactory.create()
        registration_price = 99
        course.cosmetic_display_price = 10
        with patch('course_modes.models.CourseMode.min_course_price_for_currency', return_value=registration_price):
            # Since registration_price is set, it overrides the cosmetic_display_price and should be returned
            self.assertEqual(get_cosmetic_display_price(course), "$99")

        registration_price = 0
        with patch('course_modes.models.CourseMode.min_course_price_for_currency', return_value=registration_price):
            # Since registration_price is not set, cosmetic_display_price should be returned
            self.assertEqual(get_cosmetic_display_price(course), "$10")

        course.cosmetic_display_price = 0
        # Since both prices are not set, there is no price, thus "Free"
        self.assertEqual(get_cosmetic_display_price(course), "Free")
Esempio n. 2
0
    def test_get_cosmetic_display_price(self):
        """
        Check that get_cosmetic_display_price() returns the correct price given its inputs.
        """
        course = CourseFactory.create()
        registration_price = 99
        course.cosmetic_display_price = 10
        with patch('course_modes.models.CourseMode.min_course_price_for_currency', return_value=registration_price):
            # Since registration_price is set, it overrides the cosmetic_display_price and should be returned
            self.assertEqual(get_cosmetic_display_price(course), "$99")

        registration_price = 0
        with patch('course_modes.models.CourseMode.min_course_price_for_currency', return_value=registration_price):
            # Since registration_price is not set, cosmetic_display_price should be returned
            self.assertEqual(get_cosmetic_display_price(course), "$10")

        course.cosmetic_display_price = 0
        # Since both prices are not set, there is no price, thus "Free"
        self.assertEqual(get_cosmetic_display_price(course), "Free")