1
mirror of https://github.com/streamlink/streamlink synced 2024-09-27 11:10:27 +02:00
streamlink/tests/test_streamlink_api.py
bastimeyer 745791cf21 tests: refactor Streamlink API tests
Rewrite using pytest
2023-05-24 09:40:27 -07:00

36 lines
1.2 KiB
Python

import pytest
import tests.plugin
from streamlink import Streamlink
from streamlink.api import streams
class TestStreamlinkAPI:
@pytest.fixture(autouse=True)
def _session(self, monkeypatch: pytest.MonkeyPatch, session: Streamlink):
monkeypatch.setattr("streamlink.api.Streamlink", lambda: session)
session.load_plugins(tests.plugin.__path__[0])
def test_find_test_plugin(self):
assert "hls" in streams("test.se")
def test_no_streams_exception(self):
assert streams("test.se/NoStreamsError") == {}
def test_no_streams(self):
assert streams("test.se/empty") == {}
def test_stream_type_filter(self):
stream_types = ["hls"]
available_streams = streams("test.se", stream_types=stream_types)
assert "hls" in available_streams
assert "test" not in available_streams
assert "http" not in available_streams
def test_stream_type_wildcard(self):
stream_types = ["hls", "*"]
available_streams = streams("test.se", stream_types=stream_types)
assert "hls" in available_streams
assert "test" in available_streams
assert "http" in available_streams