def delete_organization(task_id, organization_id): pm_logger = common_utils.begin_logger(task_id, __name__, inspect.currentframe()) # get list project with key organization_id try: list_projects = pm_projects.query_organization_index( task_id, organization_id) except PmError as e: pm_logger.error("プロジェクト情報取得に失敗しました。: OrganizationID=%s", organization_id) pm_logger.error(e) return False for project_item in list_projects: project_id = project_item["ProjectID"] status_delete_project = projectsBatch_logic.delete_project( task_id, project_id) if status_delete_project is False: return False # delete project try: pm_projects.delete_projects(task_id, project_id) except PmError as e: pm_logger.error("プロジェクト情報削除に失敗しました。: ProjectID=%s", project_id) pm_logger.error(e) return False return True
def tearDown(self): num = 1 while num < 4: pm_affiliation.delete_affiliation(user_id.format(str(num)), organization_id) num += 1 pm_projects.delete_projects(trace_id, project_id) pm_organizations.delete_organization(trace_id, organization_id) pm_awsAccountCoops.delete_awscoops(trace_id, awscoops_template["CoopID"]) pm_awsAccountCoops.delete_awscoops(trace_id, coop_id.format(str(999))) pm_awsAccountCoops.delete_awscoops(trace_id, coop_id_members_enable)
def tearDown(self): num = 1 while num < 7: pm_organizationTasks.delete(trace_id, task_id.format(str(num))) pm_reports.delete_reports(trace_id, report_id.format(str(num))) num += 1 pm_organizationTasks.delete(trace_id, task_id.format(str(7))) pm_organizationTasks.delete(trace_id, task_id.format(str(8))) pm_awsAccountCoops.delete_awscoops(trace_id, coop_id.format(str(1))) pm_projects.delete_projects(trace_id, project_id) pm_projects.delete_projects(trace_id, project_id_error.format(str(1))) pm_organizations.delete_organization(trace_id, organization_id) pm_organizations.delete_organization( trace_id, organization_id_error.format(str(1)))
def delete_project(trace_id, email, project_id, organization_id): # Get logging pm_logger = common_utils.begin_logger(trace_id, __name__, inspect.currentframe()) try: project = pm_projects.get_projects_by_organization_id( trace_id, project_id, organization_id, convert_response=True) except PmError as e: return common_utils.error_exception(MsgConst.ERR_402, HTTPStatus.INTERNAL_SERVER_ERROR, e, pm_logger, True) # 組織情報を取得します。 if (not project): return common_utils.error_common(MsgConst.ERR_301, HTTPStatus.NOT_FOUND, pm_logger) # プロジェクト削除の条件を満たしているかチェックを行います。現時点ではチェックすべき項目はありません。 # 現時点ではチェックすべき項目はありません。 # Delete project try: pm_projects.delete_projects(trace_id, project_id) except PmError as e: return common_utils.error_exception(MsgConst.ERR_DB_405, HTTPStatus.INTERNAL_SERVER_ERROR, e, pm_logger, True) # Create task task_id = str(uuid.uuid4()) user_id = trace_id try: pm_organizationTasks.create_organizationTask(trace_id, task_id, "DELETE_PRJ", project_id, user_id, email, Status.Waiting.value, 0, 3) except PmError as e: return common_utils.error_exception(MsgConst.ERR_DB_403, HTTPStatus.INTERNAL_SERVER_ERROR, e, pm_logger, True) aws_common.sns_organization_topic(trace_id, task_id, "DELETE_PRJ") # data response response = common_utils.get_response_by_response_body( HTTPStatus.NO_CONTENT, None) return common_utils.response(response, pm_logger)
def tearDown(self): num = 1 while num < 4: pm_affiliation.delete_affiliation(user_id.format(str(num)), organization_id) pm_reports.delete_reports(trace_id, report_id.format(str(num))) num += 1 pm_projects.delete_projects(trace_id, project_id) pm_organizations.delete_organization(trace_id, organization_id) # Delete ReportJobDefs pm_batchJobDefs.delete_report_job_def(trace_id, code_aws) pm_batchJobDefs.delete_report_job_def(trace_id, code_json) pm_batchJobDefs.delete_report_job_def(trace_id, code_excel) pm_reports.delete_reports(trace_id, report_id.format(str(4))) pm_reports.delete_reports(trace_id, report_id.format(str(5))) pm_reports.delete_reports(trace_id, report_id.format(str(6)))
def test_create_project_success(self): test_user_id = affiliation_template_user_id.format(str(1)) test_organization_id = project_organization_id_template.format(str(1)) date_now = common_utils.get_current_date() # handler path_parameters = {"organization_id": test_organization_id} project_create[ "organization_id"] = project_organization_id_template.format( str(1)) event = event_create.get_event_object( trace_id=test_user_id, path_parameters=path_parameters, body=json.dumps(project_create)) response = projects.create_project_handler(event, {}) # Get data response response_body = json.loads(response['body']) id = response_body['id'] name = response_body['name'] description = response_body['description'] organization_id = response_body['organizationId'] created_at = response_body['createdAt'] updated_at = response_body['updatedAt'] status_code = response['statusCode'] # Check data response self.assertEqual(name, project_create['name']) self.assertEqual(description, project_create['description']) self.assertEqual(organization_id, project_create['organization_id']) self.assertGreaterEqual(created_at, date_now) self.assertGreaterEqual(updated_at, date_now) self.assertEqual(status_code, HTTPStatus.CREATED.value) # Check data organization in database project_database = pm_projects.get_projects( test_user_id, id, convert_response=True)[0] self.assertEqual(name, project_database['name']) self.assertEqual(description, project_database['description']) self.assertEqual(organization_id, project_database['organizationId']) self.assertGreaterEqual(project_database['createdAt'], date_now) self.assertGreaterEqual(project_database['updatedAt'], date_now) pm_projects.delete_projects(test_user_id, id)
def tearDown(self): num = 0 while num < 2: # Get data user_id delete and organization_id delete user_id = affiliation_template['UserID'].format(str(num)) organization_id = template_organization_id.format( str(num)) # Delete data table Organization and Affiliation pm_affiliation.delete_affiliation(user_id, organization_id) pm_organizations.delete_organization(trace_id, organization_id) pm_projects.delete_projects( trace_id, projects_id_template.format(str(num))) num += 1 # remove data test function delete organaization while num < 4: delete_user_id = affiliation_template['UserID'].format(str(num)) pm_affiliation.delete_affiliation( user_id=delete_user_id, organization_id=template_organization_id.format(str(num))) num += 1 num = 0 while num < 4: delete_user_id = affiliation_template['UserID'].format(str(num)) pm_organizations.delete_organization( trace_id, organization_id=template_organization_id.format(str(num))) num += 1 num = 0 while num < 4: delete_project_id = projects_template['ProjectID'].format(str(num)) pm_projects.delete_projects(trace_id, delete_project_id) num += 1