File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,3 @@ def buscar_avatar(usuario):
11
11
url = f'https://api.github.com/users/{ usuario } '
12
12
resp = requests .get (url )
13
13
return resp .json ()['avatar_url' ]
14
-
15
-
16
- if __name__ == '__main__' :
17
- print (buscar_avatar ('renzon' ))
Original file line number Diff line number Diff line change
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' ,
11
+ }
12
+ github_api .requests .get = Mock (return_value = resp_mock )
13
+ url = github_api .buscar_avatar ('renzo' )
14
+ assert 'https://avatars3.githubusercontent.com/u/402714?v=4' == url
You can’t perform that action at this time.
0 commit comments