Mercurial > libervia-backend
annotate tests/unit/test_plugin_xep_0294.py @ 4290:4837ec911c43
plugin XEP-0176: add debug logs:
rel 447
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 29 Jul 2024 03:31:06 +0200 |
parents | 4b842c1fb686 |
children |
rev | line source |
---|---|
4063
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 # Libervia: an XMPP client |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from twisted.words.xish import domish |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4063
diff
changeset
|
22 from libervia.backend.plugins.plugin_xep_0294 import NS_JINGLE_RTP_HDREXT, XEP_0294 |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4063
diff
changeset
|
23 from libervia.backend.tools.xml_tools import parse |
4063
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 class TestXEP0294: |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 def test_extmap_attribute(self, host): |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 """Session level 'extmap' SDP attribute are set to application_data""" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 xep_0294 = XEP_0294(host) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 call_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 # "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 parts = ["1", "urn:ietf:params:rtp-hdrext:ssrc-audio-level"] |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 # Call the method with application_data as None to make is a session level |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 # attribute |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 xep_0294._parse_sdp_a_trigger("extmap", parts, call_data, {}, "audio", None, {}) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 # Call the method again with application_data set |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 application_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 xep_0294._parse_sdp_a_trigger( |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 "", [], call_data, {}, "audio", application_data, {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 ) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 # Assert data has been correctly transferred |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 assert application_data == { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 "rtp-hdrext": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 "1": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 "id": "1", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 "uri": "urn:ietf:params:rtp-hdrext:ssrc-audio-level", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 "senders": "both", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 } |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 } |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 } |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 def test_extmap_allow_mixed_attribute(self, host): |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 """Session level 'extmap-allow-mixed' SDP attribute are set to application_data""" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 xep_0294 = XEP_0294(host) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 call_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 # Call the method with application_data as None to make is a session level |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 # attribute |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 xep_0294._parse_sdp_a_trigger( |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 "extmap-allow-mixed", [], call_data, {}, "audio", None, {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 ) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 # Call the method again with application_data set |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 application_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 xep_0294._parse_sdp_a_trigger( |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 "", [], call_data, {}, "audio", application_data, {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 ) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 # Assert value has been correctly transferred |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 assert application_data == {"extmap-allow-mixed": True} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 def test_generate_sdp_content(self, host): |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 """SDP for 'extmap' and 'extmap-allow-mixed' attributes is correctly generated""" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 xep_0294 = XEP_0294(host) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 session = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 local = False |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 idx = 0 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 content_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 sdp_lines = [] |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 application_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 app_data_key = "rtp-hdrext" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 media_data = { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 "rtp-hdrext": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 "1": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 "id": "1", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 "uri": "urn:ietf:params:rtp-hdrext:ssrc-audio-level", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 "senders": "both", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 "parameters": {"param1": "value1", "param2": "value2"}, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 "2": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 "id": "2", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 "uri": "urn:ietf:params:rtp-hdrext:time-offset", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 "senders": "initiator", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 "3": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 "id": "3", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 "uri": "urn:ietf:params:rtp-hdrext:toffset", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 "senders": "none", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 "extmap-allow-mixed": True, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 } |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 media = "audio" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 xep_0294._generate_sdp_content_trigger( |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 session, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 local, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 idx, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 content_data, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 sdp_lines, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 application_data, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 app_data_key, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 media_data, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 media, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 ) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 assert sdp_lines == [ |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 "a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:ssrc-audio-level param1=value1 param2=value2", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 "a=extmap:2/sendonly urn:ietf:params:rtp-hdrext:time-offset", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 "a=extmap:3/inactive urn:ietf:params:rtp-hdrext:toffset", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 "a=extmap-allow-mixed", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 ] |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 def test_parse_description(self, host): |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 """'rtp-hdrext' and 'extmap-allow-mixed' elements are correctly parsed""" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 xep_0294 = XEP_0294(host) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 media_data = {} |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 desc_elt_str = """ |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 <description> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 <rtp-hdrext xmlns='urn:xmpp:jingle:apps:rtp:rtp-hdrext:0' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 id='1' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 uri='urn:ietf:params:rtp-hdrext:ssrc-audio-level' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 senders='both'> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 <parameter xmlns='urn:xmpp:jingle:apps:rtp:rtp-hdrext:0' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 name='vad' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 value='on'/> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 </rtp-hdrext> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 <rtp-hdrext xmlns='urn:xmpp:jingle:apps:rtp:rtp-hdrext:0' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 id='2' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 uri='urn:ietf:params:rtp-hdrext:toffset' |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 senders='initiator'/> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 <extmap-allow-mixed xmlns='urn:xmpp:jingle:apps:rtp:rtp-hdrext:0'/> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 </description> |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 """ |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 desc_elt = parse(desc_elt_str) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 xep_0294._parse_description_trigger(desc_elt, media_data) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 assert media_data == { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 "rtp-hdrext": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 "1": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 "id": "1", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 "uri": "urn:ietf:params:rtp-hdrext:ssrc-audio-level", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 "senders": "both", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 "parameters": {"vad": "on"}, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 "2": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 "id": "2", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 "uri": "urn:ietf:params:rtp-hdrext:toffset", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 "senders": "initiator", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 "extmap-allow-mixed": True, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 } |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 def test_build_description(self, host): |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 """'rtp-hdrext' and 'extmap-allow-mixed' elements are correctly built""" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 xep_0294 = XEP_0294(host) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 desc_elt = domish.Element((None, "description")) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 media_data = { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 "rtp-hdrext": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 "1": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 "id": "1", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 "uri": "urn:ietf:params:rtp-hdrext:ssrc-audio-level", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 "senders": "both", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 "parameters": {"vad": "on"}, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 "2": { |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 "id": "2", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 "uri": "urn:ietf:params:rtp-hdrext:toffset", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 "senders": "initiator", |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
191 }, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 "extmap-allow-mixed": True, |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 } |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 xep_0294._build_description_trigger(desc_elt, media_data, {}) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 rtp_hdrext_elts = list(desc_elt.elements(NS_JINGLE_RTP_HDREXT, "rtp-hdrext")) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 assert len(rtp_hdrext_elts) == 2 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 rtp_hdrext_elt1, rtp_hdrext_elt2 = rtp_hdrext_elts |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 assert rtp_hdrext_elt1["id"] == "1" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 assert rtp_hdrext_elt1["uri"] == "urn:ietf:params:rtp-hdrext:ssrc-audio-level" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
205 # both is default and should not be set |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 assert "senders" not in rtp_hdrext_elt1.attributes |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 param_elt1 = list(rtp_hdrext_elt1.elements(NS_JINGLE_RTP_HDREXT, "parameter"))[0] |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
209 assert param_elt1["name"] == "vad" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 assert param_elt1["value"] == "on" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 assert rtp_hdrext_elt2["id"] == "2" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 assert rtp_hdrext_elt2["uri"] == "urn:ietf:params:rtp-hdrext:toffset" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 assert rtp_hdrext_elt2["senders"] == "initiator" |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 extmap_allow_mixed_elts = list( |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 desc_elt.elements(NS_JINGLE_RTP_HDREXT, "extmap-allow-mixed") |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 ) |
e12936318177
tests (units): tests for plugin XEP-0294:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 assert len(extmap_allow_mixed_elts) == 1 |