Beispiel #1
0
def test_invalid_auth():
    session = Session()
    session.configure(sandbox=False)
    with pytest.raises(CuencaResponseException) as e:
        session.post('/api_keys', dict())
    assert e.value.status_code == 401
    assert str(e.value)
Beispiel #2
0
def test_configures_new_aws_creds():
    session = Session()
    session.configure(aws_access_key='new_aws_key',
                      aws_secret_access_key='new_aws_secret')
    assert session.auth.aws_secret_access_key == 'new_aws_secret'
    assert session.auth.aws_access_key == 'new_aws_key'
    assert session.auth.aws_region == 'us-east-1'
Beispiel #3
0
def test_request_expired_token():
    session = Session()
    session.configure(use_jwt=True)
    previous_jwt = session.jwt_token.token
    with freeze_time(dt.datetime.utcnow() + dt.timedelta(days=40)):
        response = session.get('/api_keys')
    assert response['items']
    assert session.jwt_token != previous_jwt
Beispiel #4
0
def test_request_valid_token():
    session = Session()
    # Set date when the cassette was created otherwise will retrieve
    # an expired token
    with freeze_time(dt.date(2020, 10, 22)):
        session.configure(use_jwt=True)
        response = session.get('/api_keys')
    assert response['items']
def session():
    session = Session()
    session.configure(
        'api_key',
        'api_secret',
        sandbox=True,
    )
    return session
Beispiel #6
0
def test_overrides_session(mock_request):
    mock_request.return_value.ok = True
    mock_request.return_value.content = '{"items": []}'
    session = Session()
    session.configure(api_key='USER_API_KEY',
                      api_secret='USER_SECRET',
                      sandbox=True)
    Card.first(user_id='USER_ID', session=session)
    mock_request.assert_called_once()
    _, kwargs = mock_request.call_args_list[0]
    assert kwargs['auth'] == session.auth
Beispiel #7
0
def test_configures_jwt():
    session = Session()
    session.configure(use_jwt=True)
    assert session.auth
    assert session.jwt_token