diff tests/unit/frontends/test_webrtc.py @ 4232:0fbe5c605eb6

tests (unit/webrtc,XEP-0176, XEP-0234): Fix tests and add webrtc file transfer tests: fix 441
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 12:59:50 +0200
parents dfccc90cacc6
children
line wrap: on
line diff
--- a/tests/unit/frontends/test_webrtc.py	Sat Apr 06 12:57:23 2024 +0200
+++ b/tests/unit/frontends/test_webrtc.py	Sat Apr 06 12:59:50 2024 +0200
@@ -162,11 +162,14 @@
         mock_pipeline.add.assert_called()
         mock_pad.link.assert_called()
 
-    @pytest.mark.skipif(Gst is None)
+    @pytest.mark.skipif(Gst is None, reason="GStreamer is not available")
     @pytest.mark.asyncio
     async def test_setup_call_correct_role(self, host, webrtc, monkeypatch):
         """Roles are set in setup_call."""
         monkeypatch.setattr(Gst, "parse_launch", MagicMock())
+        # we use MagicMock class and not instance on purpose, to pass the "isinstance"
+        # test of "setup_call".
+        monkeypatch.setattr(Gst, "Pipeline", MagicMock)
         monkeypatch.setattr(data_format, "deserialise", MagicMock(return_value=[]))
 
         await webrtc.setup_call("initiator")
@@ -196,13 +199,16 @@
         assert "v4l2src" in webrtc.gst_pipe_desc
         assert "pulsesrc" in webrtc.gst_pipe_desc
 
-    @pytest.mark.skipif(Gst is None)
+    @pytest.mark.skipif(Gst is None, reason="GStreamer is not available")
     @pytest.mark.asyncio
     async def test_setup_call_with_stun_and_turn(self, host, webrtc, monkeypatch):
         """STUN and TURN server configurations are done in setup_call."""
         mock_pipeline = MagicMock()
         mock_parse_launch = MagicMock()
         mock_parse_launch.return_value = mock_pipeline
+        # As for "test_setup_call_correct_role" we user MagicMock class and not instance
+        # on purpose here.
+        monkeypatch.setattr(Gst, "Pipeline", MagicMock)
         monkeypatch.setattr(Gst, "parse_launch", mock_parse_launch)
 
         mock_pipeline.get_by_name.return_value = webrtc.webrtcbin
@@ -237,7 +243,7 @@
             "add-turn-server", "turn://user:pass@turn.host:3478"
         )
 
-    @pytest.mark.skipif(Gst is None)
+    @pytest.mark.skipif(Gst is None, reason="GStreamer is not available")
     @pytest.mark.asyncio
     async def test_setup_call_gstreamer_pipeline_failure(self, webrtc, monkeypatch):
         """Test setup_call method handling Gstreamer pipeline failure."""