File: test_resolve_stream_name.py

package info (click to toggle)
streamlink 8.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,564 kB
  • sloc: python: 51,188; sh: 184; makefile: 152
file content (53 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from __future__ import annotations

from typing import TYPE_CHECKING
from unittest.mock import Mock

import pytest

from streamlink.stream.stream import Stream
from streamlink_cli.main import resolve_stream_name


if TYPE_CHECKING:
    from collections.abc import Mapping


@pytest.fixture(scope="module")
def streams():
    a = Stream(Mock())
    b = Stream(Mock())
    c = Stream(Mock())
    d = Stream(Mock())
    e = Stream(Mock())

    return {
        "160p": a,
        "360p": b,
        "480p": c,
        "720p": d,
        "1080p": e,
        "worst": b,
        "best": d,
        "worst-unfiltered": a,
        "best-unfiltered": e,
    }


@pytest.mark.parametrize(
    ("stream_name", "expected"),
    [
        pytest.param("unknown", "unknown"),
        pytest.param("160p", "160p"),
        pytest.param("360p", "360p"),
        pytest.param("480p", "480p"),
        pytest.param("720p", "720p"),
        pytest.param("1080p", "1080p"),
        pytest.param("worst", "360p"),
        pytest.param("best", "720p"),
        pytest.param("worst-unfiltered", "160p"),
        pytest.param("best-unfiltered", "1080p"),
    ],
)
def test_resolve_stream_name(streams: Mapping[str, Stream], stream_name: str, expected: str):
    assert resolve_stream_name(streams, stream_name) == expected