test(databus): add unit tests for cache key extraction and singleton

2 tests covering _extract_data_type parsing and get_cache() singleton pattern.
This commit is contained in:
Crypto Rug Munch 2026-07-08 05:17:08 +02:00
parent 31a6383b5e
commit 416499bc30

View file

@ -0,0 +1,15 @@
from app.domains.databus.cache import get_cache
def test_extract_data_type():
c = get_cache()
assert c._extract_data_type("source:token_price:abc123") == "token_price"
assert c._extract_data_type("databus:news:xyz") == "news"
assert c._extract_data_type("nodelimiter") == "default"
assert c._extract_data_type("single:") == ""
def test_get_cache_is_singleton():
c1 = get_cache()
c2 = get_cache()
assert c1 is c2