Add test to illustrate GH-295

This commit is contained in:
Matthew Dapena-Tretter 2014-09-26 20:42:53 -04:00
parent 002b5bdac8
commit 8d35dad5fc

View file

@ -0,0 +1,16 @@
from nose.tools import assert_false
from mock import Mock, PropertyMock, patch
from .models import Photo
def test_dont_access_source():
"""
Touching the source may trigger an unneeded query.
See <https://github.com/matthewwithanm/django-imagekit/issues/295>
"""
pmock = PropertyMock()
pmock.__get__ = Mock()
with patch.object(Photo, 'original_image', pmock):
photo = Photo() # noqa
assert_false(pmock.__get__.called)