diff tests/unit/test_pubsub-cache.py @ 4285:f1d0cde61af7

tests (unit): fix tests + black reformatting.
author Goffi <goffi@goffi.org>
date Sun, 14 Jul 2024 17:42:53 +0200
parents 4b842c1fb686
children
line wrap: on
line diff
--- a/tests/unit/test_pubsub-cache.py	Sun Jul 14 16:47:45 2024 +0200
+++ b/tests/unit/test_pubsub-cache.py	Sun Jul 14 17:42:53 2024 +0200
@@ -33,7 +33,7 @@
         client.pubsub_client.items = MagicMock(return_value=items_ret)
         host.memory.storage.get_pubsub_node.return_value = None
         pubsub_node = host.memory.storage.set_pubsub_node.return_value = PubsubNode(
-            sync_state = None
+            sync_state=None
         )
         with patch.object(host.plugins["PUBSUB_CACHE"], "cache_node") as cache_node:
             await host.plugins["XEP-0060"].get_items(
@@ -51,15 +51,10 @@
         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,
-                None,
-                "urn:xmpp:microblog:0",
-                extra = {C.KEY_USE_CACHE: False}
+                client, None, "urn:xmpp:microblog:0", extra={C.KEY_USE_CACHE: False}
             )
             assert not cache_node.called
 
@@ -71,9 +66,7 @@
             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,
@@ -82,7 +75,6 @@
                 )
                 assert not cache_node.called
 
-
     @ed
     async def test_no_pubsub_get_when_cache_completed(self, host, client):
         """No pubsub get is emitted when items are fully cached"""
@@ -90,11 +82,10 @@
         items_ret.callback(([], {}))
         client.pubsub_client.items = MagicMock(return_value=items_ret)
         host.memory.storage.get_pubsub_node.return_value = PubsubNode(
-            sync_state = SyncState.COMPLETED
+            sync_state=SyncState.COMPLETED
         )
         with patch.object(
-            host.plugins["PUBSUB_CACHE"],
-            "get_items_from_cache"
+            host.plugins["PUBSUB_CACHE"], "get_items_from_cache"
         ) as get_items_from_cache:
             get_items_from_cache.return_value = ([], {})
             await host.plugins["XEP-0060"].get_items(
@@ -112,13 +103,12 @@
         items_ret.callback(([], {}))
         client.pubsub_client.items = MagicMock(return_value=items_ret)
         host.memory.storage.get_pubsub_node.return_value = PubsubNode(
-            sync_state = SyncState.IN_PROGRESS
+            sync_state=SyncState.IN_PROGRESS
         )
         with patch.object(host.plugins["PUBSUB_CACHE"], "analyse_node") as analyse_node:
             analyse_node.return_value = {"to_sync": True}
             with patch.object(
-                host.plugins["PUBSUB_CACHE"],
-                "get_items_from_cache"
+                host.plugins["PUBSUB_CACHE"], "get_items_from_cache"
             ) as get_items_from_cache:
                 get_items_from_cache.return_value = ([], {})
                 assert client.pubsub_client.items.call_count == 0