@@ -14,7 +14,9 @@ def setUp(self):
14
14
'other' : {'age' : 23 , 'country' : 'us' },
15
15
}
16
16
response = self .client .post (
17
- self .signup_url , signup_data , format = 'json' ,
17
+ self .signup_url ,
18
+ signup_data ,
19
+ format = 'json' ,
18
20
)
19
21
token = response .data .get ('access' )
20
22
self .client .credentials (HTTP_AUTHORIZATION = 'Bearer ' + token )
@@ -23,7 +25,8 @@ def setUp(self):
23
25
def test_get_profile_initial (self ):
24
26
response = self .client .get (self .user_profile_url , format = 'json' )
25
27
self .assertEqual (
26
- response .status_code , rest_framework .status .HTTP_200_OK ,
28
+ response .status_code ,
29
+ rest_framework .status .HTTP_200_OK ,
27
30
)
28
31
expected = {
29
32
'name' : 'Steve' ,
@@ -36,24 +39,31 @@ def test_get_profile_initial(self):
36
39
def test_patch_profile_update_name_and_surname (self ):
37
40
payload = {'name' : 'John' , 'surname' : 'Tsal' }
38
41
response = self .client .patch (
39
- self .user_profile_url , payload , format = 'json' ,
42
+ self .user_profile_url ,
43
+ payload ,
44
+ format = 'json' ,
40
45
)
41
46
self .assertEqual (
42
- response .status_code , rest_framework .status .HTTP_200_OK ,
47
+ response .status_code ,
48
+ rest_framework .status .HTTP_200_OK ,
43
49
)
44
50
self .assertEqual (response .data .get ('name' ), 'John' )
45
51
self .assertEqual (response .data .get ('surname' ), 'Tsal' )
46
52
47
53
def test_patch_profile_update_avatar_url (self ):
48
54
payload = {'avatar_url' : 'http://nodomain.com/kitten.jpeg' }
49
55
response = self .client .patch (
50
- self .user_profile_url , payload , format = 'json' ,
56
+ self .user_profile_url ,
57
+ payload ,
58
+ format = 'json' ,
51
59
)
52
60
self .assertEqual (
53
- response .status_code , rest_framework .status .HTTP_200_OK ,
61
+ response .status_code ,
62
+ rest_framework .status .HTTP_200_OK ,
54
63
)
55
64
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' ,
57
67
)
58
68
59
69
def test_patch_password_and_check_persistence (self ):
@@ -69,30 +79,37 @@ def test_patch_password_and_check_persistence(self):
69
79
format = 'json' ,
70
80
)
71
81
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' ,
73
85
)
74
86
self .assertEqual (
75
- response .status_code , rest_framework .status .HTTP_200_OK ,
87
+ response .status_code ,
88
+ rest_framework .status .HTTP_200_OK ,
76
89
)
77
90
data = response .data
78
91
self .assertEqual (data .get ('name' ), 'John' )
79
92
self .assertEqual (data .get ('surname' ), 'Tsal' )
80
93
self .
assertEqual (
data .
get (
'email' ),
'[email protected] ' )
81
94
self .assertEqual (data .get ('other' ), {'age' : 23 , 'country' : 'us' })
82
95
self .assertEqual (
83
- data .get ('avatar_url' ), 'http://nodomain.com/kitten.jpeg' ,
96
+ data .get ('avatar_url' ),
97
+ 'http://nodomain.com/kitten.jpeg' ,
84
98
)
85
99
86
100
# test old token still valid
87
101
response = self .client .get (self .user_profile_url , format = 'json' )
88
102
self .assertEqual (
89
- response .status_code , rest_framework .status .HTTP_200_OK ,
103
+ response .status_code ,
104
+ rest_framework .status .HTTP_200_OK ,
90
105
)
91
106
92
107
def test_auth_sign_in_old_password_fails (self ):
93
108
new_password = 'MegaGiant88888@dooRuveS'
94
109
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' ,
96
113
)
97
114
self .client .credentials ()
98
115
response = self .client .post (
@@ -104,13 +121,16 @@ def test_auth_sign_in_old_password_fails(self):
104
121
format = 'json' ,
105
122
)
106
123
self .assertEqual (
107
- response .status_code , rest_framework .status .HTTP_401_UNAUTHORIZED ,
124
+ response .status_code ,
125
+ rest_framework .status .HTTP_401_UNAUTHORIZED ,
108
126
)
109
127
110
128
def test_auth_sign_in_new_password_succeeds (self ):
111
129
new_password = 'MegaGiant88888@dooRuveS'
112
130
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' ,
114
134
)
115
135
self .client .credentials ()
116
136
response = self .client .post (
@@ -122,5 +142,6 @@ def test_auth_sign_in_new_password_succeeds(self):
122
142
format = 'json' ,
123
143
)
124
144
self .assertEqual (
125
- response .status_code , rest_framework .status .HTTP_200_OK ,
145
+ response .status_code ,
146
+ rest_framework .status .HTTP_200_OK ,
126
147
)
0 commit comments