def process_ticket_artifact(self, dict_ticket_artifact): id_ticket = dict_ticket_artifact["id_ticket"] logger.debug("search ticket %s" % id_ticket) row_ticket_board = self.get_ticket_board(id_ticket) # if ticket exists if row_ticket_board: user_request = dict_ticket_artifact["modification_user"] # update user_request with new value of the artifact's email row_ticket_board.user_request = user_request row_ticket_board.date_requested = time.time() else: user_request = dict_ticket_artifact["modification_user"] id_environment = self.get_ticket_environment(id_ticket=id_ticket) dict_ticket = {"id_ticket": id_ticket, "id_environment": id_environment, "user_request": user_request} print "creating ticket_board, id_environment, id_ticket, id_status, date_requested..." self.insert_ticket_board(dict_ticket) ticket_artifact_dao = TicketArtifactDao(self._controller_dao.get_dict_database()) ticket_artifact_logging = TicketArtifactLoggingDao(self._controller_dao.get_dict_database()) cat_artifact_dao = CatArtifactDao(self._controller_dao.get_dict_database()) ls_artifact = dict_ticket_artifact["artifacts"] dict_ticket_artifact["code_base"] = id_ticket for code_artifact in ls_artifact: id_artifact = cat_artifact_dao.get_id_artifact(code_artifact) ticket_artifact_dao.process_ticket_artifact(id_artifact, dict_ticket_artifact) ticket_artifact_logging.add(id_artifact, dict_ticket_artifact) board_ticket = self.get_dict_board_code(id_ticket) return {"result": "OK", "board_ticket": board_ticket}
def linking_tickets(self, dict_link_ticket): id_ticket_original = dict_link_ticket["id_ticket_original"] id_ticket_linked = dict_link_ticket["id_ticket_linked"] row_ticket_board = self.get_ticket_board(id_ticket_original) row_ticket_linked = self.get_ticket_board(id_ticket_linked) if not row_ticket_board: return {"result_code": "ERROR", "message": "original ticket doesn't exist!"} if row_ticket_linked: return {"result_code": "ERROR", "message": "linked ticket already exists"} else: rows_ticket_artifact = self.get_all_ticket_artifact(id_ticket_original) user_request = row_ticket_board.user_request id_environment = self.get_ticket_environment(id_ticket=id_ticket_linked) dict_ticket = {"id_ticket": id_ticket_linked, "id_environment": id_environment, "user_request": user_request} self.insert_ticket_board(dict_ticket) ticket_artifact_dao = TicketArtifactDao(self._controller_dao.get_dict_database()) # copy original ticket's artifacts to the new ticket for row in rows_ticket_artifact: dict_ticket_artifact = {"id_ticket": id_ticket_linked, "id_type_tech": row.id_type_tech, "modification_user": row.modification_user, "id_revision": row.id_revision, "build_release": row.build_release, "build_hotfix": row.build_hotfix, "code_base": row.code_base} ticket_artifact_dao.process_ticket_artifact(id_artifact=row.id_artifact, dict_artifact=dict_ticket_artifact) return {"result_code": "OK", "message": "success"}
def get_dict_board_code(self, id_ticket): ticket_board_dao = TicketBoardDao(self._controller_dao.get_dict_database()) ticket_artifact_dao = TicketArtifactDao(self._controller_dao.get_dict_database()) row_board_code = ticket_board_dao.get_ticket_code(id_ticket) rows = ticket_artifact_dao.get_ticket_artifact_code(id_ticket) list_artifact = [] for a_row in rows: list_artifact.append(json.dumps(a_row, cls=AlchemyEncoder)) return {"dict_board": json.dumps(row_board_code, cls=AlchemyEncoder), "artifacts": list_artifact}
def test_06(self): config_file = '../board.cfg' config = ConfigParser.RawConfigParser() config.read(config_file) connection_file = config.get('DatabaseSection', 'database.file') controller_dao = ControllerDao(connection_file) ticket_artifact_dao = TicketArtifactDao(controller_dao.get_dict_database()) rows = ticket_artifact_dao.get_ticket_artifact_code('noticket') print rows self.assertFalse(rows)
def test_06(self): config_file = '../board.cfg' config = ConfigParser.RawConfigParser() config.read(config_file) connection_file = config.get('DatabaseSection', 'database.file') controller_dao = ControllerDao(connection_file) ticket_artifact_dao = TicketArtifactDao( controller_dao.get_dict_database()) rows = ticket_artifact_dao.get_ticket_artifact_code('noticket') print rows self.assertFalse(rows)
def test_05(self): config_file = '../board.cfg' config = ConfigParser.RawConfigParser() config.read(config_file) connection_file = config.get('DatabaseSection', 'database.file') controller_dao = ControllerDao(connection_file) ticket_artifact_dao = TicketArtifactDao(controller_dao.get_dict_database()) rows = ticket_artifact_dao.get_ticket_artifact_code('feature2') for row in rows: print row.ticket_artifact.id_ticket self.assertIsNotNone(rows)
def test_08(self): config_file = '../board.cfg' config = ConfigParser.RawConfigParser() config.read(config_file) connection_file = config.get('DatabaseSection', 'database.file') controller_dao = ControllerDao(db_path = connection_file) ticket_artifact_dao = TicketArtifactDao(controller_dao.get_dict_database()) ticket_artifact = {'build_hotfix': 0, 'id_revision': 9, 'modification_user': '******', 'id_type_tech': 1, 'artifacts': ['cartridge-2'], 'id_ticket': 'feature1', 'build_release': 2} rows = ticket_artifact_dao.process_ticket_artifact(12, ticket_artifact) self.assertTrue(True)
def test_05(self): config_file = '../board.cfg' config = ConfigParser.RawConfigParser() config.read(config_file) connection_file = config.get('DatabaseSection', 'database.file') controller_dao = ControllerDao(connection_file) ticket_artifact_dao = TicketArtifactDao( controller_dao.get_dict_database()) rows = ticket_artifact_dao.get_ticket_artifact_code('feature2') for row in rows: print row.ticket_artifact.id_ticket self.assertIsNotNone(rows)
def process_ticket_db(self, dict_branch, id_branch_rep): list_board_ticket = [] try: for id_ticket in dict_branch: ls_artifact = dict_branch[id_ticket] if len(ls_artifact) > 0: logger.debug("search ticket %s" % id_ticket) row_ticket_board = self.get_ticket_board(id_ticket) # if ticket exists if row_ticket_board: # get first dict artifact first_artifact = ls_artifact[0] user_request = first_artifact["email"] # update user_request with new value of the artifact's email row_ticket_board.user_request = user_request row_ticket_board.date_requested = time.time() logger.info("update ticket_board.date_requested") # print "search ticket_artifact by id_artifact, type_tech" else: first_artifact = ls_artifact[0] user_request = first_artifact["email"] id_environment = self.get_ticket_environment(id_ticket=id_ticket, id_branch=id_branch_rep) dict_ticket = {"id_ticket": id_ticket, "id_environment": id_environment, "user_request": user_request} print "creating ticket_board, id_environment, id_ticket, id_status, date_requested..." self.insert_ticket_board(dict_ticket) ticket_artifact_dao = TicketArtifactDao(self._controller_dao.get_dict_database()) ticket_artifact_logging = TicketArtifactLoggingDao(self._controller_dao.get_dict_database()) for dict_artifact in ls_artifact: ticket_artifact_dao.process_ticket_artifact(id_ticket, dict_artifact) ticket_artifact_logging.add(id_ticket, dict_artifact) board_ticket = self.get_dict_board_code(id_ticket) list_board_ticket.append(board_ticket) self.do_commit() return {"result": "OK", "board_ticket": list_board_ticket} except lite.Error as e: logger.exception(e) self._controller_dao.do_rollback() return {"result": "ERROR", "description": e.message}
def test_08(self): config_file = '../board.cfg' config = ConfigParser.RawConfigParser() config.read(config_file) connection_file = config.get('DatabaseSection', 'database.file') controller_dao = ControllerDao(db_path=connection_file) ticket_artifact_dao = TicketArtifactDao( controller_dao.get_dict_database()) ticket_artifact = { 'build_hotfix': 0, 'id_revision': 9, 'modification_user': '******', 'id_type_tech': 1, 'artifacts': ['cartridge-2'], 'id_ticket': 'feature1', 'build_release': 2 } rows = ticket_artifact_dao.process_ticket_artifact(12, ticket_artifact) self.assertTrue(True)
def get_all_ticket_artifact(self, id_ticket): ticket_artifact_dao = TicketArtifactDao(self._controller_dao.get_dict_database()) return ticket_artifact_dao.get_all_ticket_artifact(id_ticket)
def get_ticket_artifact(self, id_ticket, id_artifact, type_tech): ticket_artifact_dao = TicketArtifactDao(self._controller_dao.get_dict_database()) row = ticket_artifact_dao.get_ticket_artifact(id_ticket, id_artifact, type_tech) return row