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 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 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])