Пример #1
0
def upgrade(ctx, **kwargs):
    try:
        battenberg = Battenberg(open_repository(ctx.obj['target']))
        battenberg.upgrade(**kwargs)
    except MergeConflictException:
        # Just run "git status" in a subprocess so we don't have to re-implement the formatting
        # logic atop pygit2.
        completed_process = subprocess.run(['git', 'status'], stdout=subprocess.PIPE,
                                           stderr=subprocess.STDOUT)
        click.echo(completed_process.stdout.decode('utf-8'))
        click.echo('Cannot merge upgrade automatically, please manually resolve the conflicts')
        sys.exit(1)  # Ensure we exit with a failure code.
Пример #2
0
def test_open_repository(Repository: Mock, discover_repository: Mock):
    path = 'test-path'
    assert open_repository(path) == Repository.return_value
    Repository.assert_called_once_with(discover_repository.return_value)
    discover_repository.assert_called_once_with(path)
Пример #3
0
def test_open_repository_raises_on_invalid_path():
    path = 'test-path'
    with pytest.raises(InvalidRepositoryException) as e:
        open_repository(path)

    assert str(e.value) == f'{path} is not a valid repository path.'
Пример #4
0
def test_open_repository():
    path = 'test-path'
    with pytest.assertRaises(ValueError) as e:
        open_repository(path)

    assert str(e.value) == f'{path} is not a valid repository path.'