tests (unit): fix tests
This commit is contained in:
parent
a8348576ae
commit
039a9b5830
5 changed files with 15 additions and 12 deletions
|
|
@ -20,7 +20,7 @@ from unittest.mock import MagicMock, patch
|
|||
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 qapplication():
|
|||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ from libervia.backend.plugins.plugin_comp_ap_gateway import constants as ap_cons
|
|||
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 @@ class TestActivityPubGateway:
|
|||
# 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 @@ class TestActivityPubGateway:
|
|||
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 @@ class TestActivityPubGateway:
|
|||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -94,11 +94,12 @@ class TestXEP0167Mapping:
|
|||
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"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class TestXEP0176:
|
|||
def create_mock_session(self, content_name):
|
||||
return {
|
||||
"id": "test-session-id",
|
||||
"state": XEP_0166.STATE_ACTIVE,
|
||||
"contents": {
|
||||
content_name: {
|
||||
"application_data": {"media": "audio"},
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ class TestXEP0338:
|
|||
xep_0338 = XEP_0338(host)
|
||||
|
||||
session = {
|
||||
"contents": {"audio": {}},
|
||||
"jingle_elt": domish.Element((None, "jingle")),
|
||||
"metadata": {"group": {"BUNDLE": ["audio", "video"]}},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue