예제 #1
0
 def test_multiple_equipment_items(self):
     equipment1 = Equipment()
     equipment1.id = 1
     equipment2 = Equipment()
     equipment2.id = 2
     self.mock_equipment_service.get_all_equipment.return_value = [equipment1, equipment2]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     iter = equipment_store.iter_next(iter)
     self.assertEquals(2, equipment_store.get_value(iter, 0))
예제 #2
0
 def test_multiple_equipment_items(self):
     equipment1 = Equipment()
     equipment1.id = 1
     equipment2 = Equipment()
     equipment2.id = 2
     self.mock_equipment_service.get_all_equipment.return_value = [
         equipment1, equipment2
     ]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     iter = equipment_store.iter_next(iter)
     self.assertEquals(2, equipment_store.get_value(iter, 0))
예제 #3
0
 def test_get_item_id(self):
     equipment = Equipment()
     equipment.id = 1
     self.mock_equipment_service.get_all_equipment.return_value = [equipment]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertEquals(1, equipment_store.get_value(iter, 0))
예제 #4
0
 def test_get_item_description(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.description = u"item description"
     self.mock_equipment_service.get_all_equipment.return_value = [equipment]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertEquals("item description", equipment_store.get_value(iter, 1))
예제 #5
0
 def test_get_item_active(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.active = False
     self.mock_equipment_service.get_all_equipment.return_value = [equipment]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertFalse(equipment_store.get_value(iter, 4))
예제 #6
0
 def test_id_set_to_non_numeric_string(self):
     equipment = Equipment()
     try:
         equipment.id = "test"
     except(ValueError):
         pass
     else:
         self.fail("Should not be able to set equipment id to non numeric value.")
예제 #7
0
 def test_id_set_to_non_numeric_string(self):
     equipment = Equipment()
     try:
         equipment.id = "test"
     except (ValueError):
         pass
     else:
         self.fail("Should not be able to set equipment id to non numeric value.")
예제 #8
0
 def test_get_item_id(self):
     equipment = Equipment()
     equipment.id = 1
     self.mock_equipment_service.get_all_equipment.return_value = [
         equipment
     ]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertEquals(1, equipment_store.get_value(iter, 0))
예제 #9
0
 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))
예제 #10
0
 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))
예제 #11
0
 def test_update_equipment_non_existant(self):
     self.mock_ddbb.select.return_value = []
     equipment = Equipment()
     equipment.id = 1
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to update an item which did not previously exist.")
     except (EquipmentServiceException):
         pass
예제 #12
0
 def test_update_equipment_non_existant(self):
     self.mock_ddbb.select.return_value = []
     equipment = Equipment()
     equipment.id = 1
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to update an item which did not previously exist.")
     except(EquipmentServiceException):
         pass
예제 #13
0
 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%.")
예제 #14
0
 def test_id_set_to_non_numeric_string(self):
     equipment = Equipment()
     equipment.id = "test"
     try:
         self.ddbb.session.add(equipment)
         self.ddbb.session.flush()
     except (IntegrityError, OperationalError, DataError):
         pass
     else:
         self.fail("Should not be able to set equipment id to non numeric value.")
예제 #15
0
 def test_update_equipment_duplicate_description(self):
     self.mock_ddbb.select.return_value = [(1, u"test item", True, 500, 200, u"Test notes.")]
     equipment = Equipment()
     equipment.id = 2
     equipment.description = u"test item"
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to change item description to non-unique value.")
     except(EquipmentServiceException):
         pass
