• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python usage.UsagePlugin类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ralph_pricing.plugins.reports.usage.UsagePlugin的典型用法代码示例。如果您正苦于以下问题:Python UsagePlugin类的具体用法?Python UsagePlugin怎么用?Python UsagePlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UsagePlugin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_usages_by_internet_provider

 def test_get_usages_by_internet_provider(self):
     result = UsagePlugin._get_usages_per_warehouse(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type_cost_sum,
         ventures=self.ventures_subset,
         forecast=False,
     )
     # 5-12: (usages are from 8 to 12)
     #   usage: 5 * (30 + 60 + 90 + 120) = 1500;
     #   cost: 1000 + 10000 = 11000;
     #   price = 11000 / 1500 = 7.(3);
     # 13-17:
     #   usage: 5 * (30 + 60 + 90 + 120) = 1500;
     #   cost: 2000 + 20000 = 22000;
     #   price = 22000 / 1500 = 14.(6);
     # 18-25: (usages are from 18 to 22)
     #   usage: 5 * (30 + 60 + 90 + 120) = 1500;
     #   cost: 4000 + 40000 = 44000;
     #   price = 44000 / 1500 = 29.(3);
     self.assertEquals(result, {
         1: {
             'ut_3_count': 330.0,  # 3 * 30 + 5 * 30 + 3 * 30
             'ut_3_cost': D('5500'),  # 90*7.(3) + 150*14.(6) + 90*29.(3)
         },
         2: {
             'ut_3_count': 660.0,  # 3 * 60 + 5 * 60 + 3 * 60
             'ut_3_cost': D('11000'),  # 180*7.(3) + 300*14.(6) + 180*29.(3)
         },
     })
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:30,代码来源:test_usage_base.py


示例2: test_incomplete_price_incomplete_price

 def test_incomplete_price_incomplete_price(self):
     result = UsagePlugin._incomplete_price(
         usage_type=self.usage_type,
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 11, 20),
     )
     self.assertEquals(result, 'Incomplete price')
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:7,代码来源:test_usage_base.py


示例3: test_get_usage_type_cost_sum

 def test_get_usage_type_cost_sum(self):
     result = UsagePlugin._get_total_cost_by_warehouses(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type_cost_sum,
         ventures=self.ventures_subset,
         forecast=False,
     )
     # 5-12: (usages are from 8 to 12)
     #   usage: 5 * (30 + 60 + 90 + 120) = 1500;
     #   cost: 1000 + 10000 = 11000;
     #   price = 11000 / 1500 = 7.(3);
     # 13-17:
     #   usage: 5 * (30 + 60) = 1500;
     #   cost: 2000 + 20000 = 11000;
     #   price = 22000 / 1500 = 14.(6);
     # 18-25: (usages are from 18 to 22)
     #   usage: 5 * (30 + 60) = 1500;
     #   cost: 4000 + 40000 = 44000;
     #   price = 11000 / 1500 = 29.(3);
     #
     # 10-12:
     #   usage: 3 * (30 + 60) = 270;
     #   cost: 270 * 7.(3) = 1980
     # 13-17:
     #   usage: 5 * (30 + 60) = 450;
     #   cost: 450 * 14.(6) = 6600
     # 18-20:
     #   usage: 3 * (30 + 60) = 270;
     #   cost: 270 * 29.(3) = 7920
     #
     # total cost: 1980 + 6600 + 7920 = 16500
     self.assertEquals(result, [990.0, D('16500')])
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:33,代码来源:test_usage_base.py


示例4: test_get_usage_type_cost_sum_forecast

 def test_get_usage_type_cost_sum_forecast(self):
     result = UsagePlugin._get_total_cost_by_warehouses(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type_cost_sum,
         ventures=[self.venture1],
         forecast=True,
     )
     # 5-12: (usages are from 8 to 12)
     #   usage: 5 * (30 + 60 + 90 + 120) = 1500;
     #   cost: 2000 + 20000 = 22000;
     #   price = 22000 / 1500 = 14.(6);
     # 13-17:
     #   usage: 5 * (30 + 60) = 1500;
     #   cost: 3000 + 30000 = 33000;
     #   price = 33000 / 1500 = 22;
     # 18-25: (usages are from 18 to 22)
     #   usage: 5 * (30 + 60) = 1500;
     #   cost: 5000 + 50000 = 55000;
     #   price = 55000 / 1500 = 36.(6);
     #
     # 10-12: usage: 3 * 30 = 90; cost: 90 * 14.(6) = 1320
     # 13-17: usage: 5 * 30 = 150; cost: 150 * 22 = 3300
     # 18-20: usage: 3 * 30 = 90; cost = 90 * 36.(6) = 3300
     # total: usage: 330; cost: 7920
     self.assertEquals(result, [330.0, D('7920')])
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:26,代码来源:test_usage_base.py


