def testRunTimeDone(self, getStubMock): startTime = 100 stopTime = 500 expected = stopTime - startTime runningFrame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, start_time=startTime, stop_time=stopTime)) self.assertEqual(runningFrame.runTime(), expected)
def testRunTimeRunning(self, getStubMock): curTime = int(time.time()) startTime = 100 expected = curTime - startTime runningFrame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, start_time=startTime, stop_time=0)) threshold = abs(runningFrame.runTime() - expected) self.assertTrue(threshold < 1)
def testCreateDependencyOnFrame(self, getStubMock): dependId = 'ddd-dddd-ddd' stubMock = mock.Mock() stubMock.CreateDependencyOnFrame.return_value = \ job_pb2.FrameCreateDependencyOnFrameResponse(depend=depend_pb2.Depend(id=dependId)) getStubMock.return_value = stubMock dependFrameName = 'frameDependTest' frame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME)) dependOnFrame = job_pb2.Frame(name=dependFrameName) depend = frame.createDependencyOnFrame(dependOnFrame) stubMock.CreateDependencyOnFrame.assert_called_with( job_pb2.FrameCreateDependencyOnFrameRequest( frame=frame.data, depend_on_frame=dependOnFrame), timeout=mock.ANY) self.assertEqual(depend.id(), dependId)
def testGetFrames(self, getStubMock): frameNames = ['testFrameA', 'testFrameB'] stubMock = mock.Mock() stubMock.GetFrames.return_value = job_pb2.JobGetFramesResponse( frames=job_pb2.FrameSeq(frames=[job_pb2.Frame(name=frameNames[0]), job_pb2.Frame(name=frameNames[1])])) getStubMock.return_value = stubMock frameRange = '1-10' criteria = opencue.search.FrameSearch.criteriaFromOptions(range=frameRange) job = opencue.wrappers.job.Job( job_pb2.Job(name=TEST_JOB_NAME)) frames = job.getFrames(range=frameRange) stubMock.GetFrames.assert_called_with( job_pb2.JobGetFramesRequest(job=job.data, req=criteria), timeout=mock.ANY) self.assertTrue(len(frames), 2) self.assertTrue(frames[0].name(), frameNames[0]) self.assertTrue(frames[1].name(), frameNames[1])
def testRetry(self, getStubMock): stubMock = mock.Mock() stubMock.Retry.return_value = job_pb2.FrameRetryResponse() getStubMock.return_value = stubMock frame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING)) frame.retry() stubMock.Retry.assert_called_with( job_pb2.FrameRetryRequest(frame=frame.data), timeout=mock.ANY)
def testEat(self, getStubMock): stubMock = mock.Mock() stubMock.Eat.return_value = job_pb2.FrameEatResponse() getStubMock.return_value = stubMock frame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.WAITING)) frame.eat() stubMock.Eat.assert_called_with( job_pb2.FrameEatRequest(frame=frame.data), timeout=mock.ANY)
def testGetFrame(self, getStubMock): arbitraryId = '00000000-0000-0000-0000-012345678980' stubMock = mock.Mock() stubMock.GetFrame.return_value = job_pb2.FrameGetFrameResponse( frame=job_pb2.Frame(id=arbitraryId)) getStubMock.return_value = stubMock frame = opencue.api.getFrame(arbitraryId) stubMock.GetFrame.assert_called_with( job_pb2.FrameGetFrameRequest(id=arbitraryId), timeout=mock.ANY) self.assertEqual(arbitraryId, frame.id())
def testGetFrame(self, getStubMock): stubMock = mock.Mock() stubMock.GetFrame.return_value = host_pb2.ProcGetFrameResponse( frame=job_pb2.Frame(layer_name=TEST_LAYER_NAME)) getStubMock.return_value = stubMock proc = opencue.wrappers.proc.Proc(host_pb2.Proc(name=TEST_PROC_NAME)) frame = proc.getFrame() stubMock.GetFrame.assert_called_with( host_pb2.ProcGetFrameRequest(proc=proc.data), timeout=mock.ANY) self.assertEqual(frame.layer(), TEST_LAYER_NAME)
def testGetFrames(self, getStubMock): stubMock = mock.Mock() stubMock.GetFrames.return_value = job_pb2.FrameGetFramesResponse( frames=job_pb2.FrameSeq(frames=[ job_pb2.Frame(layer_name=TEST_LAYER_NAME, number=1), job_pb2.Frame(layer_name=TEST_LAYER_NAME, number=2), job_pb2.Frame(layer_name=TEST_LAYER_NAME, number=3), job_pb2.Frame(layer_name=TEST_LAYER_NAME, number=4), job_pb2.Frame(layer_name=TEST_LAYER_NAME, number=5), ])) getStubMock.return_value = stubMock frames = opencue.api.getFrames(TEST_JOB_NAME, range="1-5") stubMock.GetFrames.assert_called_with( job_pb2.FrameGetFramesRequest( job=TEST_JOB_NAME, r=job_pb2.FrameSearchCriteria( frame_range="1-5", page=1, limit=1000)), timeout=mock.ANY) self.assertEqual(5, len(frames)) self.assertTrue(all((frame.layer() == TEST_LAYER_NAME for frame in frames))) self.assertEqual([1, 2, 3, 4, 5], [frame.number() for frame in frames])
def testFindFrame(self, getStubMock): frameNum = 4 stubMock = mock.Mock() stubMock.FindFrame.return_value = job_pb2.FrameFindFrameResponse( frame=job_pb2.Frame(layer_name=TEST_LAYER_NAME, number=frameNum)) getStubMock.return_value = stubMock frame = opencue.api.findFrame(TEST_JOB_NAME, TEST_LAYER_NAME, frameNum) stubMock.FindFrame.assert_called_with( job_pb2.FrameFindFrameRequest(job=TEST_JOB_NAME, layer=TEST_LAYER_NAME, frame=frameNum), timeout=mock.ANY) self.assertEqual(TEST_LAYER_NAME, frame.layer()) self.assertEqual(frameNum, frame.number())
def testGetWhatThisDependsOn(self, getStubMock): dependId = 'ddd-dddd-ddd' stubMock = mock.Mock() stubMock.GetWhatThisDependsOn.return_value = job_pb2.FrameGetWhatThisDependsOnResponse( depends=depend_pb2.DependSeq(depends=[depend_pb2.Depend(id=dependId)])) getStubMock.return_value = stubMock frame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING)) depends = frame.getWhatThisDependsOn() stubMock.GetWhatThisDependsOn.assert_called_with( job_pb2.FrameGetWhatThisDependsOnRequest(frame=frame.data), timeout=mock.ANY) self.assertEqual(len(depends), 1) self.assertEqual(depends[0].id(), dependId)
def testCreateDependencyOnFrame(self, getStubMock): dependId = 'ddd-dddd-ddd' dependFrame = 'testFrame' stubMock = mock.Mock() stubMock.CreateDependencyOnFrame.return_value = job_pb2.JobCreateDependencyOnFrameResponse( depend=depend_pb2.Depend(id=dependId)) getStubMock.return_value = stubMock onFrame = job_pb2.Frame(name=dependFrame) job = opencue.wrappers.job.Job( job_pb2.Job(name=TEST_JOB_NAME)) depend = job.createDependencyOnFrame(onFrame) stubMock.CreateDependencyOnFrame.assert_called_with( job_pb2.JobCreateDependencyOnFrameRequest(job=job.data, frame=onFrame), timeout=mock.ANY) self.assertEqual(depend.id(), dependId)
def testGetFrames(self, getStubMock): stubMock = mock.Mock() stubMock.GetFrames.return_value = job_pb2.LayerGetFramesResponse( frames=job_pb2.FrameSeq( frames=[job_pb2.Frame(layer_name=TEST_LAYER_NAME)])) getStubMock.return_value = stubMock layer = opencue.wrappers.layer.Layer( job_pb2.Layer(name=TEST_LAYER_NAME)) frames = layer.getFrames() stubMock.GetFrames.assert_called_with(job_pb2.LayerGetFramesRequest( layer=layer.data, s=opencue.search.FrameSearch.criteriaFromOptions()), timeout=mock.ANY) self.assertEqual(len(frames), 1) self.assertEqual(frames[0].data.layer_name, TEST_LAYER_NAME)
def testCreateDependencyOnFrame(self, getStubMock): dependId = 'dddd-ddd-dddd' frameId = 'ffff-fff-ffff' stubMock = mock.Mock() stubMock.CreateDependOnFrame.return_value = job_pb2.LayerCreateDependOnFrameResponse( depend=depend_pb2.Depend(id=dependId)) getStubMock.return_value = stubMock layer = opencue.wrappers.layer.Layer( job_pb2.Layer(name=TEST_LAYER_NAME)) frame = job_pb2.Frame(id=frameId) depend = layer.createDependencyOnFrame(frame) stubMock.CreateDependOnFrame.assert_called_with( job_pb2.LayerCreateDependOnFrameRequest(layer=layer.data, frame=frame), timeout=mock.ANY) self.assertEqual(depend.id(), dependId)
def testCreateDependencyOnLayer(self, getStubMock): dependId = 'ddd-dddd-ddd' stubMock = mock.Mock() stubMock.CreateDependencyOnLayer.return_value = \ job_pb2.FrameCreateDependencyOnLayerResponse(depend=depend_pb2.Depend(id=dependId)) getStubMock.return_value = stubMock dependLayerName = 'layerDependTest' frame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING)) dependOnLayer = job_pb2.Layer(name=dependLayerName) depend = frame.createDependencyOnLayer(dependOnLayer) stubMock.CreateDependencyOnLayer.assert_called_with( job_pb2.FrameCreateDependencyOnLayerRequest(frame=frame.data, layer=dependOnLayer), timeout=mock.ANY) self.assertEqual(depend.id(), dependId)
def testCreateDependencyOnJob(self, getStubMock): dependId = 'ddd-dddd-ddd' stubMock = mock.Mock() stubMock.CreateDependencyOnJob.return_value = \ job_pb2.FrameCreateDependencyOnJobResponse(depend=depend_pb2.Depend(id=dependId)) getStubMock.return_value = stubMock dependJobName = 'jobDependTest' frame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, state=job_pb2.RUNNING)) dependOnJob = opencue.wrappers.job.Job(job_pb2.Job(name=dependJobName)) depend = frame.createDependencyOnJob(dependOnJob) stubMock.CreateDependencyOnJob.assert_called_with( job_pb2.FrameCreateDependencyOnJobRequest(frame=frame.data, job=dependOnJob.data), timeout=mock.ANY) self.assertEqual(depend.id(), dependId)
def testRunTimeZero(self, getStubMock): zeroFrame = opencue.wrappers.frame.Frame( job_pb2.Frame(name=TEST_FRAME_NAME, start_time=0, stop_time=1000)) self.assertEqual(zeroFrame.runTime(), 0)