def test_execute(self, exec_command, check_output): task = gapic_tasks.GapicConfigGenTask() result = task.execute( api_name='pubsub', api_version='v1', descriptor_set='/path/to/descriptor_set', organization_name='google-cloud', output_dir='/path/to/output', service_yaml='/path/to/service.yaml', toolkit_path='/path/to/toolkit', ) assert result == '/'.join(( '/path/to/output/google-cloud-pubsub-v1-config-gen', 'google-cloud-pubsub-v1_gapic.yaml', )) expected_cmds = [ 'mkdir -p %s' % os.path.dirname(result), ' '.join([ 'java -cp', '/path/to/toolkit/build/libs/gapic-generator-latest-fatjar.jar', 'com.google.api.codegen.GeneratorMain', 'GAPIC_CONFIG', '--descriptor_set=/path/to/descriptor_set', '--output=/path/to/output/google-cloud-pubsub-v1-config-gen/google-cloud-pubsub-v1_gapic.yaml', '--service_yaml=/path/to/service.yaml', ]) ] assert_calls_equal(exec_command.mock_calls, expected_cmds) expected_cmds2 = [ '/path/to/toolkit/gradlew -p /path/to/toolkit fatJar -Pclargs=', ] assert_calls_equal(check_output.mock_calls, expected_cmds2)
def test_execute(self, exec_command): task = gapic_tasks.GapicConfigGenTask() result = task.execute( api_name='pubsub', api_version='v1', descriptor_set='/path/to/descriptor_set', organization_name='google-cloud', output_dir='/path/to/output', service_yaml=['/path/to/service.yaml'], toolkit_path='/path/to/toolkit', ) assert result == '/'.join(( '/path/to/output/google-cloud-pubsub-v1-config-gen', 'google-cloud-pubsub-v1_gapic.yaml', )) expected_cmds = ( 'mkdir -p %s' % os.path.dirname(result), ''.join(( '/path/to/toolkit/gradlew -p /path/to/toolkit runConfigGen ' '-Pclargs=--descriptor_set=/path/to/descriptor_set,', '--output=/path/to/output/google-cloud-pubsub-v1-config-gen/', 'google-cloud-pubsub-v1_gapic.yaml,--service_yaml=', '/path/to/service.yaml', )), ) for call, expected in zip(exec_command.mock_calls, expected_cmds): _, args, _ = call cmd = ' '.join(args[0]) assert cmd == expected
def test_validate(self): task = gapic_tasks.GapicConfigGenTask() assert task.validate() == [gapic_requirements.ConfigGenRequirements]