本文整理汇总了Python中ralph.discovery.models.DeviceModelGroup.price方法的典型用法代码示例。如果您正苦于以下问题:Python DeviceModelGroup.price方法的具体用法?Python DeviceModelGroup.price怎么用?Python DeviceModelGroup.price使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ralph.discovery.models.DeviceModelGroup
的用法示例。
在下文中一共展示了DeviceModelGroup.price方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_blade_server
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_blade_server(self):
encl = Device.create(sn='devicex', model_type=DeviceType.blade_system,
model_name='device encl')
dev = Device.create(sn='device', model_type=DeviceType.blade_server,
model_name='device', parent=encl)
encl_dmg = DeviceModelGroup(name='DeviceModelGroup encl')
encl_dmg.slots = 4
encl_dmg.price = 65535
encl_dmg.save()
encl.model.group = encl_dmg
encl.model.save()
dmg = DeviceModelGroup(name='DeviceModelGroup')
dmg.price = 1337
dmg.slots = 1
dmg.save()
dev.model.group = dmg
dev.model.save()
pricing.device_update_cached(encl)
pricing.device_update_cached(dev)
dev = Device.objects.get(id=dev.id)
encl = Device.objects.get(id=encl.id)
self.assertEquals(dev.cached_price, 17720.75)
self.assertEquals(encl.cached_price, 49151.25)
self.assertEquals(dev.cached_price + encl.cached_price, 65535 + 1337)
示例2: test_rack_server
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_rack_server(self):
dev = Device.create(sn='device', model_type=DeviceType.rack_server,
model_name='device')
dmg = DeviceModelGroup(name='DeviceModelGroup')
dmg.price = 1337
dmg.save()
dev.model.group = dmg
dev.model.save()
pricing.device_update_cached(dev)
dev = Device.objects.get(id=dev.id)
self.assertEquals(dev.cached_price, 1337)
示例3: test_rack_server
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_rack_server(self):
dev = Device.create(sn="device", model_type=DeviceType.rack_server, model_name="device")
dmg = DeviceModelGroup(name="DeviceModelGroup")
dmg.price = 1337
dmg.save()
dev.model.group = dmg
dev.model.save()
pricing.device_update_cached(dev)
self.assertEquals(dev.cached_price, 1337)
示例4: test_manual_price
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_manual_price(self):
dev = Device.create(sn='device', model_type=DeviceType.rack_server,
model_name='device')
dmg = DeviceModelGroup(name='DeviceModelGroup')
dmg.price = 1337
dmg.save()
dev.model.group = dmg
dev.model.save()
dev.price = 238
dev.save()
pricing.device_update_cached(dev)
self.assertEquals(dev.cached_price, 238)
示例5: test_cost
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_cost(self):
dev = Device.create(sn="device", model_type=DeviceType.rack_server, model_name="device")
dmg = DeviceModelGroup(name="DeviceModelGroup")
dmg.price = 100
dmg.save()
dev.model.group = dmg
dev.model.save()
dev.margin_kind = MarginKind(name="50%", margin=50)
dev.margin_kind.save()
dev.deprecation_kind = DeprecationKind(name="10 months", months=10)
dev.deprecation_kind.save()
dev.save()
pricing.device_update_cached(dev)
self.assertEqual(dev.cached_cost, 15)
示例6: test_price_deprecation
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_price_deprecation(self):
# Device after deprecation period should have raw price = 0
dev = Device.create(sn="device", model_type=DeviceType.rack_server, model_name="device")
dmg = DeviceModelGroup(name="DeviceModelGroup")
dmg.price = 100
dmg.save()
dev.model.group = dmg
dev.purchase_date = datetime.today() - timedelta(11 * (365 / 12))
dev.model.save()
dev.margin_kind = MarginKind(name="50%", margin=50)
dev.margin_kind.save()
dev.deprecation_kind = DeprecationKind(name="10 months", months=10)
dev.deprecation_kind.save()
dev.save()
pricing.device_update_cached(dev)
self.assertEqual(get_device_raw_price(dev), 0)
self.assertEqual(dev.cached_price, 0)
self.assertEqual(dev.cached_cost, 0)
示例7: test_price_deprecation_in_progress
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_price_deprecation_in_progress(self):
# Device in deprecation period should have raw price >0 if price is set
dev = Device.create(sn='device', model_type=DeviceType.rack_server,
model_name='device')
dmg = DeviceModelGroup(name='DeviceModelGroup')
dmg.price = 100
dmg.save()
dev.model.group = dmg
# currently first month in deprecation period
dev.purchase_date = datetime.today() - timedelta(1 * (365 / 12))
dev.model.save()
dev.margin_kind = MarginKind(name='50%', margin=50)
dev.margin_kind.save()
dev.deprecation_kind = DeprecationKind(name='10 months', months=10)
dev.deprecation_kind.save()
dev.save()
pricing.device_update_cached(dev)
self.assertEqual(get_device_raw_price(dev), 100)
self.assertEqual(dev.cached_cost, 15)
self.assertEqual(dev.cached_price, 100)
示例8: test_cost
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_cost(self):
dev = Device.create(sn='device', model_type=DeviceType.rack_server,
model_name='device')
dmg = DeviceModelGroup(name='DeviceModelGroup')
dmg.price = 100
dmg.save()
dev.model.group = dmg
dev.model.save()
mk = MarginKind(name='50%', margin=50)
mk.save()
dev.margin_kind = mk
dk = DeprecationKind(name='10 months', months=10)
dk.save()
dev.deprecation_kind = dk
dev.save()
self.assertEqual(pricing.get_device_cost(dev), 15)
pricing.device_update_cached(dev)
dev = Device.objects.get(id=dev.id)
self.assertEqual(pricing.get_device_cost(dev), 15)
self.assertEqual(dev.cached_cost, 15)
示例9: test_price_deprecation
# 需要导入模块: from ralph.discovery.models import DeviceModelGroup [as 别名]
# 或者: from ralph.discovery.models.DeviceModelGroup import price [as 别名]
def test_price_deprecation(self):
# Device after deprecation period should have raw price = 0
dev = Device.create(sn='device', model_type=DeviceType.rack_server,
model_name='device')
dmg = DeviceModelGroup(name='DeviceModelGroup')
dmg.price = 100
dmg.save()
dev.model.group = dmg
dev.purchase_date = datetime.today() - timedelta(11 * (365 / 12))
dev.model.save()
mk = MarginKind(name='50%', margin=50)
mk.save()
dev.margin_kind = mk
dk = DeprecationKind(name='10 months', months=10)
dk.save()
dev.deprecation_kind = dk
dev.save()
pricing.device_update_cached(dev)
dev = Device.objects.get(id=dev.id)
self.assertEqual(get_device_raw_price(dev), 0)
self.assertEqual(dev.cached_price, 0)
self.assertEqual(dev.cached_cost, 0)