本文整理汇总了Python中pytrainer.core.equipment.Equipment.life_expectancy方法的典型用法代码示例。如果您正苦于以下问题:Python Equipment.life_expectancy方法的具体用法?Python Equipment.life_expectancy怎么用?Python Equipment.life_expectancy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytrainer.core.equipment.Equipment
的用法示例。
在下文中一共展示了Equipment.life_expectancy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_life_expectancy_set_to_non_numeric_string
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def test_life_expectancy_set_to_non_numeric_string(self):
equipment = Equipment()
try:
equipment.life_expectancy = "test"
except (ValueError):
pass
else:
self.fail("Should not be able to set life expectancy to non numeric value.")
示例2: test_get_item_usage_text
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def test_get_item_usage_text(self):
equipment = Equipment()
equipment.id = 1
equipment.life_expectancy = 200
self.mock_equipment_service.get_all_equipment.return_value = [equipment]
self.mock_equipment_service.get_equipment_usage.return_value = 100
equipment_store = EquipmentStore(self.mock_equipment_service)
iter = equipment_store.get_iter_first()
self.assertEquals("100 / 200", equipment_store.get_value(iter, 3))
示例3: test_get_item_usage_percent_usage_exceeds_life_expectancy
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def test_get_item_usage_percent_usage_exceeds_life_expectancy(self):
equipment = Equipment()
equipment.id = 1
equipment.life_expectancy = 200
self.mock_equipment_service.get_all_equipment.return_value = [equipment]
self.mock_equipment_service.get_equipment_usage.return_value = 300
equipment_store = EquipmentStore(self.mock_equipment_service)
iter = equipment_store.get_iter_first()
self.assertEquals(100, equipment_store.get_value(iter, 2), "Progress bar cannot exceed 100%.")
示例4: test_get_item_usage_percent_zero_usage
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def test_get_item_usage_percent_zero_usage(self):
equipment = Equipment()
equipment.id = 1
equipment.life_expectancy = 200
self.mock_equipment_service.get_all_equipment.return_value = [equipment]
self.mock_equipment_service.get_equipment_usage.return_value = 0
equipment_store = EquipmentStore(self.mock_equipment_service)
iter = equipment_store.get_iter_first()
self.assertEquals(0, equipment_store.get_value(iter, 2))
示例5: _confirm_add_equipment_clicked
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def _confirm_add_equipment_clicked(self, widget):
#FIXME input validation for numeric fields
description = self._builder.get_object("entryEquipmentAddDescription").get_text()
life_expectancy = self._builder.get_object("entryEquipmentAddLifeExpectancy").get_text()
prior_usage = self._builder.get_object("entryEquipmentAddPriorUsage").get_text()
active = self._builder.get_object("checkbuttonEquipmentAddActive").get_active()
notes_buffer = self._builder.get_object("textviewEquipmentAddNotes").get_buffer()
notes = notes_buffer.get_text(notes_buffer.get_start_iter(), notes_buffer.get_end_iter())
new_equipment = Equipment()
new_equipment.description = unicode(description)
new_equipment.active = active
new_equipment.life_expectancy = life_expectancy
new_equipment.prior_usage = prior_usage
new_equipment.notes = unicode(notes)
self._equipment_store.add_equipment(new_equipment)
self.show_page_equipment_list()
示例6: _confirm_add_equipment_clicked
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def _confirm_add_equipment_clicked(self, widget):
#FIXME input validation for numeric fields
description = gtk_str(self._builder.get_object("entryEquipmentAddDescription").get_text())
life_expectancy = gtk_str(self._builder.get_object("entryEquipmentAddLifeExpectancy").get_text())
prior_usage = gtk_str(self._builder.get_object("entryEquipmentAddPriorUsage").get_text())
active = self._builder.get_object("checkbuttonEquipmentAddActive").get_active()
notes_buffer = self._builder.get_object("textviewEquipmentAddNotes").get_buffer()
notes = gtk_str(notes_buffer.get_text(notes_buffer.get_start_iter(),
notes_buffer.get_end_iter(), True))
new_equipment = Equipment()
new_equipment.description = description
new_equipment.active = bool(active)
new_equipment.life_expectancy = int(life_expectancy)
new_equipment.prior_usage = int(prior_usage)
new_equipment.notes = notes
self._equipment_store.add_equipment(new_equipment)
self.show_page_equipment_list()
示例7: test_life_expectancy_set_to_numeric_string
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def test_life_expectancy_set_to_numeric_string(self):
equipment = Equipment()
equipment.life_expectancy = "3"
self.assertEquals(3, equipment.life_expectancy)
示例8: test_life_expectancy_set_to_integer
# 需要导入模块: from pytrainer.core.equipment import Equipment [as 别名]
# 或者: from pytrainer.core.equipment.Equipment import life_expectancy [as 别名]
def test_life_expectancy_set_to_integer(self):
equipment = Equipment()
equipment.life_expectancy = 2
self.assertEquals(2, equipment.life_expectancy)