Skip to content

Commit 2e0a80f

Browse files
style: Fix formatting issues detected by ruff format
1 parent b20c6fc commit 2e0a80f

File tree

2 files changed

+56
-23
lines changed

2 files changed

+56
-23
lines changed

promo_code/user/tests/user/operations/test_profile.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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'), '[email protected]')
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
)

promo_code/user/tests/user/validations/test_profile_validation.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@ def setUp(self):
1515
'other': {'age': 48, 'country': 'gb'},
1616
}
1717
response = self.client.post(
18-
self.signup_url, signup_data, format='json',
18+
self.signup_url,
19+
signup_data,
20+
format='json',
1921
)
2022
token = response.data.get('access')
2123
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + token)
2224

2325
def test_update_profile_empty_name_and_surname(self):
2426
payload = {'name': '', 'surname': ''}
2527
response = self.client.patch(
26-
self.user_profile_url, payload, format='json',
28+
self.user_profile_url,
29+
payload,
30+
format='json',
2731
)
2832
self.assertEqual(
29-
response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST,
33+
response.status_code,
34+
rest_framework.status.HTTP_400_BAD_REQUEST,
3035
)
3136

3237
@parameterized.parameterized.expand(
@@ -39,10 +44,13 @@ def test_update_profile_empty_name_and_surname(self):
3944
def test_update_profile_invalid_avatar_url(self, name, url):
4045
payload = {'avatar_url': url}
4146
response = self.client.patch(
42-
self.user_profile_url, payload, format='json',
47+
self.user_profile_url,
48+
payload,
49+
format='json',
4350
)
4451
self.assertEqual(
45-
response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST,
52+
response.status_code,
53+
rest_framework.status.HTTP_400_BAD_REQUEST,
4654
)
4755

4856
@parameterized.parameterized.expand(
@@ -61,16 +69,20 @@ def test_update_profile_invalid_avatar_url(self, name, url):
6169
def test_update_profile_weak_password(self, name, pwd):
6270
payload = {'password': pwd}
6371
response = self.client.patch(
64-
self.user_profile_url, payload, format='json',
72+
self.user_profile_url,
73+
payload,
74+
format='json',
6575
)
6676
self.assertEqual(
67-
response.status_code, rest_framework.status.HTTP_400_BAD_REQUEST,
77+
response.status_code,
78+
rest_framework.status.HTTP_400_BAD_REQUEST,
6879
)
6980

7081
def test_get_profile(self):
7182
response = self.client.get(self.user_profile_url, format='json')
7283
self.assertEqual(
73-
response.status_code, rest_framework.status.HTTP_200_OK,
84+
response.status_code,
85+
rest_framework.status.HTTP_200_OK,
7486
)
7587
expected = {
7688
'name': 'Jack',

0 commit comments

Comments
 (0)