# Path: artman/tasks/gapic_tasks.py
# class GapicConfigGenTask(task_base.TaskBase):
# class DiscoGapicConfigGenTask(task_base.TaskBase):
# class GapicConfigMoveTask(task_base.TaskBase):
# class GapicCodeGenTask(task_base.TaskBase):
# class DiscoGapicCodeGenTask(task_base.TaskBase):
# class CSharpGapicPackagingTask(task_base.TaskBase):
#     def execute(self, toolkit_path, descriptor_set, service_yaml,
#                 output_dir, api_name, api_version, organization_name):
#     def execute(self, toolkit_path, discovery_doc,
#         output_dir, api_name, api_version, organization_name):
#     def _move_to(self, gapic_config_path, gapic_yaml):
#     def execute(self, gapic_config_path, gapic_yaml):
#     def validate(self):
#     def execute(self, language, toolkit_path, descriptor_set, service_yaml,
#                 gapic_yaml, package_metadata_yaml, proto_package,
#                 gapic_code_dir, api_name, api_version, organization_name,
#                 aspect, samples, generator_args, grpc_service_config=''):
#     def _get_sample_yamls(self, path):
#     def execute(self, language, toolkit_path, discovery_doc,
#         gapic_yaml, package_metadata_yaml,
#         gapic_code_dir, api_name, api_version, organization_name, root_dir):
#     def execute(self, gapic_code_dir, grpc_code_dir, proto_code_dir, gapic_yaml):


import os
import subprocess
import unittest
import mock
import pytest
from artman.tasks import gapic_tasks
            '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',
                      'DISCOGAPIC_CONFIG',
                      '--discovery_doc=/path/to/discovery_doc.json',
                      '--output=/path/to/output/google-cloud-compute-v1-config-gen/google-cloud-compute-v1_gapic.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)


class GapicConfigMoveTaskTests(unittest.TestCase):
    @mock.patch.object(gapic_tasks.GapicConfigMoveTask, 'exec_command')
    def test_execute(self, exec_command):
        task = gapic_tasks.GapicConfigMoveTask()
        task.execute('/path/src', '/path/dest')
        assert exec_command.call_count == 2
        expected_cmds = [
            'mkdir -p /path',
            'cp /path/src /path/dest',
        ]
        assert_calls_equal(exec_command.mock_calls, expected_cmds)

    @mock.patch.object(gapic_tasks.GapicConfigMoveTask, 'exec_command')
    def test_execute_no_dest(self, exec_command):

# Path: artman/tasks/gapic_tasks.py
# class GapicConfigGenTask(task_base.TaskBase):
# class DiscoGapicConfigGenTask(task_base.TaskBase):
# class GapicConfigMoveTask(task_base.TaskBase):
# class GapicCodeGenTask(task_base.TaskBase):
# class DiscoGapicCodeGenTask(task_base.TaskBase):
# class CSharpGapicPackagingTask(task_base.TaskBase):
#     def execute(self, toolkit_path, descriptor_set, service_yaml,
#                 output_dir, api_name, api_version, organization_name):
#     def execute(self, toolkit_path, discovery_doc,
#         output_dir, api_name, api_version, organization_name):
#     def _move_to(self, gapic_config_path, gapic_yaml):
#     def execute(self, gapic_config_path, gapic_yaml):
#     def validate(self):
#     def execute(self, language, toolkit_path, descriptor_set, service_yaml,
#                 gapic_yaml, package_metadata_yaml, proto_package,
#                 gapic_code_dir, api_name, api_version, organization_name,
#                 aspect, samples, generator_args, grpc_service_config=''):
#     def _get_sample_yamls(self, path):
#     def execute(self, language, toolkit_path, discovery_doc,
#         gapic_yaml, package_metadata_yaml,
#         gapic_code_dir, api_name, api_version, organization_name, root_dir):
#     def execute(self, gapic_code_dir, grpc_code_dir, proto_code_dir, gapic_yaml):


# Path: test/tasks/test_gapic.py
import os
import subprocess
import unittest
import mock
import pytest
from artman.tasks import gapic_tasks

            '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',
                      'DISCOGAPIC_CONFIG',
                      '--discovery_doc=/path/to/discovery_doc.json',
                      '--output=/path/to/output/google-cloud-compute-v1-config-gen/google-cloud-compute-v1_gapic.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)


class GapicConfigMoveTaskTests(unittest.TestCase):
    @mock.patch.object(gapic_tasks.GapicConfigMoveTask, 'exec_command')
    def test_execute(self, exec_command):
        task = gapic_tasks.GapicConfigMoveTask()
        task.execute('/path/src', '/path/dest')
        assert exec_command.call_count == 2
        expected_cmds = [
            'mkdir -p /path',
            'cp /path/src /path/dest',
        ]
        assert_calls_equal(exec_command.mock_calls, expected_cmds)

    @mock.patch.object(gapic_tasks.GapicConfigMoveTask, 'exec_command')
    def test_execute_no_dest(self, exec_command):

        task = gapic_tasks.GapicConfigMoveTask()