diff tests/unit/test_ap-gateway.py @ 4285:f1d0cde61af7 default tip @

tests (unit): fix tests + black reformatting.
author Goffi <goffi@goffi.org>
date Sun, 14 Jul 2024 17:42:53 +0200
parents 49019947cc76
children
line wrap: on
line diff
--- a/tests/unit/test_ap-gateway.py	Sun Jul 14 16:47:45 2024 +0200
+++ b/tests/unit/test_ap-gateway.py	Sun Jul 14 17:42:53 2024 +0200
@@ -718,8 +718,7 @@
             first_item["id"] == "https://test.example/_ap/item/some_user@test.example/4"
         )
         assert (
-            first_item["actor"]
-            == "https://test.example/_ap/actor/some_user@test.example"
+            first_item["actor"] == "https://test.example/_ap/actor/some_user@test.example"
         )
         assert first_item["type"] == "Create"
         first_item_obj = first_item["object"]
@@ -803,8 +802,7 @@
         )
         assert following["@context"] == ["https://www.w3.org/ns/activitystreams"]
         assert (
-            following["id"]
-            == "https://test.example/_ap/following/some_user@test.example"
+            following["id"] == "https://test.example/_ap/following/some_user@test.example"
         )
         assert following["totalItems"] == len(subscriptions)
         assert following["type"] == "OrderedCollection"
@@ -841,8 +839,7 @@
         )
         assert followers["@context"] == ["https://www.w3.org/ns/activitystreams"]
         assert (
-            followers["id"]
-            == "https://test.example/_ap/followers/some_user@test.example"
+            followers["id"] == "https://test.example/_ap/followers/some_user@test.example"
         )
         assert followers["totalItems"] == len(subscribers)
         assert followers["type"] == "OrderedCollection"
@@ -1398,7 +1395,9 @@
         assert ap_post.called
         url, actor_id, doc = ap_post.call_args.args
         assert url == TEST_USER_DATA["endpoints"]["sharedInbox"]
-        assert actor_id == ap_gateway.build_apurl(ap_const.TYPE_ACTOR, TEST_JID.userhost())
+        assert actor_id == ap_gateway.build_apurl(
+            ap_const.TYPE_ACTOR, TEST_JID.userhost()
+        )
         assert doc["type"] == "Announce"
         assert ap_const.NS_AP_PUBLIC in doc["to"]
         assert doc["object"] == ap_item["id"]
@@ -1434,8 +1433,14 @@
                 ap_gateway.host.memory.storage, "cache_pubsub_items"
             ) as cache_pubsub_items:
                 await ap_gateway.server.resource.handle_announce_activity(
-                    TEST_AP_ACTOR_ID, Request(MagicMock()), announce, None, None, None,
-                    "", TEST_AP_ACTOR_ID
+                    TEST_AP_ACTOR_ID,
+                    Request(MagicMock()),
+                    announce,
+                    None,
+                    None,
+                    None,
+                    "",
+                    TEST_AP_ACTOR_ID,
                 )
 
         assert cache_pubsub_items.called
@@ -1444,7 +1449,10 @@
         extra = mb_data["extra"]
         assert "repeated" in extra
         repeated = extra["repeated"]
-        assert repeated["by"] == ap_gateway.get_local_jid_from_account(TEST_AP_ACCOUNT).full()
+        assert (
+            repeated["by"]
+            == ap_gateway.get_local_jid_from_account(TEST_AP_ACCOUNT).full()
+        )
         xmpp_item_xmpp_url = xmpp_uri.build_xmpp_uri(
             "pubsub",
             path=TEST_JID.full(),
@@ -1487,7 +1495,9 @@
         assert ap_post.called
         url, actor_id, doc = ap_post.call_args.args
         assert url == TEST_USER_DATA["endpoints"]["sharedInbox"]
-        assert actor_id == ap_gateway.build_apurl(ap_const.TYPE_ACTOR, TEST_JID.userhost())
+        assert actor_id == ap_gateway.build_apurl(
+            ap_const.TYPE_ACTOR, TEST_JID.userhost()
+        )
         assert doc["type"] == "Like"
         assert ap_const.NS_AP_PUBLIC in doc["cc"]
         assert doc["object"] == ap_item["id"]
@@ -1748,9 +1758,9 @@
         assert event_data["head-picture"] == {
             "sources": [{"url": "https://example.org/head_picture.jpg"}]
         }
-        assert event_data["descriptions"] ==  [{
-            "description": "<p>meeting for test</p>", "type": "xhtml"
-        }]
+        assert event_data["descriptions"] == [
+            {"description": "<p>meeting for test</p>", "type": "xhtml"}
+        ]
         assert event_data["categories"] == [{"term": "test"}]
         assert event_data["locations"] == [{"description": "somewhere in the world"}]
         assert event_data["rsvp"] == [