Question: 6. def test_user_registration_success(client): with client: response = client.post(/registration, data={ email: steve@steve.com, password: testtest, confirm: testtest, }, follow_redirects=True) assert response.request.path == url_for('authentication.login') assert response.status_code == 200
6.
def test_user_registration_success(client): with client: response = client.post("/registration", data={ "email": "steve@steve.com", "password": "testtest", "confirm": "testtest", }, follow_redirects=True) assert response.request.path == url_for('authentication.login') assert response.status_code == 200
> assert response.request.path == url_for('authentication.login') E AssertionError: assert '/' == '/login' E - /login E + /
def test_user_registration_duplicate_user_fail(app, client): with app.app_context(): user = User.create('steve@steve.com', 'testtest') db.session.add(user) db.session.commit() with client: response = client.post("/registration", data={ "email": "steve@steve.com", "password": "testtest", "confirm": "testtest", }, follow_redirects=True) assert response.request.path == url_for('authentication.registration') assert response.status_code == 200 assert b"Already Registered" in response.data
> assert b"Already Registered" in response.data E assert b'Already Registered
def test_user_logout_success(client): with client: response = client.post("/registration", data={ "email": "steve@steve.com", "password": "testtest", "confirm": "testtest", }, follow_redirects=True) assert response.request.path == url_for('authentication.login') assert response.status_code == 200 response = client.post("/login", data={ "email": "steve@steve.com", "password": "testtest", }, follow_redirects=True) assert response.request.path == url_for('authentication.dashboard') assert response.status_code == 200 assert b"steve@steve.com" in response.data response = client.get("/logout", follow_redirects=True) assert response.request.path == url_for('homepage.homepage') assert response.status_code == 200
PROBLEM
'/' != '/login'
Expected :'/login' Actual :'/'
8.
def test_user_login_user_not_found(client): with client: response = client.post("/registration", data={ "email": "steve@steve.com", "password": "testtest", "confirm": "testtest", }, follow_redirects=True) assert response.request.path == url_for('authentication.login') assert response.status_code == 200 response = client.post("/login", data={ "email": "steve@steve.bad", "password": "testtes", }, follow_redirects=True) assert response.request.path == url_for('authentication.login') assert response.status_code == 200 assert b"User Not Found" in response.data
PROBLEM Expected :'/login' Actual :'/'
> assert response.request.path == url_for('authentication.login') E AssertionError: assert '/' == '/login' E - /login E + /
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
