コード例 #1
0
ファイル: test_apps.py プロジェクト: naphatkrit/TigerHost
def test_create_app_in_repo(runner, make_git_repo, saved_user, fake_api_client):
    app = 'app1'
    fake_api_client.get_application_git_remote.return_value = 'remote'
    result = runner.invoke(entry, ['create', app])
    assert result.exit_code == 0
    assert app in result.output
    fake_api_client.create_application.assert_called_once_with(app, None)
    git = GitVcs()
    assert git.get_remotes()['tigerhost'] == 'remote'
コード例 #2
0
ファイル: test_apps.py プロジェクト: naphatkrit/TigerHost
def test_create_app_in_repo_failed_connection(runner, make_git_repo, saved_user, fake_api_client):
    app = 'app1'
    fake_api_client.get_application_git_remote.side_effect = ApiClientResponseError(
        None)
    result = runner.invoke(entry, ['create', app])
    assert result.exit_code == 0
    assert app in result.output
    fake_api_client.create_application.assert_called_once_with(app, None)
    git = GitVcs()
    assert 'tigerhost' not in git.get_remotes()
コード例 #3
0
ファイル: test_apps.py プロジェクト: naphatkrit/TigerHost
def test_create_app_in_repo(runner, make_git_repo, saved_user,
                            fake_api_client):
    app = 'app1'
    fake_api_client.get_application_git_remote.return_value = 'remote'
    result = runner.invoke(entry, ['create', app])
    assert result.exit_code == 0
    assert app in result.output
    fake_api_client.create_application.assert_called_once_with(app, None)
    git = GitVcs()
    assert git.get_remotes()['tigerhost'] == 'remote'
コード例 #4
0
ファイル: test_apps.py プロジェクト: naphatkrit/TigerHost
def test_create_app_in_repo_failed_connection(runner, make_git_repo,
                                              saved_user, fake_api_client):
    app = 'app1'
    fake_api_client.get_application_git_remote.side_effect = ApiClientResponseError(
        None)
    result = runner.invoke(entry, ['create', app])
    assert result.exit_code == 0
    assert app in result.output
    fake_api_client.create_application.assert_called_once_with(app, None)
    git = GitVcs()
    assert 'tigerhost' not in git.get_remotes()
コード例 #5
0
def secret_clone(remote_url, force):
    """Clone a repo from the remote URL as the secret directory.
    """
    path = secret_dir.secret_dir_path()
    if os.path.exists(path):
        if not force:
            click.echo(
                'Secret directory at {} already exists. This may mean that you have already deployed an instance of TigerHost.'.format(path))
            click.confirm(
                'Remove existing secret directory? You will no longer be able to manage any previously deployed instances of TigerHost.', default=False, abort=True)
        shutil.rmtree(path)
    GitVcs.clone(remote_url, path)
コード例 #6
0
ファイル: test_git.py プロジェクト: naphatkrit/TigerHost
def test_git_remotes(runner, make_app, app_id):
    """
    @type runner: click.testing.CliRunner
    """
    remote = 'tigerhost2'
    result = runner.invoke(entry, ['git:remote', '--app', app_id, '--remote', remote])
    assert result.exit_code == 0
    assert remote in result.output

    git = GitVcs()
    remotes = git.get_remotes()
    assert remotes[remote] == remotes['tigerhost']
コード例 #7
0
def test_git_remotes(runner, make_app, app_id):
    """
    @type runner: click.testing.CliRunner
    """
    remote = 'tigerhost2'
    result = runner.invoke(entry,
                           ['git:remote', '--app', app_id, '--remote', remote])
    assert result.exit_code == 0
    assert remote in result.output

    git = GitVcs()
    remotes = git.get_remotes()
    assert remotes[remote] == remotes['tigerhost']
コード例 #8
0
ファイル: test_git.py プロジェクト: naphatkrit/TigerHost
def git(repo_path, request):
    assert not os.system(
        'cd {path} && git init'.format(path=repo_path))
    for commit in request.param:
        assert not os.system(
            'cd {p} && touch {c} && git add {c} && git commit -m {c}'.format(p=repo_path, c=commit))
    return GitVcs(path=repo_path)
コード例 #9
0
def test_with_git(runner, make_git_repo, command):
    result = runner.invoke(command)
    assert result.exit_code == 2

    result = runner.invoke(command, ['--app', 'a-1'])
    assert result.exit_code == 0
    assert 'a-1' in result.output

    git = GitVcs()
    git.add_remote('tigerhost', 'a-2')

    result = runner.invoke(command)
    assert result.exit_code == 0
    assert 'a-2' in result.output

    result = runner.invoke(command, ['--app', 'a-1'])
    assert result.exit_code == 0
    assert 'a-1' in result.output
コード例 #10
0
ファイル: decorators.py プロジェクト: naphatkrit/TigerHost
 def new_func(ctx, *args, **kwargs):
     if 'vcs' in ctx.obj:
         return ctx.invoke(f, *args, **kwargs)
     # if not a repository, pass ``None``
     try:
         vcs = GitVcs()
     except CommandError:
         vcs = None
     ctx.obj['vcs'] = vcs
     return ctx.invoke(f, *args, **kwargs)
コード例 #11
0
ファイル: test_git.py プロジェクト: naphatkrit/TigerHost
def test_clone(git, repo_path):
    with contextmanagers.temp_dir() as temp_dir:
        git = GitVcs.clone(repo_path, temp_dir)
        assert git.path == temp_dir
コード例 #12
0
def clone_project():
    """Clone a copy of the repo to the default project path
    """
    GitVcs.clone(settings.PROJECT_REMOTE, default_project_path())