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
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'}
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)
def test_login_returns_dict(dummy_request): """Test request to login returns a dict.""" response = login(dummy_request) assert type(response) == dict
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 == {}
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'}