def _getImportDataForJobID(self, job_id): job = self._getJob(job_id) arguments = CodeImportSourceDetails.fromCodeImport( job.code_import).asArguments() branch = job.code_import.branch branch_url = canonical_url(branch) log_file_name = '%s.log' % branch.unique_name[1:].replace('/', '-') return (arguments, branch_url, log_file_name)
def test_getImportDataForJobID(self): # getImportDataForJobID returns the worker arguments, branch url and # log file name for an import corresponding to a particular job. code_import_job = self.makeCodeImportJob(running=True) code_import = removeSecurityProxy(code_import_job).code_import code_import_arguments, branch_url, log_file_name = self.api.getImportDataForJobID(code_import_job.id) import_as_arguments = CodeImportSourceDetails.fromCodeImport(code_import).asArguments() expected_log_file_name = "%s.log" % (code_import.branch.unique_name[1:].replace("/", "-")) self.assertEqual( (import_as_arguments, canonical_url(code_import.branch), expected_log_file_name), (code_import_arguments, branch_url, log_file_name), )
def test_getImportDataForJobID(self): # getImportDataForJobID returns the worker arguments, branch url and # log file name for an import corresponding to a particular job. code_import_job = self.makeCodeImportJob(running=True) code_import = removeSecurityProxy(code_import_job).code_import code_import_arguments, branch_url, log_file_name = \ self.api.getImportDataForJobID(code_import_job.id) import_as_arguments = CodeImportSourceDetails.fromCodeImport( code_import).asArguments() expected_log_file_name = '%s.log' % ( code_import.branch.unique_name[1:].replace('/', '-')) self.assertEqual((import_as_arguments, canonical_url( code_import.branch), expected_log_file_name), (code_import_arguments, branch_url, log_file_name))
def getStartedJobForImport(self, code_import): """Get a started `CodeImportJob` for `code_import`. This method approves the import, creates a job, marks it started and returns the job. It also makes sure there are no branches or foreign trees in the default stores to interfere with processing this job. """ source_details = CodeImportSourceDetails.fromCodeImport(code_import) clean_up_default_stores_for_import(source_details) self.addCleanup(clean_up_default_stores_for_import, source_details) if code_import.review_status != CodeImportReviewStatus.REVIEWED: code_import.updateFromData( {'review_status': CodeImportReviewStatus.REVIEWED}, self.factory.makePerson()) job = getUtility(ICodeImportJobSet).getJobForMachine('machine', 10) self.assertEqual(code_import, job.code_import) return job
def getStartedJobForImport(self, code_import): """Get a started `CodeImportJob` for `code_import`. This method approves the import, creates a job, marks it started and returns the job. It also makes sure there are no branches or foreign trees in the default stores to interfere with processing this job. """ source_details = CodeImportSourceDetails.fromCodeImport(code_import) clean_up_default_stores_for_import(source_details) self.addCleanup(clean_up_default_stores_for_import, source_details) if code_import.review_status != CodeImportReviewStatus.REVIEWED: code_import.updateFromData( {'review_status': CodeImportReviewStatus.REVIEWED}, self.factory.makePerson()) job = getUtility(ICodeImportJobSet).getJobForMachine('machine', 10) self.assertEqual(code_import, job.code_import) return job