예제 #16
0
 def test_update_equipment(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.description = u"new description"
     self.mock_ddbb.select.return_value =  [(1, u"old description", 1, 0, 0,u"")]
     self.equipment_service.store_equipment(equipment)
     self.mock_ddbb.update.assert_called_with("equipment", 
                                              "description,active,life_expectancy,prior_usage,notes", 
                                              ["new description", 1, 0, 0,"" ], 
                                              "id = 1")
예제 #17
0
 def test_get_item_active(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.active = False
     self.mock_equipment_service.get_all_equipment.return_value = [
         equipment
     ]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertFalse(equipment_store.get_value(iter, 4))
예제 #18
0
 def test_update_equipment_duplicate_description(self):
     self.mock_ddbb.select.return_value = [(1, u"test item", True, 500, 200, u"Test notes.")]
     equipment = Equipment()
     equipment.id = 2
     equipment.description = u"test item"
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to change item description to non-unique value.")
     except (EquipmentServiceException):
         pass
예제 #19
0
 def test_get_item_usage_text_rounded(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.6
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertEqual("101 / 200", equipment_store.get_value(iter, 3))
예제 #20
0
 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))
예제 #21
0
 def test_get_item_usage_text_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("300 / 200", equipment_store.get_value(iter, 3))
예제 #22
0
 def test_get_item_description(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.description = u"item description"
     self.mock_equipment_service.get_all_equipment.return_value = [
         equipment
     ]
     equipment_store = EquipmentStore(self.mock_equipment_service)
     iter = equipment_store.get_iter_first()
     self.assertEquals("item description",
                       equipment_store.get_value(iter, 1))
예제 #23
0
 def test_id_set_to_non_numeric_string(self):
     if self.ddbb.engine.name == 'mysql':
         self.skipTest('Not supported on Mysql 5.6')
     equipment = Equipment()
     equipment.id = "test"
     try:
         self.ddbb.session.add(equipment)
         self.ddbb.session.flush()
     except (IntegrityError, OperationalError, DataError):
         pass
     else:
         self.fail("Should not be able to set equipment id to non numeric value.")
예제 #24
0
 def test_update_equipment(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.description = u"new description"
     self.mock_ddbb.select.return_value = [(1, u"old description", 1, 0, 0, u"")]
     self.equipment_service.store_equipment(equipment)
     self.mock_ddbb.update.assert_called_with(
         "equipment",
         "description,active,life_expectancy,prior_usage,notes",
         ["new description", 1, 0, 0, ""],
         "id = 1",
     )
예제 #25
0
 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%.")
예제 #26
0
 def test_update_equipment_duplicate_description(self):
     self.mock_ddbb.session.execute(self.equipment_table.insert(),
                                        {"life_expectancy": 500,
                                             "notes": u"Test notes.",
                                        "description": u"test item",
                                        "prior_usage": 200, "active": True})
     equipment = Equipment()
     equipment.id = 2
     equipment.description = u"test item"
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to change item description to non-unique value.")
     except(EquipmentServiceException):
         pass
예제 #27
0
 def test_get_equipment_usage_none(self):
     self.mock_ddbb.select.return_value = [(None,)]
     equipment = Equipment()
     equipment.id = 1
     usage = self.equipment_service.get_equipment_usage(equipment)
     self.assertEquals(0, usage)
예제 #28
0
 def test_get_equipment_usage_none(self):
     self.mock_ddbb.select.return_value = [(None,)]
     equipment = Equipment()
     equipment.id = 1
     usage = self.equipment_service.get_equipment_usage(equipment)
     self.assertEquals(0, usage)
예제 #29
0
 def test_id_set_to_numeric_string(self):
     equipment = Equipment()
     equipment.id = "3"
     self.assertEquals(3, equipment.id)
예제 #30
0
 def test_equals_instances_with_same_id(self):
     equipment1 = Equipment()
     equipment1.id = 1
     equipment2 = Equipment()
     equipment2.id = 1
     self.assertEqual(equipment1, equipment2, "Equipment instances with same id should be equal.")
예제 #31
0
 def test_equals_instances_with_different_ids(self):
     equipment1 = Equipment()
     equipment1.id = 1
     equipment2 = Equipment()
     equipment2.id = 2
     self.assertNotEqual(equipment1, equipment2, "Equipment instances with different ids should not be equal.")
예제 #32
0
 def test_id_set_to_integer(self):
     equipment = Equipment()
     equipment.id = 2
     self.assertEquals(2, equipment.id)
예제 #33
0
 def test_id_set_to_numeric_string(self):
     equipment = Equipment()
     equipment.id = "3"
     self.assertEquals(3, equipment.id)
예제 #34
0
 def test_equals_instances_with_same_id(self):
     equipment1 = Equipment()
     equipment1.id = 1
     equipment2 = Equipment()
     equipment2.id = 1
     self.assertEqual(equipment1, equipment2, "Equipment instances with same id should be equal.")
예제 #35
0
 def test_equals_instances_with_different_ids(self):
     equipment1 = Equipment()
     equipment1.id = 1
     equipment2 = Equipment()
     equipment2.id = 2
     self.assertNotEqual(equipment1, equipment2, "Equipment instances with different ids should not be equal.")
예제 #36
0
 def test_id_set_to_numeric_string(self):
     equipment = Equipment()
     equipment.id = "3"
     self.ddbb.session.add(equipment)
     self.ddbb.session.commit()
     self.assertEquals(3, equipment.id)
예제 #37
0
 def test_id_set_to_integer(self):
     equipment = Equipment()
     equipment.id = 2
     self.assertEquals(2, equipment.id)
예제 #38
0
 def test_get_equipment_prior_usage(self):
     equipment = Equipment()
     equipment.id = 1
     equipment.prior_usage = 250
     usage = self.equipment_service.get_equipment_usage(equipment)
     self.assertEquals(250, usage)