示例#1
0
def test_login_bad_creds_one(dummy_request, set_creds):
    """Test login with bad password returns error message."""
    dummy_request.method = 'POST'
    dummy_request.POST = {
        'username': os.environ.get('AUTH_USERNAME'),
        'password': '******'
    }
    assert login(dummy_request) == {'error': 'Bad username or password'}
    assert type(login(dummy_request)) == dict
示例#2
0
def test_login_bad_creds_both(dummy_request):
    """Test login with bad credentials returns error message."""
    dummy_request.method = 'POST'
    dummy_request.POST = {
        'username': '******',
        'password': '******'
    }
    assert login(dummy_request) == {'error': 'Bad username or password'}
示例#3
0
def test_login_with_good_creds(dummy_request, set_creds):
    """Test login with good credentials redirects."""
    dummy_request.method = 'POST'
    dummy_request.POST = {
        'username': os.environ.get('AUTH_USERNAME'),
        'password': '******'
    }
    response = login(dummy_request)
    assert response.status_code == 302
    assert isinstance(response, HTTPFound)
示例#4
0
def test_login_returns_dict(dummy_request):
    """Test request to login returns a dict."""
    response = login(dummy_request)
    assert type(response) == dict
示例#5
0
def test_get_login_returns_dict(dummy_request):
    from pyramid_learning_journal.views.default import login
    dummy_request.method = "GET"
    response = login(dummy_request)
    assert response == {}
示例#6
0
def test_login_bad_credentials_fails(post_request):
    from pyramid_learning_journal.views.default import login
    data = {'username': '******', 'password': '******'}
    post_request.POST = data
    response = login(post_request)
    assert response == {'error': 'Bad username or password'}