mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-17 05:40:25 +00:00
Add test to illustrate GH-295
This commit is contained in:
parent
002b5bdac8
commit
8d35dad5fc
1 changed files with 16 additions and 0 deletions
16
tests/test_no_extra_queries.py
Normal file
16
tests/test_no_extra_queries.py
Normal 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)
|
||||
Loading…
Reference in a new issue