Esempio n. 1
0
 def test_schema_with_warehouse(self):
     result = UsagePlugin(usage_type=self.usage_type_cost_wh, type='schema')
     self.assertEquals(
         result,
         OrderedDict([
             ('ut_2_count_wh_1', {
                 'name': _('UsageType2 count (Warehouse1)'),
                 'rounding': 2,
                 'divide_by': 0,
             }),
             ('ut_2_cost_wh_1', {
                 'name': _('UsageType2 cost (Warehouse1)'),
                 'currency': True,
             }),
             ('ut_2_count_wh_2', {
                 'name': _('UsageType2 count (Warehouse2)'),
                 'rounding': 2,
                 'divide_by': 0,
             }),
             ('ut_2_cost_wh_2', {
                 'name': _('UsageType2 cost (Warehouse2)'),
                 'currency': True,
             }),
             ('ut_2_total_cost', {
                 'name': _('UsageType2 total cost'),
                 'currency': True,
                 'total_cost': True,
             }),
         ]))
Esempio n. 2
0
 def test_schema(self):
     result = UsagePlugin(usage_type=self.usage_type, type='schema')
     self.assertEquals(
         result,
         OrderedDict([
             ('ut_1_count', {
                 'name': _('UsageType1 count')
             }),
             ('ut_1_cost', {
                 'name': _('UsageType1 cost'),
                 'currency': True,
                 'total_cost': True,
             }),
         ]))
Esempio n. 3
0
 def test_get_dailyusages(self):
     # test if sum of usages per day if properly calculated
     du = models.DailyUsage(
         date=datetime.date(2013, 10, 11),
         pricing_venture=self.venture2,
         pricing_device=utils.get_or_create_device(),
         value=100,
         type=self.usage_type,
     )
     du.save()
     result = UsagePlugin(
         usage_type=self.usage_type,
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 13),
         ventures=self.ventures_subset,
         type='dailyusages',
     )
     self.assertEquals(
         result,
         {
             datetime.date(2013, 10, 10): {
                 self.venture1.id: 10,
                 self.venture2.id: 20,
             },
             datetime.date(2013, 10, 11): {
                 self.venture1.id: 10,
                 self.venture2.id: 120,  # additional usage!
             },
             datetime.date(2013, 10, 12): {
                 self.venture1.id: 10,
                 self.venture2.id: 20,
             },
             datetime.date(2013, 10, 13): {
                 self.venture1.id: 10,
                 self.venture2.id: 20,
             },
         })
Esempio n. 4
0
 def test_usages_schema(self):
     result = UsagePlugin(usage_type=self.usage_type_cost_wh,
                          type='dailyusages_header')
     self.assertEquals(result, self.usage_type_cost_wh.name)