Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9883b39 commit f5561cdCopy full SHA for f5561cd
libpythonpro/github_api.py
@@ -11,7 +11,3 @@ def buscar_avatar(usuario):
11
url = f'https://api.github.com/users/{usuario}'
12
resp = requests.get(url)
13
return resp.json()['avatar_url']
14
-
15
16
-if __name__ == '__main__':
17
- print(buscar_avatar('renzon'))
libpythonpro/tests/test_spam/test_github_api.py
@@ -0,0 +1,14 @@
1
+from unittest.mock import Mock
2
+
3
+from libpythonpro import github_api
4
5
6
+def test_buscar_avatar():
7
+ resp_mock = Mock()
8
+ resp_mock.json.return_value = {
9
+ 'login': 'renzo', 'id': 402714,
10
+ 'avatar_url': 'https://avatars3.githubusercontent.com/u/402714?v=4',
+ }
+ github_api.requests.get = Mock(return_value=resp_mock)
+ url = github_api.buscar_avatar('renzo')
+ assert 'https://avatars3.githubusercontent.com/u/402714?v=4' == url
0 commit comments