changeset 4213:716dd791be46

tests (unit): fix tests
author Goffi <goffi@goffi.org>
date Fri, 23 Feb 2024 15:42:02 +0100
parents 5f2d496c633f
children 07439bc0ed3c
files tests/unit/cli/test_calls.py tests/unit/test_ap-gateway.py tests/unit/test_plugin_xep_0167.py tests/unit/test_plugin_xep_0176.py tests/unit/test_plugin_xep_0338.py
diffstat 5 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/tests/unit/cli/test_calls.py	Fri Feb 23 13:31:04 2024 +0100
+++ b/tests/unit/cli/test_calls.py	Fri Feb 23 15:42:02 2024 +0100
@@ -20,7 +20,7 @@
 from PyQt6.QtWidgets import QApplication
 import pytest
 
-from libervia.cli.call_gui import AVCallGUI
+from libervia.cli.call_gui import AVCallUI
 from libervia.frontends.tools import display_servers
 
 
@@ -34,7 +34,7 @@
 def av_call_gui(qapplication):
     host = MagicMock()
     icons_path = MagicMock()
-    gui = AVCallGUI(host, icons_path)
+    gui = AVCallUI(host, icons_path)
     gui.webrtc_call = MagicMock()
     return gui
 
--- 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
 
--- a/tests/unit/test_plugin_xep_0167.py	Fri Feb 23 13:31:04 2024 +0100
+++ b/tests/unit/test_plugin_xep_0167.py	Fri Feb 23 15:42:02 2024 +0100
@@ -94,11 +94,12 @@
             f"o={base64.b64encode('toto@example.org/test'.encode()).decode()} 1 1 IN IP4 0.0.0.0\r\n"
             "s=-\r\n"
             "t=0 0\r\n"
-            "a=sendrecv\r\n"
             "a=msid-semantic:WMS *\r\n"
-            "m=audio 9999 UDP/TLS/RTP/SAVPF 96\r\n"
+            "a=ice-options:trickle\r\n"
+            "m=audio 9 UDP/TLS/RTP/SAVPF 96\r\n"
             "c=IN IP4 0.0.0.0\r\n"
             "a=mid:audio\r\n"
+            "a=sendrecv\r\n"
             "a=rtpmap:96 opus/48000\r\n"
             "a=fmtp:96 sprop-stereo=1\r\n"
             "a=ice-ufrag:ufrag\r\n"
--- a/tests/unit/test_plugin_xep_0176.py	Fri Feb 23 13:31:04 2024 +0100
+++ b/tests/unit/test_plugin_xep_0176.py	Fri Feb 23 15:42:02 2024 +0100
@@ -36,6 +36,7 @@
     def create_mock_session(self, content_name):
         return {
             "id": "test-session-id",
+            "state": XEP_0166.STATE_ACTIVE,
             "contents": {
                 content_name: {
                     "application_data": {"media": "audio"},
--- a/tests/unit/test_plugin_xep_0338.py	Fri Feb 23 13:31:04 2024 +0100
+++ b/tests/unit/test_plugin_xep_0338.py	Fri Feb 23 15:42:02 2024 +0100
@@ -67,6 +67,7 @@
         xep_0338 = XEP_0338(host)
 
         session = {
+            "contents": {"audio": {}},
             "jingle_elt": domish.Element((None, "jingle")),
             "metadata": {"group": {"BUNDLE": ["audio", "video"]}},
         }