Skip to content

Commit

Permalink
Add some source cache tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Aug 4, 2022
1 parent f8c0323 commit 7c60918
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/test_cache_source.py
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

0 comments on commit 7c60918

Please sign in to comment.