Example #1
0
def test_check_for_updates_ko_call(mocker, capsys):
    mocker.patch(
        'connect.cli.core.utils.subprocess.check_output',
        side_effect=subprocess.CalledProcessError('error', []),
    )

    utils.check_for_updates()

    captured = capsys.readouterr()
    assert captured.out == ''
Example #2
0
def test_check_for_updates_is_latest(mocker, capsys, mocked_responses):
    mocker.patch('connect.cli.core.utils.get_version', return_value='2.0.0')
    mocked_responses.add('GET', PYPI_JSON_API_URL, json={'info': {'version': '2.0.0'}})

    utils.check_for_updates()

    captured = capsys.readouterr()

    assert 'You are running CloudBlue Connect CLI version 1.0.0. ' not in captured.out
    assert 'A newer version is available: 2.0.0' not in captured.out
Example #3
0
def test_check_for_updates_ko_name(mocker, capsys):
    pip_resp = [
        {
            'name': 'connect-client',
            'version': '1.0.0',
            'latest_version': '2.0.0',
        },
    ]
    mocker.patch(
        'connect.cli.core.utils.subprocess.check_output',
        return_value=json.dumps(pip_resp),
    )

    utils.check_for_updates()

    captured = capsys.readouterr()
    assert captured.out == ''
Example #4
0
def test_check_for_updates_ok(mocker, capsys):
    pip_resp = [
        {
            'name': 'connect-cli',
            'version': '1.0.0',
            'latest_version': '2.0.0',
        },
    ]
    mocker.patch(
        'connect.cli.core.utils.subprocess.check_output',
        return_value=json.dumps(pip_resp),
    )

    utils.check_for_updates()

    captured = capsys.readouterr()

    assert 'You are running CloudBlue Connect CLI version 1.0.0. ' in captured.out
    assert 'A newer version is available: 2.0.0' in captured.out
Example #5
0
def print_version(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    click.echo(f'CloudBlue Connect CLI, version {get_version()}')
    check_for_updates()
    ctx.exit()