示例#1
0
    def test_round_uses_function_defined_in_OSCAR_OFFER_ROUNDING_FUNCTION(
            self, round_func_mock):
        benefit = Benefit()

        decimal = Decimal(10.05)

        self.assertEqual(benefit.round(decimal), round_func_mock(decimal))
示例#2
0
    def test_default_rounding(self):
        benefit = Benefit()

        decimal = Decimal(10.0570)

        self.assertEqual(benefit.round(decimal),
                         decimal.quantize(Decimal('0.01'), ROUND_DOWN))
示例#3
0
 def test_proxy(self, range):
     for benefit_type, __ in Benefit.TYPE_CHOICES:
         benefit = Benefit(
             type=benefit_type, value=10, range=range, max_affected_items=1)
         proxy = benefit.proxy()
         assert benefit.type == proxy.type
         assert benefit.value == proxy.value
         assert benefit.range == proxy.range
         assert benefit.max_affected_items == proxy.max_affected_items
 def test_proxy(self, range):
     for benefit_type, __ in Benefit.TYPE_CHOICES:
         benefit = Benefit(
             type=benefit_type, value=10, range=range, max_affected_items=1)
         proxy = benefit.proxy()
         assert benefit.type == proxy.type
         assert benefit.value == proxy.value
         assert benefit.range == proxy.range
         assert benefit.max_affected_items == proxy.max_affected_items
示例#5
0
    def test_round_uses_function_defined_in_OSCAR_OFFER_ROUNDING_FUNCTION(self, round_func_mock):
        benefit = Benefit()

        decimal = Decimal(10.05)

        self.assertEqual(
            benefit.round(decimal),
            round_func_mock(decimal)
        )
示例#6
0
    def test_default_rounding(self):
        benefit = Benefit()

        decimal = Decimal(10.0570)

        self.assertEqual(
            benefit.round(decimal),
            decimal.quantize(Decimal('0.01'), ROUND_DOWN)
        )
示例#7
0
 def test_name_and_description(self, range):
     """
     Tests that the benefit proxy classes all return a name and
     description. Unfortunately, the current implementations means
     a valid range is required.w
     """
     for benefit_type, __ in Benefit.TYPE_CHOICES:
         benefit = Benefit(type=benefit_type, range=range)
         assert all([benefit.name, benefit.description, str(benefit)])
示例#8
0
 def test_name_and_description(self, range):
     """
     Tests that the benefit proxy classes all return a name and
     description. Unfortunately, the current implementations means
     a valid range is required.
     This test became necessary because the complex name/description logic
     broke with the python_2_unicode_compatible decorator.
     """
     for benefit_type, __ in Benefit.TYPE_CHOICES:
         benefit = Benefit(type=benefit_type, range=range)
         assert all(
             [benefit.name, benefit.description,
              six.text_type(benefit)])