-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #894 from girder/copy-styled-tilesource-class
Copy tilesource instances to add styles
- Loading branch information
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
import large_image | ||
from large_image.cache_util import cachesClear | ||
|
||
from .datastore import datastore | ||
|
||
|
||
@pytest.mark.singular | ||
def testCacheSourceStyle(): | ||
cachesClear() | ||
imagePath = datastore.fetch('sample_image.ptif') | ||
ts1 = large_image.open(imagePath) | ||
ts2 = large_image.open(imagePath, style={'max': 128}) | ||
ts3 = large_image.open(imagePath, style={'max': 160}) | ||
tile1 = ts1.getTile(0, 0, 4) | ||
assert ts1.getTile(0, 0, 4) is not None | ||
assert ts2.getTile(0, 0, 4) is not None | ||
assert ts3.getTile(0, 0, 4) is not None | ||
cachesClear() | ||
assert ts1.getTile(0, 0, 4) == tile1 | ||
del ts1 | ||
assert ts2.getTile(1, 0, 4) is not None | ||
cachesClear() | ||
assert ts2.getTile(2, 0, 4) is not None | ||
ts1 = large_image.open(imagePath) | ||
assert ts1.getTile(0, 0, 4) == tile1 | ||
|
||
|
||
@pytest.mark.singular | ||
def testCacheSourceStyleFirst(): | ||
cachesClear() | ||
imagePath = datastore.fetch('sample_image.ptif') | ||
ts2 = large_image.open(imagePath, style={'max': 128}) | ||
ts1 = large_image.open(imagePath) | ||
tile1 = ts1.getTile(0, 0, 4) | ||
assert ts1.getTile(0, 0, 4) is not None | ||
assert ts2.getTile(0, 0, 4) is not None | ||
del ts1 | ||
assert ts2.getTile(1, 0, 4) is not None | ||
cachesClear() | ||
assert ts2.getTile(2, 0, 4) is not None | ||
ts1 = large_image.open(imagePath) | ||
assert ts1.getTile(0, 0, 4) == tile1 |