def test_request_cli_access_token_real():
    try:
        requests.get('https://solarforecastarbiter.auth0.com')
    except Exception:  # pragma: no cover
        return pytest.skip('Cannot connect to Auth0')
    else:
        assert api.request_cli_access_token('*****@*****.**',
                                            'Thepassword123!') is not None
Пример #2
0
def cli_access_token(user, password):
    try:
        token = request_cli_access_token(user, password)
    except requests.HTTPError as e:
        click.echo(
            click.style(e.response.json()['error_description'], fg='red'))
        sys.exit(1)
    else:
        return token
def test_request_cli_access_token_mocked(requests_mock):
    requests_mock.register_uri(
        'POST',
        'https://solarforecastarbiter.auth0.com/oauth/token',
        content=b'{"access_token": "token"}')
    assert api.request_cli_access_token('test', 'pass') == 'token'