def test_delete_exception(mocker, general_test_customer): mock_session = mocker.patch.object(sqlalchemy.orm.Session, 'delete', name="mock_session") mock_session.delete.side_effect = RuntimeError("Error deleting customer") base_dao = BaseDao(Customer, mock_session) try: base_dao.delete(general_test_customer.get_identifier()) except RuntimeError as e: assert str(e) == "Error deleting customer"
def test_delete(mocker): mock_session = mocker.Mock(sqlalchemy.orm.Session) base_dao = BaseDao(Customer, mock_session) actual_result = base_dao.delete("ce05ae37-75ae-4b2c-b4e2-4384e5be0c73") mock_session.delete.assert_called_once() assert actual_result is True