Skip to content

Commit 72a490a

Browse files
committed
Integration tests done.
1 parent 44f7908 commit 72a490a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/ch14_testing/final/tests/account_tests.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,22 @@ def test_v_register_view_new_user():
8080

8181
# Assert
8282
assert resp.___location == '/account'
83+
84+
85+
def test_int_account_home_no_login(client):
86+
target = 'pypi_org.services.user_service.find_user_by_id'
87+
with unittest.mock.patch(target, return_value=None):
88+
resp: Response = client.get('/account')
89+
90+
assert resp.status_code == 302
91+
assert resp.___location == 'http://localhost/account/login'
92+
93+
94+
def test_int_account_home_with_login(client):
95+
target = 'pypi_org.services.user_service.find_user_by_id'
96+
test_user = User(name='Michael', email='[email protected]')
97+
with unittest.mock.patch(target, return_value=test_user):
98+
resp: Response = client.get('/account')
99+
100+
assert resp.status_code == 200
101+
assert b'Michael' in resp.data

0 commit comments

Comments
 (0)