@@ -14,7 +14,9 @@ def setUp(self):
1414 'other' : {'age' : 23 , 'country' : 'us' },
1515 }
1616 response = self .client .post (
17- self .signup_url , signup_data , format = 'json' ,
17+ self .signup_url ,
18+ signup_data ,
19+ format = 'json' ,
1820 )
1921 token = response .data .get ('access' )
2022 self .client .credentials (HTTP_AUTHORIZATION = 'Bearer ' + token )
@@ -23,7 +25,8 @@ def setUp(self):
2325 def test_get_profile_initial (self ):
2426 response = self .client .get (self .user_profile_url , format = 'json' )
2527 self .assertEqual (
26- response .status_code , rest_framework .status .HTTP_200_OK ,
28+ response .status_code ,
29+ rest_framework .status .HTTP_200_OK ,
2730 )
2831 expected = {
2932 'name' : 'Steve' ,
@@ -36,24 +39,31 @@ def test_get_profile_initial(self):
3639 def test_patch_profile_update_name_and_surname (self ):
3740 payload = {'name' : 'John' , 'surname' : 'Tsal' }
3841 response = self .client .patch (
39- self .user_profile_url , payload , format = 'json' ,
42+ self .user_profile_url ,
43+ payload ,
44+ format = 'json' ,
4045 )
4146 self .assertEqual (
42- response .status_code , rest_framework .status .HTTP_200_OK ,
47+ response .status_code ,
48+ rest_framework .status .HTTP_200_OK ,
4349 )
4450 self .assertEqual (response .data .get ('name' ), 'John' )
4551 self .assertEqual (response .data .get ('surname' ), 'Tsal' )
4652
4753 def test_patch_profile_update_avatar_url (self ):
4854 payload = {'avatar_url' : 'http://nodomain.com/kitten.jpeg' }
4955 response = self .client .patch (
50- self .user_profile_url , payload , format = 'json' ,
56+ self .user_profile_url ,
57+ payload ,
58+ format = 'json' ,
5159 )
5260 self .assertEqual (
53- response .status_code , rest_framework .status .HTTP_200_OK ,
61+ response .status_code ,
62+ rest_framework .status .HTTP_200_OK ,
5463 )
5564 self .assertEqual (
56- response .data .get ('avatar_url' ), 'http://nodomain.com/kitten.jpeg' ,
65+ response .data .get ('avatar_url' ),
66+ 'http://nodomain.com/kitten.jpeg' ,
5767 )
5868
5969 def test_patch_password_and_check_persistence (self ):
@@ -69,30 +79,37 @@ def test_patch_password_and_check_persistence(self):
6979 format = 'json' ,
7080 )
7181 response = self .client .patch (
72- self .user_profile_url , {'password' : new_password }, format = 'json' ,
82+ self .user_profile_url ,
83+ {'password' : new_password },
84+ format = 'json' ,
7385 )
7486 self .assertEqual (
75- response .status_code , rest_framework .status .HTTP_200_OK ,
87+ response .status_code ,
88+ rest_framework .status .HTTP_200_OK ,
7689 )
7790 data = response .data
7891 self .assertEqual (data .get ('name' ), 'John' )
7992 self .assertEqual (data .get ('surname' ), 'Tsal' )
8093 self .assertEqual (data .get ('email' ), 'creator@apple.com' )
8194 self .assertEqual (data .get ('other' ), {'age' : 23 , 'country' : 'us' })
8295 self .assertEqual (
83- data .get ('avatar_url' ), 'http://nodomain.com/kitten.jpeg' ,
96+ data .get ('avatar_url' ),
97+ 'http://nodomain.com/kitten.jpeg' ,
8498 )
8599
86100 # test old token still valid
87101 response = self .client .get (self .user_profile_url , format = 'json' )
88102 self .assertEqual (
89- response .status_code , rest_framework .status .HTTP_200_OK ,
103+ response .status_code ,
104+ rest_framework .status .HTTP_200_OK ,
90105 )
91106
92107 def test_auth_sign_in_old_password_fails (self ):
93108 new_password = 'MegaGiant88888@dooRuveS'
94109 response = self .client .patch (
95- self .user_profile_url , {'password' : new_password }, format = 'json' ,
110+ self .user_profile_url ,
111+ {'password' : new_password },
112+ format = 'json' ,
96113 )
97114 self .client .credentials ()
98115 response = self .client .post (
@@ -104,13 +121,16 @@ def test_auth_sign_in_old_password_fails(self):
104121 format = 'json' ,
105122 )
106123 self .assertEqual (
107- response .status_code , rest_framework .status .HTTP_401_UNAUTHORIZED ,
124+ response .status_code ,
125+ rest_framework .status .HTTP_401_UNAUTHORIZED ,
108126 )
109127
110128 def test_auth_sign_in_new_password_succeeds (self ):
111129 new_password = 'MegaGiant88888@dooRuveS'
112130 response = self .client .patch (
113- self .user_profile_url , {'password' : new_password }, format = 'json' ,
131+ self .user_profile_url ,
132+ {'password' : new_password },
133+ format = 'json' ,
114134 )
115135 self .client .credentials ()
116136 response = self .client .post (
@@ -122,5 +142,6 @@ def test_auth_sign_in_new_password_succeeds(self):
122142 format = 'json' ,
123143 )
124144 self .assertEqual (
125- response .status_code , rest_framework .status .HTTP_200_OK ,
145+ response .status_code ,
146+ rest_framework .status .HTTP_200_OK ,
126147 )
0 commit comments