示例5: test_incomplete_price_internet_providers_no_price

 def test_incomplete_price_internet_providers_no_price(self):
     result = UsagePlugin._incomplete_price(
         usage_type=self.usage_type_cost_sum,
         start=datetime.date(2013, 10, 26),
         end=datetime.date(2013, 11, 20),
     )
     self.assertEquals(result, 'No price')
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:7,代码来源:test_usage_base.py


示例6: test_get_usage_type_cost_by_cost

    def test_get_usage_type_cost_by_cost(self):
        result = UsagePlugin._get_total_cost_by_warehouses(
            start=datetime.date(2013, 10, 10),
            end=datetime.date(2013, 10, 20),
            usage_type=self.usage_type_cost_wh,
            ventures=self.ventures_subset,
            forecast=False,
        )
        # 5-12: (usages are from 8 to 12)
        #   warehouse1:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 3600;
        #               price = 3600 / 400 = 9;
        #   warehouse2:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 3600;
        #               price = 3600 / 600 = 6;
        # 13-17:
        #   warehouse1:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 5400
        #               price = 5400 / 600 = 9;
        #   warehouse2:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 3600
        #               price = 3600 / 400 = 9;
        # 18-25: (usages are from 18 to 22)
        #   warehouse1:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 4800
        #               price = 4800 / 400 = 12;
        #   warehouse2:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 7200
        #               price = 7200 / 600 = 12;

        # 10-12:
        #   warehouse1: usage: 1 * (20 + 40) = 60;
        #               cost: 60 * 9 = 540
        #   warehouse2: usage: 2 * (20 + 40) = 120;
        #               cost: 120 * 6 = 720
        # 13-17:
        #   warehouse1: usage: 3 * (20 + 40) = 180;
        #               cost: 180 * 9 = 1620
        #   warehouse2: usage: 2 * (20 + 40) = 120;
        #               cost: 120 * 9 = 1080
        # 18-20:
        #   warehouse1: usage: 1 * (20 + 40) = 60;
        #               cost: 60 * 12 = 720
        #   warehouse2: usage: 2 * (20 + 40) = 120;
        #               cost: 120 * 12 = 1440
        # total:
        #   warehouse1: usage: 300; cost: 2880
        #   warehouse2: usage: 360; cost: 3240
        #   total: cost: 6840
        self.assertEquals(
            result,
            [300.0, D('2880'), 360.0, D('3240'), D('6120')]
        )
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:59,代码来源:test_usage_base.py


示例7: test_get_usage_type_cost_by_cost_forecast

    def test_get_usage_type_cost_by_cost_forecast(self):
        result = UsagePlugin._get_total_cost_by_warehouses(
            start=datetime.date(2013, 10, 10),
            end=datetime.date(2013, 10, 20),
            usage_type=self.usage_type_cost_wh,
            ventures=[self.venture1],
            forecast=True,
        )
        # 5-12: (usages are from 8 to 12)
        #   warehouse1:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 2400;
        #               price = 2400 / 400 = 6;
        #   warehouse2:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 5400;
        #               price = 5400 / 600 = 9;
        # 13-17:
        #   warehouse1:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 5400
        #               price = 5400 / 600 = 9;
        #   warehouse2:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 1200
        #               price = 1200 / 400 = 3;
        # 18-25: (usages are from 18 to 22)
        #   warehouse1:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 12000
        #               price = 12000 / 400 = 30;
        #   warehouse2:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 3600
        #               price = 3600 / 600 = 6;

        # 10-12:
        #   warehouse1: usage: 1 * 20 = 20;
        #               cost: 20 * 6 = 120
        #   warehouse2: usage: 2 * 20 = 40;
        #               cost: 40 * 9 = 360
        # 13-17:
        #   warehouse1: usage: 3 * 20 = 60;
        #               cost: 60 * 9 = 540
        #   warehouse2: usage: 2 * 20 = 40;
        #               cost: 40 * 3 = 120
        # 18-20:
        #   warehouse1: usage: 1 * 20 = 20;
        #               cost: 20 * 30 = 600
        #   warehouse2: usage: 2 * 20 = 40;
        #               cost: 40 * 6 = 240
        # total:
        #   warehouse1: usage: 100; cost: 1260
        #   warehouse2: usage: 120; cost: 720
        #   total: cost: 1980
        self.assertEquals(
            result,
            [100.0, D('1260'), 120.0, D('720'), D('1980')]
        )
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:59,代码来源:test_usage_base.py


