File tree 1 file changed +18
-3
lines changed
libpythonpro/tests/test_spam
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 1
1
from unittest .mock import Mock
2
2
3
+ import pytest
4
+
3
5
from libpythonpro import github_api
4
6
5
7
6
- def test_buscar_avatar ():
8
+ @pytest .fixture
9
+ def avatar_url ():
7
10
resp_mock = Mock ()
11
+ url = 'https://avatars3.githubusercontent.com/u/402714?v=4'
8
12
resp_mock .json .return_value = {
9
13
'login' : 'renzo' , 'id' : 402714 ,
10
- 'avatar_url' : 'https://avatars3.githubusercontent.com/u/402714?v=4' ,
14
+ 'avatar_url' : url ,
11
15
}
16
+ get_original = github_api .requests .get
12
17
github_api .requests .get = Mock (return_value = resp_mock )
18
+ yield url
19
+ github_api .requests .get = get_original
20
+
21
+
22
+ def test_buscar_avatar (avatar_url ):
13
23
url = github_api .buscar_avatar ('renzo' )
14
- assert 'https://avatars3.githubusercontent.com/u/402714?v=4' == url
24
+ assert avatar_url == url
25
+
26
+
27
+ def test_buscar_avatar_integracao ():
28
+ url = github_api .buscar_avatar ('renzon' )
29
+ assert 'https://avatars3.githubusercontent.com/u/3457115?v=4' == url
You can’t perform that action at this time.
0 commit comments