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:
parent
31a6383b5e
commit
416499bc30
1 changed files with 15 additions and 0 deletions
15
tests/unit/domains/databus/test_cache.py
Normal file
15
tests/unit/domains/databus/test_cache.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue