File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
app/ch14_testing/final/tests Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments