Mock requests

This commit is contained in:
Nick Mowen 2022-10-21 14:58:19 -06:00
parent d1d9711123
commit bf24b827e4

View File

@ -1,6 +1,7 @@
"""Test restream.py.""" """Test restream.py."""
from unittest import TestCase, main from unittest import TestCase, main
from unittest.mock import patch
from frigate.config import FrigateConfig from frigate.config import FrigateConfig
from frigate.restream import RestreamApi from frigate.restream import RestreamApi
@ -42,14 +43,16 @@ class TestRestream(TestCase):
}, },
} }
def test_rtsp_stream(self) -> None: @patch("frigate.restream.requests")
def test_rtsp_stream(self, mock_requests) -> None:
"""Test that the normal rtsp stream is sent plainly.""" """Test that the normal rtsp stream is sent plainly."""
frigate_config = FrigateConfig(**self.config) frigate_config = FrigateConfig(**self.config)
restream = RestreamApi(frigate_config) restream = RestreamApi(frigate_config)
restream.add_cameras() restream.add_cameras()
assert restream.relays["back"].startswith("rtsp") assert restream.relays["back"].startswith("rtsp")
def test_http_stream(self) -> None: @patch("frigate.restream.requests")
def test_http_stream(self, mock_requests) -> None:
"""Test that the http stream is sent via ffmpeg.""" """Test that the http stream is sent via ffmpeg."""
frigate_config = FrigateConfig(**self.config) frigate_config = FrigateConfig(**self.config)
restream = RestreamApi(frigate_config) restream = RestreamApi(frigate_config)