Skip to content

Commit 500c8f5

Browse files
author
kimobrian
committed
chore(pep-8): Use PEP8 styling
1 parent 8d6d581 commit 500c8f5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

users.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import json
33

44
USERS_URL = 'http://jsonplaceholder.typicode.com/users'
5+
6+
57
def get_users():
68
"""Get list of users"""
79
response = requests.get(USERS_URL)
@@ -16,4 +18,4 @@ def get_user(user_id):
1618
all_users = get_users().json()
1719
for user in all_users:
1820
if user['id'] == user_id:
19-
return user
21+
return user

users_test/test_users.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from users import get_users, get_user
33
from unittest.mock import patch, Mock
44

5+
56
class BasicTests(unittest.TestCase):
67
def test_request_response(self):
78
mock_get_patcher = patch('users.requests.get')
@@ -16,7 +17,7 @@ def test_request_response(self):
1617
mock_get = mock_get_patcher.start()
1718

1819
# Configure the mock to return a response with status code 200.
19-
mock_get.return_value = Mock(status_code = 200)
20+
mock_get.return_value = Mock(status_code=200)
2021
mock_get.return_value.json.return_value = users
2122

2223
# Call the service, which will send a request to the server.
@@ -33,14 +34,18 @@ def test_request_response(self):
3334
def test_get_one_user(self, mock_get_users):
3435
"""Test for getting one user using their userID"""
3536
users = [
36-
{'phone': '514-794-6957', 'first_name': 'Brant', 'last_name': 'Mekhi', 'id': 0},
37-
{'phone': '772-370-0117', 'first_name': 'Thalia', 'last_name': 'Kenyatta', 'id': 1},
38-
{'phone': '176-290-7637', 'first_name': 'Destin', 'last_name': 'Soledad', 'id': 2}
39-
]
37+
{'phone': '514-794-6957', 'first_name': 'Brant',
38+
'last_name': 'Mekhi', 'id': 0},
39+
{'phone': '772-370-0117', 'first_name': 'Thalia',
40+
'last_name': 'Kenyatta', 'id': 1},
41+
{'phone': '176-290-7637', 'first_name': 'Destin',
42+
'last_name': 'Soledad', 'id': 2}
43+
]
4044
mock_get_users.return_value = Mock()
4145
mock_get_users.return_value.json.return_value = users
4246
user = get_user(2)
4347
self.assertEqual(user, users[2])
4448

49+
4550
if __name__ == "__main__":
4651
unittest.main()

0 commit comments

Comments
 (0)