Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 def test_description_set_to_non_string(self):
     equipment = Equipment()
     try:
         equipment.description = 42
     except (TypeError):
         pass
     else:
         self.fail("Should not be able to set description to non string value.")
Exemplo n.º 3
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))
Exemplo n.º 4
0
 def test_description_set_to_non_string(self):
     equipment = Equipment()
     try:
         equipment.description = 42
     except(TypeError):
         pass
     else:
         self.fail("Should not be able to set description to non string value.")
Exemplo n.º 5
0
 def test_store_equipment_duplicate_description(self):
     self.mock_ddbb.select.return_value = [(1,)]
     equipment = Equipment()
     equipment.description = u"test item"
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to store new item with non-unique description.")
     except(EquipmentServiceException):
         pass
Exemplo n.º 6
0
 def test_store_equipment_duplicate_description(self):
     self.mock_ddbb.select.return_value = [(1,)]
     equipment = Equipment()
     equipment.description = u"test item"
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to store new item with non-unique description.")
     except (EquipmentServiceException):
         pass
Exemplo n.º 7
0
 def test_description_set_to_non_unicode_string(self):
     equipment = Equipment()
     equipment.description = "100$ Shoes" + chr(255)
     try:
         self.ddbb.session.add(equipment)
         self.ddbb.session.flush()
     except (ProgrammingError, DataError):
         pass
     else:
         self.fail("Should not be able to set description to non unicode string value.")
Exemplo n.º 8
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
Exemplo n.º 9
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
Exemplo n.º 10
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")
Exemplo n.º 11
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))
Exemplo n.º 12
0
 def test_description_set_to_non_unicode_string(self):
     if self.ddbb.engine.name == 'mysql':
         self.skipTest('Not supported on Mysql 5.6')
     equipment = Equipment()
     equipment.description = "100$ Shoes" + chr(255)
     try:
         self.ddbb.session.add(equipment)
         self.ddbb.session.flush()
     except (ProgrammingError, DataError, OperationalError):
         pass
     else:
         self.fail("Should not be able to set description to non unicode string value.")
Exemplo n.º 13
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",
     )
Exemplo n.º 14
0
 def test_store_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.description = u"test item"
     try:
         self.equipment_service.store_equipment(equipment)
         self.fail("Should not be able to store new item with non-unique description.")
     except(EquipmentServiceException):
         pass
Exemplo n.º 15
0
 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()
Exemplo n.º 16
0
 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()
Exemplo n.º 17
0
 def test_store_equipment(self):
     equipment = Equipment()
     equipment.description = u"test description"
     equipment_ids = []
     def mock_select(table, columns, where):
         if columns == "id":
             return equipment_ids
         else:
             return [(2, u"", 1, 0, 0,u"")]
     def update_equipment_ids(*args):
         equipment_ids.append([1])
     self.mock_ddbb.select = mock.Mock(wraps=mock_select)
     self.mock_ddbb.insert.side_effect = update_equipment_ids
     stored_equipment = self.equipment_service.store_equipment(equipment)
     self.mock_ddbb.insert.assert_called_with("equipment", 
                                              "description,active,life_expectancy,prior_usage,notes", 
                                              ["test description", 1, 0, 0,"" ])
     self.assertEquals(2, stored_equipment.id)
Exemplo n.º 18
0
    def test_store_equipment(self):
        equipment = Equipment()
        equipment.description = u"test description"
        equipment_ids = []

        def mock_select(table, columns, where):
            if columns == "id":
                return equipment_ids
            else:
                return [(2, u"", 1, 0, 0, u"")]

        def update_equipment_ids(*args):
            equipment_ids.append([1])

        self.mock_ddbb.select = mock.Mock(wraps=mock_select)
        self.mock_ddbb.insert.side_effect = update_equipment_ids
        stored_equipment = self.equipment_service.store_equipment(equipment)
        self.mock_ddbb.insert.assert_called_with(
            "equipment", "description,active,life_expectancy,prior_usage,notes", ["test description", 1, 0, 0, ""]
        )
        self.assertEquals(2, stored_equipment.id)
Exemplo n.º 19
0
 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()
Exemplo n.º 20
0
 def test_description_set_to_non_string(self):
     equipment = Equipment()
     equipment.description = 42
     self.ddbb.session.add(equipment)
     self.ddbb.session.commit()
     self.assertEquals(u"42", equipment.description)
Exemplo n.º 21
0
 def test_description_set_to_unicode_string(self):
     equipment = Equipment()
     equipment.description = u"Zapatos de €100"
     self.assertEquals(u"Zapatos de €100", equipment.description)
Exemplo n.º 22
0
 def test_description_set_to_unicode_string(self):
     equipment = Equipment()
     equipment.description = u"Zapatos de €100"
     self.assertEquals(u"Zapatos de €100", equipment.description)
Exemplo n.º 23
0
 def test_store_equipment(self):
     equipment = Equipment()
     equipment.description = u"test description"
     stored_equipment = self.equipment_service.store_equipment(equipment)
     self.assertEquals(1, stored_equipment.id)