def test_without_project_path_default_exists_dir(runner, fake_git_remote):
    assert get_project_path() is None
    assert not os.system('mkdir {}'.format(default_project_path()))
    with mock.patch('deploy.settings.PROJECT_REMOTE', new=fake_git_remote):
        result = runner.invoke(dummy, input='1\n\n')
    assert result.exit_code == exit_codes.SUCCESS
    assert get_project_path() == path_utils.canonical_path(default_project_path())
def test_without_project_path_default_exists_dir(runner, fake_git_remote):
    assert get_project_path() is None
    assert not os.system('mkdir {}'.format(default_project_path()))
    with mock.patch('deploy.settings.PROJECT_REMOTE', new=fake_git_remote):
        result = runner.invoke(dummy, input='1\n\n')
    assert result.exit_code == exit_codes.SUCCESS
    assert get_project_path() == path_utils.canonical_path(
        default_project_path())
def test_without_project_path_default_normal(runner, fake_git_remote):
    assert get_project_path() is None
    with mock.patch('deploy.settings.PROJECT_REMOTE', new=fake_git_remote):
        result = runner.invoke(dummy, input='1\n')
    assert result.exit_code == exit_codes.SUCCESS
    assert get_project_path() == path_utils.canonical_path(
        default_project_path())
Esempio n. 4
0
def test_clone_project():
    path = default_project_path()
    assert not os.path.exists(path)
    with contextmanagers.temp_dir() as temp_dir:
        with contextmanagers.chdir(temp_dir):
            assert not os.system('git init')
            assert not os.system('touch a && git add . && git commit -m a')
        with mock.patch('deploy.settings.PROJECT_REMOTE', new=temp_dir):
            clone_project()
    assert os.path.exists(path)
    assert os.path.exists(os.path.join(path, 'a'))
Esempio n. 5
0
 def new_func(ctx, *args, **kwargs):
     """
     :param click.Context ctx:
     """
     if get_project_path() is None:
         click.echo('Config project_path not set.')
         click.echo('You can do one of the following:')
         choice = click_utils.prompt_choices([
             'Clone the repository to {}.'.format(default_project_path()),
             'Specify the path to an existing repo.'
         ])
         if choice == 0:
             path = default_project_path()
             if os.path.exists(path):
                 click.confirm(
                     'Path {} already exists. Continuing will remove this path.'
                     .format(path),
                     default=True,
                     abort=True)
                 if os.path.isdir(path):
                     shutil.rmtree(path)
                 else:
                     os.remove(path)
             click.echo('Cloning to {}...'.format(path), nl=False)
             clone_project()
             click.secho('Done', fg='black', bg='green')
             save_project_path(path)
         else:
             value = click.prompt('Please enter the path to your project',
                                  type=str)
             value = path_utils.canonical_path(value)
             if not os.path.exists(value) or not os.path.isdir(value):
                 click.echo('This directory does not exist.')
                 ctx.exit(code=exit_codes.OTHER_FAILURE)
             click.confirm('Is your project at {}?'.format(value),
                           default=True,
                           abort=True)
             save_project_path(value)
     return ctx.invoke(f, *args, **kwargs)
Esempio n. 6
0
def clone(force):
    """Clone a copy of the TigerHost project to
    a private location and set the project path
    to the cloned location.
    """
    path = default_project_path()
    if os.path.exists(path):
        if not force:
            click.confirm('Path {} already exists. Continuing will remove this path.'.format(
                path), default=True, abort=True)
        if os.path.isdir(path):
            shutil.rmtree(path)
        else:
            os.remove(path)
    click.echo('Cloning to {}...'.format(path), nl=False)
    clone_project()
    click.secho('Done', fg='black', bg='green')
    save_project_path(path)
Esempio n. 7
0
def clone(force):
    """Clone a copy of the TigerHost project to
    a private location and set the project path
    to the cloned location.
    """
    path = default_project_path()
    if os.path.exists(path):
        if not force:
            click.confirm(
                'Path {} already exists. Continuing will remove this path.'.
                format(path),
                default=True,
                abort=True)
        if os.path.isdir(path):
            shutil.rmtree(path)
        else:
            os.remove(path)
    click.echo('Cloning to {}...'.format(path), nl=False)
    clone_project()
    click.secho('Done', fg='black', bg='green')
    save_project_path(path)
def test_without_project_path_default_normal(runner, fake_git_remote):
    assert get_project_path() is None
    with mock.patch('deploy.settings.PROJECT_REMOTE', new=fake_git_remote):
        result = runner.invoke(dummy, input='1\n')
    assert result.exit_code == exit_codes.SUCCESS
    assert get_project_path() == path_utils.canonical_path(default_project_path())