diff tests/unit/test_ap-gateway.py @ 4213:716dd791be46

tests (unit): fix tests
author Goffi <goffi@goffi.org>
date Fri, 23 Feb 2024 15:42:02 +0100
parents 4b842c1fb686
children 49019947cc76
line wrap: on
line diff
--- a/tests/unit/test_ap-gateway.py	Fri Feb 23 13:31:04 2024 +0100
+++ b/tests/unit/test_ap-gateway.py	Fri Feb 23 15:42:02 2024 +0100
@@ -42,7 +42,6 @@
 from libervia.backend.plugins.plugin_comp_ap_gateway import TYPE_ACTOR
 from libervia.backend.plugins.plugin_comp_ap_gateway.http_server import HTTPServer
 from libervia.backend.plugins.plugin_xep_0277 import NS_ATOM
-from libervia.backend.plugins.plugin_xep_0422 import NS_FASTEN
 from libervia.backend.plugins.plugin_xep_0424 import NS_MESSAGE_RETRACT
 from libervia.backend.plugins.plugin_xep_0465 import NS_PPS
 from libervia.backend.tools import xml_tools
@@ -1011,15 +1010,16 @@
         # origin ID is the ID of the message to retract
         origin_id = "mess_retract_123"
 
-        # we call retract_by_origin_id to get the message element of a retraction request
+        # we call send_retract to get the message element of a retraction request
         fake_client = MagicMock()
         fake_client.jid = TEST_JID
         dest_jid = ap_gateway.get_local_jid_from_account(TEST_AP_ACCOUNT)
-        ap_gateway._r.retract_by_origin_id(fake_client, dest_jid, origin_id)
+        fake_history = MagicMock()
+        fake_history.type = C.MESS_TYPE_CHAT
+        ap_gateway._r.send_retract(fake_client, dest_jid, origin_id, fake_history)
         # message_retract_elt is the message which would be sent for a retraction
         message_retract_elt = fake_client.send.call_args.args[0]
-        apply_to_elt = next(message_retract_elt.elements(NS_FASTEN, "apply-to"))
-        retract_elt = apply_to_elt.retract
+        retract_elt = next(message_retract_elt.elements(NS_MESSAGE_RETRACT, "retract"))
 
         with patch.object(ap_gateway, "sign_and_post") as sign_and_post:
             sign_and_post.return_value = FakeTReqPostResponse()
@@ -1073,6 +1073,7 @@
         with patch.object(ap_gateway.host.memory.storage, "get") as storage_get:
             fake_history = MagicMock()
             fake_history.source_jid = client.jid
+            fake_history.dest = str(TEST_JID)
             fake_history.dest_jid = TEST_JID
             fake_history.origin_id = ap_item["id"]
             storage_get.return_value = fake_history
@@ -1092,9 +1093,8 @@
         assert sent_elt.name == "message"
         assert sent_elt["from"] == client.jid.full()
         assert sent_elt["to"] == TEST_JID.full()
-        apply_to_elt = next(sent_elt.elements(NS_FASTEN, "apply-to"))
-        assert apply_to_elt["id"] == ap_item["id"]
-        retract_elt = apply_to_elt.retract
+        retract_elt = next(sent_elt.elements(NS_MESSAGE_RETRACT, "retract"))
+        assert retract_elt["id"] == ap_item["id"]
         assert retract_elt is not None
         assert retract_elt.uri == NS_MESSAGE_RETRACT