def test_grpc_codegen_python(self): gtf = gapic_generation.GapicTaskFactory() grpc_tf = grpc_generation.GRPC_TASK_FACTORY_DICT['python'] with mock.patch.object(grpc_tf, 'get_grpc_codegen_tasks') as get: tasks_ = gtf._get_grpc_codegen_tasks(language='python') assert tasks_ == get.return_value get.assert_called_once_with(language='python')
def test_validation(self, does_not_exist, does_exist): gtf = gapic_generation.GapicTaskFactory() gcpb = code_generation.CodeGenerationPipelineBase(gtf, language='python', publish='noop', ) does_exist.assert_called_once() does_not_exist.assert_called_once()
def test_do_build_flow_no_gapic(self): CGPB = code_generation.CodeGenerationPipelineBase with mock.patch.object(CGPB, 'validate_kwargs') as validate: cgpb = CGPB(gapic_generation.GapicTaskFactory(), language='python', aspect='ALL') validate.assert_called_once() flow = cgpb.do_build_flow(language='python', aspect='ALL') assert isinstance(flow, linear_flow.Flow) assert len(flow) == 7
def test_additional_remote_tasks(self): CGPB = code_generation.CodeGenerationPipelineBase with mock.patch.object(CGPB, 'validate_kwargs') as validate: cgpb = CGPB( gapic_generation.GapicTaskFactory(), language='python', publish='noop', ) validate.assert_called_once() remote_tasks = cgpb.additional_tasks_for_remote_execution() assert len(remote_tasks) == 3 # Check that we got the actual tasks that we expect. expected = ( io_tasks.PrepareUploadDirTask, io_tasks.BlobUploadTask, io_tasks.CleanupTempDirsTask, ) for task, class_ in zip(remote_tasks, expected): assert isinstance(task, class_)
def make_tasks(**kwargs): tf = gapic_generation.GapicTaskFactory() return tf.get_tasks(**kwargs)