def test_deletion(self, user_response): tab = ReactionTab() model = Model() reaction1 = Reaction("r1") reaction2 = Reaction("r2") reaction3 = Reaction("r3") model.add_reactions([reaction1, reaction2, reaction3]) model.setup_reaction_table() assert len(model.reactions) == model.QtReactionTable.rowCount() == 3 tab.set_model(model) tab.confirmDeletion = Mock(return_value=user_response) item = tab.dataTable.item(1, 0) selected_reaction = item.link source_index = tab.dataTable.indexFromItem(item) view_index = tab.proxyModel.mapFromSource(source_index) tab.dataView.selectRow(view_index.row()) assert tab.confirmDeletion.called is False tab.deleteItemSlot() assert tab.confirmDeletion.called is True assert (selected_reaction in model.reactions) is not user_response assert tab.dataTable.findItems( selected_reaction.id) is not user_response if user_response: assert len( model.reactions) == model.QtReactionTable.rowCount() == 2
def test_modify_item_reject(self): tab = ReactionTab() model = Model() model.QtReactionTable.update_row_from_link = Mock() reaction = Reaction(id="old_id") model.add_reactions([reaction]) model.setup_reaction_table() tab.set_model(model) tab.dataView.selectRow(0) assert model.QtReactionTable.update_row_from_link.called is False tab.editItemSlot() assert model.QtReactionTable.update_row_from_link.called is False