Created
February 16, 2016 23:41
-
-
Save jmrnilsson/156f9c5a3c504ccc5c8c to your computer and use it in GitHub Desktop.
patch.object for requests.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from nose.tools import assert_equal | |
from mock import Mock, patch | |
from brew import brewery_db as client | |
from utils import json_load | |
def response_mock(): | |
return Mock(json=Mock(return_value=json_load('brewery_db.json'))) | |
def test_find_by_id(): | |
with patch.object(requests, 'get', return_value=response_mock()): | |
actual = client.find_by_id('oeGS1') | |
assert_equal(actual['data']['name'], 'NAU 91') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment