File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 55
66import pytest
77
8- from cachier .cores .base import _BaseCore
8+ from cachier .cores .base import RecalculationNeeded , _BaseCore
99
1010
1111class ConcreteCachingCore (_BaseCore ):
@@ -143,3 +143,26 @@ async def test_base_core_aset_entry_fallback():
143143
144144 assert result is True
145145 assert core .last_set == (key , 99 )
146+
147+
148+ def test_base_core_size_hooks_default_to_zero ():
149+ """Base metric hooks should return zero when a backend does not override them."""
150+ core = ConcreteCachingCore (hash_func = None , wait_for_calc_timeout = None )
151+
152+ assert core ._get_entry_count () == 0
153+ assert core ._get_total_size () == 0
154+
155+
156+ def test_check_calc_timeout_raises_recalculation_needed ():
157+ """check_calc_timeout should raise when elapsed time reaches the configured timeout."""
158+ core = ConcreteCachingCore (hash_func = None , wait_for_calc_timeout = 2 )
159+
160+ with pytest .raises (RecalculationNeeded ):
161+ core .check_calc_timeout (2 )
162+
163+
164+ def test_check_calc_timeout_does_not_raise_before_timeout ():
165+ """check_calc_timeout should not raise before the configured timeout."""
166+ core = ConcreteCachingCore (hash_func = None , wait_for_calc_timeout = 2 )
167+
168+ core .check_calc_timeout (1 )
You can’t perform that action at this time.
0 commit comments