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