def test_execute(self, exec_command, check_output): task = gapic_tasks.DiscoGapicCodeGenTask() task.execute(api_name='compute', api_version='v1', gapic_yaml='/path/to/compute.yaml', gapic_code_dir='/path/to/output', language='java', organization_name='google-cloud', package_metadata_yaml='/path/to/pmy.yaml', discovery_doc="compute.v1.json", toolkit_path='/path/to/toolkit', root_dir='root_dir') expected_cmds = [ ' '.join([ 'java -cp', '/path/to/toolkit/build/libs/gapic-generator-latest-fatjar.jar', 'com.google.api.codegen.GeneratorMain LEGACY_DISCOGAPIC_AND_PACKAGE', '--discovery_doc=root_dir/compute.v1.json', '--package_yaml2=/path/to/pmy.yaml --output=/path/to/output', '--language=java --gapic_yaml=/path/to/compute.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.DiscoGapicCodeGenTask() task.execute(api_name='compute', api_version='v1', gapic_api_yaml='compute.yaml', gapic_code_dir='api-client-staging/generated/java', discogapic_language_yaml='java.yaml', language='java', organization_name='google-cloud', package_metadata_yaml='pmy.yaml', discovery_doc="compute.v1.json", toolkit_path='/path/to/toolkit') expected_cmds = ( '/path/to/toolkit/gradlew -p /path/to/toolkit runDiscoCodeGen', ) for call, expected in zip(exec_command.mock_calls, expected_cmds): _, args, _ = call assert expected in ' '.join(args[0])
def test_validate(self): task = gapic_tasks.DiscoGapicCodeGenTask() assert task.validate() == [gapic_requirements.GapicRequirements]