forked from pythonprobr/libpythonpro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_github_api.py
More file actions
29 lines (21 loc) · 747 Bytes
/
test_github_api.py
File metadata and controls
29 lines (21 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest.mock
import pytest
from pytest_mock import mocker
from ... import github_api
@pytest.fixture
def avatar_url(mocker):
resp_mock = unittest.mock.Mock()
url = 'https://avatars3.githubusercontent.com/u/402714?v=4'
resp_mock.json.return_value = {
'login': 'renzo', 'id': 402714,
'avatar_url': url,
}
get_mock = mocker.patch('libpythonpro.libpythonpro.github_api.requests.get')
get_mock.return_value = resp_mock
return url
def test_buscar_avatar(avatar_url):
url = github_api.buscar_avatar('renzo')
assert avatar_url == url
def test_buscar_avatar_integracao():
url = github_api.buscar_avatar('renzo')
assert 'https://avatars3.githubusercontent.com/u/402714?v=4' == url