Fix these 16 tests by running each test individually and fixing the error. Many of the error
Question:
Fix these 16 tests by running each test individually and fixing the error. Many of the error are just the wrong text is being displayed or it is not redirecting the user to the proper web page; however, some errors are more challenging.
1.
def test_index_route(client):
response = client.get("/about")
assert response.status_code == 200
assert b"about me" in response.data
2.
def test_index_route(client):
response = client.get("/")
assert response.status_code == 200
assert b"IS 601" in response.data
3.def test_user_login_bad_password(client):
with client:
response = client.post("/registration", data={
"..e@ 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={
"..e@ steve.com",
"password": "testtes",
}, follow_redirects=True)
assert response.request.path == url_for('authentication.login')
assert response.status_code == 200
assert b"Password Incorrect" in response.data
4.def test_user_login_dashboard(client, login):
with client:
response = client.get("/dashboard", follow_redirects=True)
assert response.request.path == url_for('authentication.dashboard')
assert response.status_code == 200
a..e@ steve.com" in response.data
5.def test_user_login_success(client):
with client:
response = client.post("/registration", data={
"..e@ 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={
"..e@ steve.com",
"password": "testtest",
}, follow_redirects=True)
assert response.request.path == url_for('authentication.dashboard')
assert response.status_code == 200
6.def test_user_login_user_not_found(client):
with client:
response = client.post("/registration", data={
"..e@ 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={
"..e@ 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
7.def test_user_logout_success(client):
with client:
response = client.post("/registration", data={
"..e@ 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={
"..e@ steve.com",
"password": "testtest",
}, follow_redirects=True)
assert response.request.path == url_for('authentication.dashboard')
assert response.status_code == 200
a..e@ 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
8.def test_user_profile_post_controller(app, client, login):
with app.app_context():
assert Profile.record_count() == 0
with client:
response = client.post("/profile", data={
"first_name": "Steve",
"last_name": "Steve",
"phone": "5555555",
}, follow_redirects=True)
assert response.status_code == 200
with app.app_context():
assert Profile.record_count() == 1
9.def test_user_profile_model(app, create_5_users):
with app.app_context():
assert Profile.record_count() == 0
user = User.find_by_id(1)
profile = Profile("Steve", "Steve", "5555555")
user.profile = profile
user.save()
assert Profile.record_count() == 1
assert user.profile.first_name == "Steve"
assert user.profile.last_name == "Steve"
assert user.profile.phone == "5555555"
10. def test_user_registration_duplicate_user_fail(app, client):
with app.app_context():
user = U..e@ steve.com', 'testtest')
db.session.add(user)
db.session.commit()
with client:
response = client.post("/registration", data={
"..e@ 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
11.
def test_user_registration_success(client):
with client:
response = client.post("/registration", data={
"..e@ steve.com",
"password": "testtest",
"confirm": "testtest",
}, follow_redirects=True)
assert response.request.path == url_for('authentication.login')
assert response.status_code == 200
12.
def test_main_menu_authenticated(client, login):
response = client.get("/dashboard")
assert response.status_code == 200
assert b"Calculate Sample" in response.data
assert b"My Sample Sizes" in response.data
assert b"Logout" in response.data
assert b"My Profile" in response.data
13.
def test_sample_size_login_redirect_route(client):
response = client.post("/registration", data={
"..e@ steve.com",
"password": "testtest",
"confirm": "testtest",
}, follow_redirects=True)
assert response.status_code == 200
assert response.request.path == url_for('authentication.login')
response = client.get("/sample_size", follow_redirects=True)
assert response.status_code == 200
assert response.request.path == url_for('authentication.login')
response = client.get(
"/login?next=%2Fsample_size",
follow_redirects=True
)
response = client.post(
"/login?next=%2Fsample_size",
d..e@ steve.com', password='testtest'),
follow_redirects=True
)
assert response.status_code == 200
assert response.request.path == url_for('sample_size.sample_size_page')
14.
def test_sample_calc_model(app, create_5_users):
with app.app_context():
assert SampleCalc.record_count() == 0
sample_calc = SampleCalc(z_score=2.58, margin_error=.05, std=.5, population_size=425)
assert sample_calc.calc_sample_size == 259.39
user = User.get_random_record()
user.sample_calcs.append(sample_calc)
user.save()
assert SampleCalc.record_count() == 1
15.
def test_sample_calc_route(app, client, login):
with app.app_context():
assert SampleCalc.record_count() == 0
with client:
response = client.post("/sample_size", data={
"z_score": "2.58",
"margin_error": ".05",
"std": ".5",
"population_size": "425"
}, follow_redirects=True)
with app.app_context():
assert SampleCalc.record_count() == 1
assert response.status_code == 200
assert response.request.path == url_for('sample_size.my_sample_calcs')
assert b"259.39" in response.data
16.def test_menu_calculate_sample_unauthenticated(client):
response = client.get("/")
assert response.status_code == 200
assert b"Calculate Sample" in response.data
Accounting Information Systems
ISBN: 978-0133428537
13th edition
Authors: Marshall B. Romney, Paul J. Steinbart