tests (unit): Fix tests.

This commit is contained in:
Goffi 2025-12-03 17:43:06 +01:00
commit e68278a1ac

View file

@ -24,7 +24,6 @@ from libervia.backend.core.constants import Const as C
class TestPubsubCache:
@ed
async def test_cache_is_used_transparently(self, host, client):
"""Cache is used when a pubsub get_items operation is done"""
@ -61,12 +60,16 @@ class TestPubsubCache:
@ed
async def test_cache_is_not_used_when_no_cache(self, host, client):
"""Cache is skipped when 'pubsub_cache_strategy' is set to 'no_cache'"""
with host.use_option_and_reload(None, "pubsub_cache_strategy", "no_cache"):
with patch("libervia.backend.plugins.plugin_pubsub_cache.G") as mock_G:
mock_G.config.common.pubsub_cache_strategy = "no_cache"
items_ret = defer.Deferred()
items_ret.callback(([], {}))
client.pubsub_client.items = MagicMock(return_value=items_ret)
host.memory.storage.get_pubsub_node.return_value = None
host.memory.storage.set_pubsub_node.return_value = PubsubNode(sync_state=None)
host.memory.storage.set_pubsub_node.return_value = PubsubNode(
sync_state=None
)
with patch.object(host.plugins["PUBSUB_CACHE"], "cache_node") as cache_node:
await host.plugins["XEP-0060"].get_items(
client,