File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
libpythonpro/tests/test_spam Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 11from unittest .mock import Mock
22
3+ import pytest
4+
35from libpythonpro import github_api
46
57
6- def test_buscar_avatar ():
8+ @pytest .fixture
9+ def avatar_url ():
710 resp_mock = Mock ()
11+ url = 'https://avatars3.githubusercontent.com/u/402714?v=4'
812 resp_mock .json .return_value = {
913 'login' : 'renzo' , 'id' : 402714 ,
10- 'avatar_url' : 'https://avatars3.githubusercontent.com/u/402714?v=4' ,
14+ 'avatar_url' : url ,
1115 }
16+ get_original = github_api .requests .get
1217 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 ):
1323 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