Example #1
0
    def test_execute_with_grpc_explicit_src(self, uuid4, chdir, exec_command):
        uuid4.return_value = uuid.UUID('00000000-0000-0000-0000-000000000000')

        # Run the task.
        task = github.CreateGitHubBranch()
        branch_name = task.execute(
            api_name='pubsub',
            api_version='v1',
            gapic_code_dir='/path/to/code',
            grpc_code_dir='/path/to/grpc_code',
            git_repo={
                'location':
                '[email protected]:me/repo.git',
                'paths': [{
                    'src': 'gapic',
                    'dest': 'generated/python/gapic-pubsub-v1',
                }, {
                    'artifact': 'grpc',
                    'src': 'proto',
                    'dest': 'generated/python/proto-pubsub-v1',
                }],
            },
            github={
                'username': '******',
                'token': 'TOKEN',
            },
            language='python',
            output_dir='/path/to',
        )

        # List the commands that should have been executed.
        expected_commands = (
            'git clone https://test:[email protected]/me/repo.git /tmp/00000000',
            'git checkout -b pubsub-python-v1-00000000',
            ' '.join([
                'git rm -r --force --ignore-unmatch',
                'generated/python/gapic-pubsub-v1',
            ]),
            'cp -rf /path/to/code/gapic generated/python/gapic-pubsub-v1',
            'git add generated/python/gapic-pubsub-v1',
            ' '.join([
                'git rm -r --force --ignore-unmatch',
                'generated/python/proto-pubsub-v1',
            ]),
            'cp -rf /path/to/grpc_code/proto generated/python/proto-pubsub-v1',
            'git add generated/python/proto-pubsub-v1',
            'git commit --allow-empty -m Python GAPIC: Pubsub v1',
            'git push origin pubsub-python-v1-00000000',
            'rm -rf /path/to',
            'rm -rf /tmp/00000000',
        )

        # Now prove that they were.
        assert exec_command.call_count == len(expected_commands)
        for cmd, exec_call in zip(expected_commands, exec_command.mock_calls):
            _, args, _ = exec_call
            assert ' '.join(args[0]) == cmd
Example #2
0
    def test_execute_with_non_master_base(self, uuid4, chdir, exec_command):
        uuid4.return_value = uuid.UUID('00000000-0000-0000-0000-000000000000')

        # Run the task.
        task = github.CreateGitHubBranch()
        branch_name = task.execute(
            api_name='pubsub',
            api_version='v1',
            gapic_code_dir='/path/to/code',
            git_repo={
                'location': '[email protected]:me/repo.git',
                'branch': 'pubsub',
                'paths': ['generated/ruby/gapic-google-cloud-pubsub-v1'],
            },
            github={
                'username': '******',
                'token': 'TOKEN',
            },
            language='ruby',
            output_dir='/path/to',
        )

        # List the commands that should have been executed.
        expected_commands = (
            'git clone https://test:[email protected]/me/repo.git /tmp/00000000',
            'git checkout --track -b pubsub origin/pubsub',
            'git checkout -b pubsub-ruby-v1-00000000',
            ' '.join([
                'git rm -r --force --ignore-unmatch',
                'generated/ruby/gapic-google-cloud-pubsub-v1',
            ]),
            'cp -rf /path/to/code generated/ruby/gapic-google-cloud-pubsub-v1',
            'git add generated/ruby/gapic-google-cloud-pubsub-v1',
            'git commit --allow-empty -m Ruby GAPIC: Pubsub v1',
            'git push origin pubsub-ruby-v1-00000000',
            'rm -rf /path/to',
            'rm -rf /tmp/00000000',
        )

        # Now prove that they were.
        assert exec_command.call_count == len(expected_commands)
        for cmd, exec_call in zip(expected_commands, exec_command.mock_calls):
            _, args, _ = exec_call
            assert ' '.join(args[0]) == cmd