annotate tests/browser/unit/test_calls.py @ 1612:ebd538cb26cb

server, pages (files/view): use new `use_local_shared_tmp` option.
author Goffi <goffi@goffi.org>
date Wed, 12 Jun 2024 23:11:08 +0200
parents 00d04f51787e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1551
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia Web
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 import sys
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 import pytest
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from unittest.mock import MagicMock, AsyncMock
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
22
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 # Mock all non-stdlib modules
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 class CancelError(Exception):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 pass
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 sys.modules["bridge"] = MagicMock(AsyncBridge=AsyncMock)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 browser = sys.modules["browser"] = MagicMock(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 aio=MagicMock(), console=MagicMock(), document=MagicMock(), window=MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 sys.modules["cache"] = MagicMock(cache=MagicMock())
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 dialog = sys.modules["dialog"] = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 dialog.CancelError = CancelError
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 confirm_mock = dialog.Confirm.return_value = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 confirm_ashow = confirm_mock.ashow = AsyncMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 sys.modules["jid"] = MagicMock(JID=MagicMock)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 sys.modules["jid_search"] = MagicMock(JidSearch=MagicMock())
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 sys.modules["loading"] = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 sys.modules["template"] = MagicMock(Template=MagicMock())
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 sys.modules["webrtc"] = MagicMock(WebRTC=MagicMock())
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 # After mocking the modules, import the actual module
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 from libervia.web.pages.calls import _browser as calls
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 calls.cache.fill_identities = AsyncMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
50
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 class TestCallUI:
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 @pytest.fixture
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def call_ui(self):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 ui = calls.CallUI()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 ui.webrtc.sid = None
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 ui.call_status_tpl = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 ui.call_status_wrapper_elt = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 ui.call_box_elt = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 ui._update_call_button = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 ui.audio_player_elt = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 ui.switch_mode = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 ui.incoming_call_dialog_elt = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
63
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 ui.call_status_wrapper_elt.appended_elements = []
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 # Mock the `<=` operator for call_status_wrapper_elt
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 def mock_append_child(parent, child):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 # Store the child for later assertion
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 parent.appended_elements.append(child)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 return child
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
71
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 ui.call_status_wrapper_elt.__le__ = mock_append_child
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
73
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 return ui
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
75
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 def test_status(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 """Allowed values are set"""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 # Set initial status
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 call_ui._status = None
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 assert call_ui.status == None
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
81
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 # Change status
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 call_ui.status = "dialing"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 assert call_ui.status == "dialing"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
85
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 def test_disallowed_status(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 """Not allowed status raises an Exception"""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 with pytest.raises(Exception, match="this status is not allowed"):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 call_ui.status = "disallowed_status"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
90
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 def test_status_element_update(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 """A status change update the status element"""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 call_ui._callee = "test_callee"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 mock_cache = calls.cache
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 mock_cache.identities = {"test_callee": {"nicknames": ["Test Callee Nickname"]}}
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
96
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 status_elt_mock = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 call_ui.call_status_tpl.get_elt.return_value = status_elt_mock
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
99
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 call_ui.status = "dialing"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 call_ui.call_status_tpl.get_elt.assert_called_with(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 "entity": "test_callee",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 "status": "dialing",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 "name": "Test Callee Nickname",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 }
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 assert call_ui.call_status_wrapper_elt.appended_elements[-1] == status_elt_mock
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 def test_status_element_updates_with_unknown_callee(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 """A status change update the element even if callee is not known"""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 call_ui._callee = "test_callee"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 mock_cache = calls.cache
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 mock_cache.identities = {}
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
115
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 call_ui.status = "dialing"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 call_ui.call_status_tpl.get_elt.assert_called_with(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 {"entity": "test_callee", "status": "dialing", "name": "test_callee"}
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
120
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 def test_call_mode(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 call_ui.call_mode = calls.AUDIO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 assert call_ui.call_mode == calls.AUDIO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 call_ui._update_call_button.assert_called_once()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 call_ui.call_box_elt.select.assert_called_with(".is-video-only")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
126
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 call_ui.call_mode = calls.VIDEO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 assert call_ui.call_mode == calls.VIDEO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 call_ui.call_box_elt.select.assert_called_with(".is-video-only")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 def test_call_mode_invalid_mode(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 with pytest.raises(ValueError, match="Invalid call mode"):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 call_ui.call_mode = "invalid_mode"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
134
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 def test_switch_call_mode(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 call_ui._call_mode = calls.AUDIO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 call_ui.switch_call_mode(None)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 assert call_ui.call_mode == calls.VIDEO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
139
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 call_ui._call_mode = calls.VIDEO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 call_ui.switch_call_mode(None)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 assert call_ui.call_mode == calls.AUDIO
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
143
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 @pytest.mark.asyncio
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 async def test_ignore_new_call_when_call_in_progress(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 """Ignoring new incoming call when a call is already in progress."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 call_ui.sid = "some_sid"
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 await call_ui.on_action_new(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 "from_jid": "test@example.org",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 "session_id": "session123",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 "sub_type": "audio",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 },
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 "action_id",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 call_ui.audio_player_elt.play.assert_not_called()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
157
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 @pytest.mark.asyncio
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 async def test_action_new_fill_identities(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 """Filling identities from cache with the correct JID."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 calls.cache.identities = {"test@example.org": {"nicknames": ["Test User"]}}
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
162
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 await call_ui.on_action_new(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 "from_jid": "test@example.org",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 "session_id": "session123",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 "sub_type": "audio",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 },
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 "action_id",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 calls.cache.fill_identities.assert_called_once_with(["test@example.org"])
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
172
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 @pytest.mark.asyncio
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 async def test_incoming_call_triggers_audio(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 """Incoming call triggering the play action on the audio element."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 await call_ui.on_action_new(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 "from_jid": "test@example.org",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 "session_id": "session123",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 "sub_type": "audio",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 },
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 "action_id",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 call_ui.audio_player_elt.play.assert_called_once()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
185
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 @pytest.mark.asyncio
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 async def test_user_accepts_call(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 """User accepting the incoming call."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 confirm_ashow.return_value = True
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 await call_ui.on_action_new(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 "from_jid": "test@example.org",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 "session_id": "session123",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 "sub_type": "video",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 },
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 "action_id",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 call_ui.switch_mode.assert_called_once_with("call")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
199
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
200 @pytest.mark.asyncio
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 async def test_user_rejects_call(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 """User rejecting the incoming call."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 confirm_ashow.return_value = False
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 await call_ui.on_action_new(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 "from_jid": "test@example.org",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 "session_id": "session123",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 "sub_type": "video",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
209 },
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 "action_id",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
212 call_ui.switch_mode.assert_not_called()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
213
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 @pytest.mark.asyncio
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 async def test_call_gets_cancelled(self, call_ui):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 """Incoming call gets cancelled."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
217 confirm_ashow.side_effect = dialog.CancelError
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 await call_ui.on_action_new(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 "from_jid": "test@example.org",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 "session_id": "session123",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 "sub_type": "audio",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 },
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
224 "action_id",
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
225 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
226 assert call_ui.sid is None
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 call_ui.switch_mode.assert_not_called()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
228
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 def test_toggle_fullscreen_enter(self, call_ui, monkeypatch):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 """Entering fullscreen mode for video elements."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
231 monkeypatch.setattr(browser.document, "fullscreenElement", None)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
232 monkeypatch.setattr(call_ui.call_box_elt, "requestFullscreen", MagicMock())
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
233
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
234 btn_mock_show = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
235 monkeypatch.setattr("dialog.notification.show", btn_mock_show)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 btn_mock_add = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
237 btn_mock_remove = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
238
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
239 full_screen_mock = MagicMock(classList=MagicMock(add=btn_mock_add))
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
240 exit_full_screen_mock = MagicMock(classList=MagicMock(remove=btn_mock_remove))
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
241
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
242 mock_document = {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 "full_screen_btn": full_screen_mock,
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
244 "exit_full_screen_btn": exit_full_screen_mock,
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
245 }
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
246
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 getitem_mock = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
248 monkeypatch.setattr(browser.document, "__getitem__", getitem_mock)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
249 getitem_mock.side_effect = mock_document.__getitem__
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
250
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
251 call_ui.toggle_fullscreen(True)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
252
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
253 call_ui.call_box_elt.requestFullscreen.assert_called_once()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
254 btn_mock_add.assert_called_with("is-hidden")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
255 btn_mock_remove.assert_called_with("is-hidden")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
256 btn_mock_show.assert_not_called()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
257
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
258 def test_toggle_fullscreen_exit(self, call_ui, monkeypatch):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
259 """Exiting fullscreen mode for video elements."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
260 # As it's not None, we're in fullscreen
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
261 monkeypatch.setattr(browser.document, "fullscreenElement", "mocked_value")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
262 monkeypatch.setattr(browser.document, "exitFullscreen", MagicMock())
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
263
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
264 btn_mock_show = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
265 monkeypatch.setattr("dialog.notification.show", btn_mock_show)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
266 btn_mock_add = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
267 btn_mock_remove = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
268
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
269 full_screen_mock = MagicMock(classList=MagicMock(remove=btn_mock_remove))
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
270 exit_full_screen_mock = MagicMock(classList=MagicMock(add=btn_mock_add))
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
271
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
272 mock_document = {
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
273 "full_screen_btn": full_screen_mock,
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
274 "exit_full_screen_btn": exit_full_screen_mock,
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
275 }
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
276
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
277 getitem_mock = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
278 monkeypatch.setattr(browser.document, "__getitem__", getitem_mock)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
279 getitem_mock.side_effect = mock_document.__getitem__
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
280
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
281 call_ui.toggle_fullscreen(False)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
282
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
283 browser.document.exitFullscreen.assert_called_once()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
284 btn_mock_add.assert_called_with("is-hidden")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
285 btn_mock_remove.assert_called_with("is-hidden")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
286 btn_mock_show.assert_not_called()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
287
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
288 def test_toggle_audio_mute(self, call_ui, monkeypatch):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 """Toggle audio mute."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
290 mock_toggle_audio_mute = MagicMock(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
291 return_value=True
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
292 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 monkeypatch.setattr(call_ui.webrtc, "toggle_audio_mute", mock_toggle_audio_mute)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
294
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
295 btn_mock_show = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 monkeypatch.setattr("dialog.notification.show", btn_mock_show)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
297
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
298 evt_mock = MagicMock(currentTarget=MagicMock(classList=MagicMock()))
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
299
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 call_ui.toggle_audio_mute(evt_mock)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
301
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
302 mock_toggle_audio_mute.assert_called_once()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 evt_mock.currentTarget.classList.remove.assert_called_with("is-success")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
304 evt_mock.currentTarget.classList.add.assert_called_with("muted", "is-warning")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
305 btn_mock_show.assert_called_once_with("audio is now muted", level="info", delay=2)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
306
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
307 def test_toggle_video_mute(self, call_ui, monkeypatch):
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
308 """Toggle video mute."""
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
309 mock_toggle_video_mute = MagicMock(
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
310 return_value=True
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
311 )
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
312 monkeypatch.setattr(call_ui.webrtc, "toggle_video_mute", mock_toggle_video_mute)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
313
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
314 btn_mock_show = MagicMock()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
315 monkeypatch.setattr("dialog.notification.show", btn_mock_show)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
316
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
317 evt_mock = MagicMock(currentTarget=MagicMock(classList=MagicMock()))
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
318
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
319 call_ui.toggle_video_mute(evt_mock)
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
320
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
321 mock_toggle_video_mute.assert_called_once()
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
322 evt_mock.currentTarget.classList.remove.assert_called_with("is-success")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
323 evt_mock.currentTarget.classList.add.assert_called_with("muted", "is-warning")
00d04f51787e tests: add `calls` unit tests:
Goffi <goffi@goffi.org>
parents:
diff changeset
324 btn_mock_show.assert_called_once_with("video is now muted", level="info", delay=2)