示例8: test_incomplete_price_by_warehouse

 def test_incomplete_price_by_warehouse(self):
     result = UsagePlugin._incomplete_price(
         usage_type=self.usage_type_cost_wh,
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         warehouse=self.warehouse1,
     )
     self.assertEquals(result, None)
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:8,代码来源:test_usage_base.py


示例9: test_get_total_cost_sum_whole

 def test_get_total_cost_sum_whole(self):
     result = UsagePlugin.total_cost(
         start=datetime.date(2013, 10, 5),
         end=datetime.date(2013, 10, 25),
         usage_type=self.usage_type_cost_sum,
         ventures=self.ventures,
         forecast=False,
     )
     self.assertEquals(result, D('77000'))
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:9,代码来源:test_usage_base.py


示例10: test_get_total_cost_sum

 def test_get_total_cost_sum(self):
     result = UsagePlugin.total_cost(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type_cost_sum,
         ventures=self.ventures_subset,
         forecast=False,
     )
     self.assertEquals(result, D('16500'))
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:9,代码来源:test_usage_base.py


示例11: test_get_total_cost_sum_beyond_usageprices

 def test_get_total_cost_sum_beyond_usageprices(self):
     # even with no_price_msg total cost should return valid cost
     result = UsagePlugin.total_cost(
         start=datetime.date(2013, 10, 1),
         end=datetime.date(2013, 10, 28),
         usage_type=self.usage_type_cost_sum,
         ventures=self.ventures,
         forecast=False,
         no_price_msg=True,
     )
     self.assertEquals(result, D('77000'))
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:11,代码来源:test_usage_base.py


示例12: test_get_usage_type_cost

 def test_get_usage_type_cost(self):
     result = UsagePlugin._get_total_cost_by_warehouses(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type,
         ventures=self.ventures_subset,
         forecast=False,
     )
     # 10-12: usage: 3 * (10 + 20) = 90; cost: 90 * 10 = 900
     # 13-17: usage: 5 * (10 + 20) = 150; cost: 150 * 20 = 3000
     # 18-20: usage: 3 * (10 + 20) = 90; cost = 90 * 30 = 2700
     # total: usage: 330; cost: 6600
     self.assertEquals(result, [330.0, D('6600')])
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:13,代码来源:test_usage_base.py


示例13: test_get_usage_type_cost_forecast

 def test_get_usage_type_cost_forecast(self):
     result = UsagePlugin._get_total_cost_by_warehouses(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type,
         ventures=[self.venture1],
         forecast=True,
     )
     # 10-12: usage: 3 * 10 = 30; cost: 30 * 50 = 1500
     # 13-17: usage: 5 * 10 = 50; cost: 50 * 60 = 3000
     # 18-20: usage: 3 * 10 = 30; cost = 30 * 70 = 2100
     # total: usage: 110; cost: 6600
     self.assertEquals(result, [110.0, D('6600')])
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:13,代码来源:test_usage_base.py


示例14: test_get_usages_per_warehouse_by_device

 def test_get_usages_per_warehouse_by_device(self):
     result = UsagePlugin._get_usages_per_warehouse(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type_cost_wh,
         ventures=[self.venture1],
         forecast=False,
         by_device=True,
     )
     self.assertEquals(result, {
         self.ventures_devices[self.venture1].id: {
             'ut_2_count_wh_1': 100.0,
             'ut_2_cost_wh_1': D('960'),
             'ut_2_count_wh_2': 120.0,
             'ut_2_cost_wh_2': D('1080'),
             'ut_2_total_cost': D('2040'),
         }
     })
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:18,代码来源:test_usage_base.py


示例15: test_usage_type_average

 def test_usage_type_average(self):
     result = UsagePlugin.costs(
         start=datetime.date(2013, 10, 10),
         end=datetime.date(2013, 10, 20),
         usage_type=self.usage_type_average,
         ventures=self.ventures_subset,
         forecast=False,
     )
     self.assertEquals(result, {
         1: {
             'ut_4_count': 40.0,  # average daily usage
             'ut_4_cost': D('8800'),
         },
         2: {
             'ut_4_count': 80.0,  # average daily usage
             'ut_4_cost': D('17600'),
         },
     })
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:18,代码来源:test_usage_base.py


