Skip to content

Instantly share code, notes, and snippets.

@EdwardIII

EdwardIII/f.py Secret

Last active December 30, 2015 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdwardIII/ab80f8f2f9f73d35f340 to your computer and use it in GitHub Desktop.
Save EdwardIII/ab80f8f2f9f73d35f340 to your computer and use it in GitHub Desktop.
def lookup_xml_response(*args, **kwargs):
print args # returning (), which makes sense, because of how it's getting called on #15
m = Mock()
m.status_code = 200
m.text = '< .... />' // Do the stuff to determine what response to send back based on args/kwargs
return m
class MyTestCase(TestCase):
def setUp(self):
self.api = MyApi()
self.maxDiff = None
@patch('requests.post')
def test_search(self, requests_mock):
requests_mock.side_effect = lookup_xml_response
self.api.search('tasty things')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment