From 7c609188df1ef457440543beb9dc4dbf286abd87 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 4 Aug 2022 16:08:05 -0400 Subject: [PATCH] Add some source cache tests. --- test/test_cache_source.py | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/test_cache_source.py diff --git a/test/test_cache_source.py b/test/test_cache_source.py new file mode 100644 index 000000000..e268709f5 --- /dev/null +++ b/test/test_cache_source.py @@ -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