# HG changeset patch # User Goffi # Date 1661958423 -7200 # Node ID c129234a5d0b2c0cdd93c5d2c748503e119954e0 # Parent 1ab5fb468a4163f09113401de6b8353be8edd88d tests (AP gateway): fix tests following changes in gateway: - `shareInbox` is now used when available, thus tests now check for that - `client._ap_storage` is used, thus is added to the mockClient `ap_const.NS_AP_PUBLIC` is now in `cc` instead of `to` field rel 371 diff -r 1ab5fb468a41 -r c129234a5d0b tests/unit/test_ap-gateway.py --- a/tests/unit/test_ap-gateway.py Wed Aug 31 17:07:03 2022 +0200 +++ b/tests/unit/test_ap-gateway.py Wed Aug 31 17:07:03 2022 +0200 @@ -412,12 +412,19 @@ return fake_cached_node -def getVirtualClient(jid): +def mockClient(jid): client = MagicMock() client.jid = jid + client.host = "test.example" + client._ap_storage.get = AsyncMock() + client._ap_storage.aset = AsyncMock() return client +def getVirtualClient(jid): + return mockClient(jid) + + class FakeTReqPostResponse: code = 202 @@ -428,9 +435,7 @@ gateway.initialised = True gateway.isPubsub = AsyncMock() gateway.isPubsub.return_value = False - client = MagicMock() - client.jid = jid.JID("ap.test.example") - client.host = "test.example" + client = mockClient(jid.JID("ap.test.example")) client.getVirtualClient = getVirtualClient gateway.client = client gateway.local_only = True @@ -967,7 +972,7 @@ url, actor_id, doc = signAndPost.call_args[0] jid_account = await ap_gateway.getAPAccountFromJidAndNode(TEST_JID, None) jid_actor_id = ap_gateway.buildAPURL(ap_const.TYPE_ACTOR, jid_account) - assert url == f"{TEST_BASE_URL}/users/{TEST_USER}/inbox" + assert url == f"{TEST_BASE_URL}/inbox" assert actor_id == jid_actor_id assert doc["type"] == "Delete" assert doc["actor"] == jid_actor_id @@ -1424,7 +1429,7 @@ assert signAndPost.called url, actor_id, doc = signAndPost.call_args.args - assert url == TEST_USER_DATA["inbox"] + assert url == TEST_USER_DATA["endpoints"]["sharedInbox"] assert actor_id == ap_gateway.buildAPURL(ap_const.TYPE_ACTOR, TEST_JID.userhost()) assert doc["type"] == "Announce" assert ap_const.NS_AP_PUBLIC in doc["to"] @@ -1498,12 +1503,6 @@ recipient_jid = ap_gateway.getLocalJIDFromAccount(TEST_AP_ACCOUNT) # noticed item ap_item = TEST_AP_ITEMS[0] - ap_item_url = xmpp_uri.buildXMPPUri( - "pubsub", - path=recipient_jid.full(), - node=ap_gateway._m.namespace, - item=ap_item["id"] - ) attachment_node = ap_gateway._pa.getAttachmentNodeName( recipient_jid, ap_gateway._m.namespace, @@ -1511,7 +1510,7 @@ ) item_elt = xml_tools.parse(f""" - + @@ -1534,10 +1533,10 @@ assert signAndPost.called url, actor_id, doc = signAndPost.call_args.args - assert url == TEST_USER_DATA["inbox"] + assert url == TEST_USER_DATA["endpoints"]["sharedInbox"] assert actor_id == ap_gateway.buildAPURL(ap_const.TYPE_ACTOR, TEST_JID.userhost()) assert doc["type"] == "Like" - assert ap_const.NS_AP_PUBLIC in doc["to"] + assert ap_const.NS_AP_PUBLIC in doc["cc"] assert doc["object"] == ap_item["id"] @ed