Skip to content

Instantly share code, notes, and snippets.

@tuannvm
Created January 5, 2017 17:02
Show Gist options
  • Save tuannvm/fcdcfb75fa56b9a5356a21a2ed42e1e9 to your computer and use it in GitHub Desktop.
Save tuannvm/fcdcfb75fa56b9a5356a21a2ed42e1e9 to your computer and use it in GitHub Desktop.
# Standard library imports...
from unittest.mock import Mock, patch
# Third-party imports...
from nose.tools import assert_is_not_none
# Local imports...
from project.services import get_todos
@patch('project.services.requests.get')
def test_getting_todos(mock_get):
# Configure the mock to return a response with an OK status code.
mock_get.return_value.ok = True
# Call the service, which will send a request to the server.
response = get_todos()
# If the request is sent successfully, then I expect a response to be returned.
assert_is_not_none(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment