File: test_streamlink_api.py

package info (click to toggle)
streamlink 7.3.0-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 5,584 kB
  • sloc: python: 49,172; sh: 184; makefile: 145
file content (35 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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.plugins.load_path(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