本文整理汇总了Python中ralph_pricing.plugins.reports.usage.UsagePlugin._get_usages_per_warehouse方法的典型用法代码示例。如果您正苦于以下问题:Python UsagePlugin._get_usages_per_warehouse方法的具体用法?Python UsagePlugin._get_usages_per_warehouse怎么用?Python UsagePlugin._get_usages_per_warehouse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ralph_pricing.plugins.reports.usage.UsagePlugin
的用法示例。
在下文中一共展示了UsagePlugin._get_usages_per_warehouse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_usages_by_internet_provider
# 需要导入模块: from ralph_pricing.plugins.reports.usage import UsagePlugin [as 别名]
# 或者: from ralph_pricing.plugins.reports.usage.UsagePlugin import _get_usages_per_warehouse [as 别名]
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)
},
})
示例2: test_get_usages_per_warehouse_by_device
# 需要导入模块: from ralph_pricing.plugins.reports.usage import UsagePlugin [as 别名]
# 或者: from ralph_pricing.plugins.reports.usage.UsagePlugin import _get_usages_per_warehouse [as 别名]
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'),
}
})
示例3: test_get_usages_by_internet_provider_incomplete_price
# 需要导入模块: from ralph_pricing.plugins.reports.usage import UsagePlugin [as 别名]
# 或者: from ralph_pricing.plugins.reports.usage.UsagePlugin import _get_usages_per_warehouse [as 别名]
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',
},
})
示例4: test_get_usages_per_warehouse_with_warehouse
# 需要导入模块: from ralph_pricing.plugins.reports.usage import UsagePlugin [as 别名]
# 或者: from ralph_pricing.plugins.reports.usage.UsagePlugin import _get_usages_per_warehouse [as 别名]
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
},
})