def reparentJobs(self, jobs): """Moves the given jobs into this group @type jobs: list<Job> @param jobs: The jobs to add to this group""" jobSeq = job_pb2.JobSeq(jobs=[job.data for job in jobs]) self.stub.ReparentJobs(job_pb2.GroupReparentJobsRequest( group=self.data, jobs=jobSeq), timeout=Cuebot.Timeout)
def reparentJobs(self, jobs): """Moves the given jobs into this group @type jobs: list<opencue.wrappers.job.Job> @param jobs: The jobs to add to this group""" jobsToReparent = [] for job in jobs: if isinstance(job, opencue.wrappers.job.NestedJob): job = job.asJob() jobsToReparent.append(job.data) jobSeq = job_pb2.JobSeq(jobs=jobsToReparent) self.stub.ReparentJobs(job_pb2.GroupReparentJobsRequest(group=self.data, jobs=jobSeq), timeout=Cuebot.Timeout)
def testReparentJobs(self, getStubMock): stubMock = mock.Mock() stubMock.ReparentJobs.return_value = job_pb2.GroupReparentJobsResponse() getStubMock.return_value = stubMock testJob = job_pb2.Job(name='testJob') testNestedJob = job_pb2.NestedJob(name='testNestedJob') jobs = [opencue.wrappers.job.Job(testJob), opencue.wrappers.job.NestedJob(testNestedJob)] group = opencue.wrappers.group.Group( job_pb2.Group(name=TEST_GROUP_NAME)) group.reparentJobs(jobs) expected = job_pb2.JobSeq(jobs=[job_pb2.Job(name='testJob'), job_pb2.Job(name='testNestedJob', job_stats=job_pb2.JobStats())]) stubMock.ReparentJobs.assert_called_with( job_pb2.GroupReparentJobsRequest(group=group.data, jobs=expected), timeout=mock.ANY)