Пример #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'}