Mercurial > libervia-backend
comparison tests/unit/test_plugin_xep_0167.py @ 4285:f1d0cde61af7
tests (unit): fix tests + black reformatting.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Jul 2024 17:42:53 +0200 |
parents | 716dd791be46 |
children | 9447796408f6 |
comparison
equal
deleted
inserted
replaced
4284:3a550e9a2b55 | 4285:f1d0cde61af7 |
---|---|
23 from pytest import raises | 23 from pytest import raises |
24 from twisted.words.protocols.jabber import jid | 24 from twisted.words.protocols.jabber import jid |
25 | 25 |
26 from libervia.backend.plugins.plugin_xep_0166 import XEP_0166 | 26 from libervia.backend.plugins.plugin_xep_0166 import XEP_0166 |
27 from libervia.backend.plugins.plugin_xep_0167 import XEP_0167, mapping | 27 from libervia.backend.plugins.plugin_xep_0167 import XEP_0167, mapping |
28 from libervia.backend.plugins.plugin_xep_0167.constants import NS_JINGLE_RTP, NS_JINGLE_RTP_INFO | 28 from libervia.backend.plugins.plugin_xep_0167.constants import ( |
29 NS_JINGLE_RTP, | |
30 NS_JINGLE_RTP_INFO, | |
31 ) | |
29 from libervia.backend.tools import xml_tools | 32 from libervia.backend.tools import xml_tools |
30 from libervia.backend.tools.common import data_format | 33 from libervia.backend.tools.common import data_format |
31 | 34 |
32 | 35 |
33 @fixture(autouse=True) | 36 @fixture(autouse=True) |
43 | 46 |
44 def test_senders_to_sdp(self): | 47 def test_senders_to_sdp(self): |
45 """Senders are mapped to SDP attribute""" | 48 """Senders are mapped to SDP attribute""" |
46 assert mapping.senders_to_sdp("both", {"role": "initiator"}) == "a=sendrecv" | 49 assert mapping.senders_to_sdp("both", {"role": "initiator"}) == "a=sendrecv" |
47 assert mapping.senders_to_sdp("none", {"role": "initiator"}) == "a=inactive" | 50 assert mapping.senders_to_sdp("none", {"role": "initiator"}) == "a=inactive" |
48 assert mapping.senders_to_sdp("initiator", {"role": "initiator"}) == "a=sendonly" | 51 assert mapping.senders_to_sdp("initiator", {"role": "initiator"}) == "a=recvonly" |
49 assert mapping.senders_to_sdp("responder", {"role": "initiator"}) == "a=recvonly" | 52 assert mapping.senders_to_sdp("responder", {"role": "initiator"}) == "a=sendonly" |
50 | 53 |
51 def test_generate_sdp_from_session(self): | 54 def test_generate_sdp_from_session(self): |
52 """SDP is correctly generated from session data""" | 55 """SDP is correctly generated from session data""" |
53 session = { | 56 session = { |
54 "local_jid": jid.JID("toto@example.org/test"), | 57 "local_jid": jid.JID("toto@example.org/test"), |
132 "audio": { | 135 "audio": { |
133 "application_data": { | 136 "application_data": { |
134 "media": "audio", | 137 "media": "audio", |
135 "payload_types": { | 138 "payload_types": { |
136 96: { | 139 96: { |
140 "clockrate": 48000, | |
137 "id": 96, | 141 "id": 96, |
138 "name": "opus", | 142 "name": "opus", |
139 "clockrate": 48000, | |
140 "parameters": {"sprop-stereo": "1"}, | 143 "parameters": {"sprop-stereo": "1"}, |
141 } | 144 } |
142 }, | 145 }, |
143 }, | 146 }, |
147 "id": "audio", | |
148 "senders": "both", | |
144 "transport_data": { | 149 "transport_data": { |
150 "candidates": [ | |
151 { | |
152 "address": "10.0.0.1", | |
153 "component_id": 1, | |
154 "foundation": "1", | |
155 "port": 12345, | |
156 "priority": 1, | |
157 "transport": "UDP", | |
158 "type": "host", | |
159 } | |
160 ], | |
145 "port": 9999, | 161 "port": 9999, |
146 "pwd": "pwd", | 162 "pwd": "pwd", |
147 "ufrag": "ufrag", | 163 "ufrag": "ufrag", |
148 "candidates": [ | |
149 { | |
150 "foundation": "1", | |
151 "component_id": 1, | |
152 "transport": "UDP", | |
153 "priority": 1, | |
154 "address": "10.0.0.1", | |
155 "port": 12345, | |
156 "type": "host", | |
157 } | |
158 ], | |
159 }, | 164 }, |
160 "id": "audio", | |
161 }, | 165 }, |
162 "metadata": {}, | 166 "metadata": {}, |
163 } | 167 } |
164 | 168 |
165 assert mapping.parse_sdp(sdp) == expected_session | 169 assert mapping.parse_sdp(sdp, "responder") == expected_session |
166 | 170 |
167 def test_build_description(self): | 171 def test_build_description(self): |
168 """<description> element is generated from media data""" | 172 """<description> element is generated from media data""" |
169 session = {"metadata": {}} | 173 session = {"metadata": {}} |
170 | 174 |