Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Created March 4, 2014 03:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmycuadra/9339727 to your computer and use it in GitHub Desktop.
Save jimmycuadra/9339727 to your computer and use it in GitHub Desktop.
from mock import patch
@patch('path.to.module.S3Library')
def test_stores_data_in_s3(S3Library):
my_method(data)
assert S3Library.upload_file.called_once_with(data)
@patch('path.to.module.S3Library')
def test_data_contains_some_value(S3Library):
S3Library.get_file.return_value = _stub_data()
xml_file = S3Library.get_file('filename')
data = XMLParser.parse(xml_file)
assert data.value == 'something'
def _stub_data():
return FakeXMLObject()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment