Beispiel #1
0
 def test_get_usages_incomplete_price(self):
     result = UsagePlugin.usages(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 30),
         usage_type=self.usage_type,
         ventures=self.ventures_subset,
         forecast=False,
         no_price_msg=True,
     )
     self.assertEquals(result, {
         1: {
             'ut_1_count': 130.0,  # 13 * 10
             'ut_1_cost': _('Incomplete price'),
         },
         2: {
             'ut_1_count': 260.0,  # 13 * 20
             'ut_1_cost': _('Incomplete price'),
         }
     })
Beispiel #2
0
 def test_get_usages(self):
     result = UsagePlugin.usages(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type,
         ventures=self.ventures_subset,
         forecast=False,
         no_price_msg=False,
     )
     self.assertEquals(result, {
         1: {
             'ut_1_count': 110.0,  # 11 * 10
             'ut_1_cost': D('2200'),  # 10 * (3 * 10 + 5 * 20 + 3 * 30)
         },
         2: {
             'ut_1_count': 220.0,  # 11 * 20
             'ut_1_cost': D('4400'),  # 20 * (3 * 10 + 5 * 20 + 3 * 30)
         }
     })
Beispiel #3
0
 def test_get_usages_no_price(self):
     start = datetime.date(2013, 11, 8)
     end = datetime.date(2013, 11, 22)
     base_usage_types = models.UsageType.objects.filter(type='BU')
     for i, ut in enumerate(base_usage_types, start=1):
         days = rrule.rrule(rrule.DAILY, dtstart=start, until=end)
         for j, day in enumerate(days, start=1):
             for k, venture in enumerate(self.ventures, start=1):
                 daily_usage = models.DailyUsage(
                     date=day,
                     pricing_venture=venture,
                     value=10 * i * k,
                     type=ut,
                 )
                 if ut.by_warehouse:
                     daily_usage.warehouse = (
                         self.warehouses[j % len(self.warehouses)]
                     )
                 daily_usage.save()
     result = UsagePlugin.usages(
         start=datetime.date(2013, 11, 10),
         end=datetime.date(2013, 11, 20),
         usage_type=self.usage_type,
         ventures=self.ventures_subset,
         forecast=False,
         no_price_msg=True,
     )
     self.assertEquals(result, {
         1: {
             'ut_1_count': 110.0,  # 11 * 10
             'ut_1_cost': _('No price'),
         },
         2: {
             'ut_1_count': 220.0,  # 11 * 20
             'ut_1_cost': _('No price'),
         }
     })