init: zero-dep dns-over-https resolver
This commit is contained in:
commit
7348f9b0dd
18 changed files with 589 additions and 0 deletions
29
tests/test_cache.py
Normal file
29
tests/test_cache.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import time
|
||||
|
||||
from pydoh.cache import TTLCache
|
||||
|
||||
|
||||
def test_cache_hit():
|
||||
cache = TTLCache()
|
||||
cache.set("k", ["1.2.3.4"], ttl=60)
|
||||
assert cache.get("k") == ["1.2.3.4"]
|
||||
|
||||
|
||||
def test_cache_expires():
|
||||
cache = TTLCache()
|
||||
cache.set("k", ["1.2.3.4"], ttl=0.05)
|
||||
assert cache.get("k") == ["1.2.3.4"]
|
||||
time.sleep(0.1)
|
||||
assert cache.get("k") is None
|
||||
|
||||
|
||||
def test_cache_clear():
|
||||
cache = TTLCache()
|
||||
cache.set("k", ["1.2.3.4"], ttl=60)
|
||||
cache.clear()
|
||||
assert cache.get("k") is None
|
||||
|
||||
|
||||
def test_cache_miss():
|
||||
cache = TTLCache()
|
||||
assert cache.get("missing") is None
|
||||
Loading…
Add table
Add a link
Reference in a new issue