Exemple #1
0
 def test_total_cost(self):
     self.assertEqual(
         D(4240),
         ServicePlugin.total_cost(
             datetime.date(2013, 10, 10),
             datetime.date(2013, 10, 20),
             self.service,
             False,
             [self.venture1]
         )
     )
    def test_total_cost(self):
        # add regular usage type
        regular_usage_type = models.UsageType(
            name='RUsageType1',
            symbol='rut1',
            by_cost=True,
            type='RU',
        )
        regular_usage_type.save()
        models.DailyUsage(
            type=regular_usage_type,
            pricing_venture=self.venture1,
            value=100,
            date=datetime.date(2013, 10, 11)
        ).save()
        models.DailyUsage(
            type=regular_usage_type,
            pricing_venture=self.venture2,
            value=300,
            date=datetime.date(2013, 10, 12)
        ).save()
        models.ServiceUsageTypes(
            usage_type=self.service_usage_type1,
            service=self.service,
            start=datetime.date(2013, 10, 1),
            end=datetime.date(2013, 10, 30),
            percent=100,
        ).save()
        models.UsagePrice(
            type=regular_usage_type,
            start=datetime.date(2013, 10, 1),
            end=datetime.date(2013, 10, 30),
            cost=1000
        ).save()
        self.service.regular_usage_types.add(regular_usage_type)
        self.service.save()

        self.assertEqual(
            D(4490),
            ServicePlugin.total_cost(
                datetime.date(2013, 10, 10),
                datetime.date(2013, 10, 20),
                self.service,
                False,
                [self.venture1]
            )
        )
    def test_total_cost(self):
        # add regular usage type
        regular_usage_type = models.UsageType(
            name='RUsageType1',
            symbol='rut1',
            by_cost=True,
            type='RU',
        )
        regular_usage_type.save()
        models.DailyUsage(type=regular_usage_type,
                          pricing_venture=self.venture1,
                          value=100,
                          date=datetime.date(2013, 10, 11)).save()
        models.DailyUsage(type=regular_usage_type,
                          pricing_venture=self.venture2,
                          value=300,
                          date=datetime.date(2013, 10, 12)).save()
        models.ServiceUsageTypes(
            usage_type=self.service_usage_type1,
            service=self.service,
            start=datetime.date(2013, 10, 1),
            end=datetime.date(2013, 10, 30),
            percent=100,
        ).save()
        models.UsagePrice(type=regular_usage_type,
                          start=datetime.date(2013, 10, 1),
                          end=datetime.date(2013, 10, 30),
                          cost=1000).save()
        self.service.regular_usage_types.add(regular_usage_type)
        self.service.save()

        self.assertEqual(
            D(4490),
            ServicePlugin.total_cost(datetime.date(2013, 10, 10),
                                     datetime.date(2013, 10, 20), self.service,
                                     False, [self.venture1]))