示例16: test_get_usages_incomplete_price

 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'),
         }
     })
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:19,代码来源:test_usage_base.py


示例17: test_get_usages

 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)
         }
     })
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:19,代码来源:test_usage_base.py


示例18: test_get_usages_by_internet_provider_incomplete_price

 def test_get_usages_by_internet_provider_incomplete_price(self):
     result = UsagePlugin._get_usages_per_warehouse(
         start=datetime.date(2013, 10, 4),
         end=datetime.date(2013, 10, 26),
         usage_type=self.usage_type_cost_sum,
         ventures=self.ventures_subset,
         forecast=False,
         no_price_msg=True,
     )
     self.assertEquals(result, {
         1: {
             'ut_3_count': 450.0,  # 5 * 30 + 5 * 30 + 5 * 30
             'ut_3_cost': 'Incomplete price',
         },
         2: {
             'ut_3_count': 900.0,  # 5 * 60 + 5 * 60 + 5 * 60
             'ut_3_cost': 'Incomplete price',
         },
     })
开发者ID:kula1922,项目名称:ralph_pricing,代码行数:19,代码来源:test_usage_base.py


示例19: test_get_usages_no_price

 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'),
         }
     })
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:37,代码来源:test_usage_base.py


示例20: test_get_usages_per_warehouse_with_warehouse

    def test_get_usages_per_warehouse_with_warehouse(self):
        result = UsagePlugin._get_usages_per_warehouse(
            start=datetime.date(2013, 10, 10),
            end=datetime.date(2013, 10, 20),
            usage_type=self.usage_type_cost_wh,
            ventures=self.ventures_subset,
            forecast=False,
        )
        # prices:
        # 5-12: (usages are from 8 to 12)
        #   warehouse1:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 3600;
        #               price = 3600 / 400 = 9;
        #   warehouse2:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 3600;
        #               price = 3600 / 600 = 6;
        # 13-17:
        #   warehouse1:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 5400
        #               price = 5400 / 600 = 9;
        #   warehouse2:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 3600
        #               price = 3600 / 400 = 9;
        # 18-25: (usages are from 18 to 22)
        #   warehouse1:
        #               usage: 2 * (20 + 40 + 60 + 80) = 400;
        #               cost: 4800
        #               price = 4800 / 400 = 12;
        #   warehouse2:
        #               usage: 3 * (20 + 40 + 60 + 80) = 600;
        #               cost: 7200
        #               price = 7200 / 600 = 12;

        # warehouse1 has usages only in odd days
        # odd days in usages prices:
        # 10-12: 1
        # 13-17: 3
        # 18-20: 1

        # warehouse2 has usages only in even days
        # even days in usages prices:
        # 10-12: 2
        # 13-17: 2
        # 18-20: 2
        self.assertEquals(result, {
            1: {
                'ut_2_count_wh_1': 100.0,  # 5 * 20 (5 is number of odd days)
                'ut_2_cost_wh_1': D('960'),  # 20 * (1 * 9 + 3 * 9 + 1 * 12)
                'ut_2_count_wh_2': 120.0,  # 6 * 20 (6 is number of even days)
                'ut_2_cost_wh_2': D('1080'),  # 20 * (2 * 6 + 2 * 9 + 2 * 12)
                'ut_2_total_cost': D('2040'),  # 960 + 1080
            },
            2: {
                'ut_2_count_wh_1': 200.0,  # 5 * 40 (5 is number of odd days)
                'ut_2_cost_wh_1': D('1920'),  # 40 * (1 * 9 + 3 * 9 + 1 * 12)
                'ut_2_count_wh_2': 240.0,  # 6 * 40 (6 is number of even days)
                'ut_2_cost_wh_2': D('2160'),  # 40 * (2 * 6 + 2 * 9 + 2 * 12)
                'ut_2_total_cost': D('4080'),  # 1920 + 2160
            },
        })
开发者ID:ar4s,项目名称:ralph_pricing,代码行数:64,代码来源:test_usage_base.py



注:本文中的ralph_pricing.plugins.reports.usage.UsagePlugin类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ramanTools.RamanSpectrum类代码示例发布时间:2022-05-26
下一篇:
Python pricing.device_update_cached函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap