當前位置: 首頁>>代碼示例>>Python>>正文


Python DeviceModelGroup.price方法代碼示例

本文整理匯總了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)
開發者ID:damjanek,項目名稱:ralph,代碼行數:30,代碼來源:tests.py

示例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)
開發者ID:damjanek,項目名稱:ralph,代碼行數:13,代碼來源:tests.py

示例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)
開發者ID:viciu,項目名稱:ralph,代碼行數:13,代碼來源:tests.py

示例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)
開發者ID:Makdaam,項目名稱:ralph,代碼行數:16,代碼來源:tests.py

示例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)
開發者ID:szaydel,項目名稱:ralph,代碼行數:17,代碼來源:tests.py

示例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)
開發者ID:szaydel,項目名稱:ralph,代碼行數:20,代碼來源:tests.py

示例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)
開發者ID:Makdaam,項目名稱:ralph,代碼行數:22,代碼來源:tests.py

示例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)
開發者ID:damjanek,項目名稱:ralph,代碼行數:23,代碼來源:tests.py

示例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)
開發者ID:damjanek,項目名稱:ralph,代碼行數:24,代碼來源:tests.py


注:本文中的ralph.discovery.models.DeviceModelGroup.price方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。