django-imagekit/tests/test_no_extra_queries.py

17 lines
474 B
Python
Raw Permalink Normal View History

2014-09-27 00:42:53 +00:00
from nose.tools import assert_false
from unittest.mock import Mock, PropertyMock, patch
2014-09-27 00:42:53 +00:00
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)