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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from streamlink.options import Options
from streamlink.plugins.soop import Soop
from tests.plugins import PluginCanHandleUrl
if TYPE_CHECKING:
from streamlink.session import Streamlink
class TestPluginCanHandleUrlSoop(PluginCanHandleUrl):
__plugin__ = Soop
should_match_groups = [
("https://play.sooplive.co.kr/CHANNEL", {"channel": "CHANNEL"}),
("https://play.sooplive.co.kr/CHANNEL/0123456789", {"channel": "CHANNEL", "bno": "0123456789"}),
("https://play.afreecatv.com/CHANNEL", {"channel": "CHANNEL"}),
("https://play.afreecatv.com/CHANNEL/0123456789", {"channel": "CHANNEL", "bno": "0123456789"}),
]
should_not_match = [
"https://sooplive.co.kr/CHANNEL",
"https://sooplive.co.kr/CHANNEL/0123456789",
"https://afreecatv.com/CHANNEL",
"https://afreecatv.com/CHANNEL/0123456789",
]
@pytest.mark.parametrize(
("plugin_options", "expected"),
[
pytest.param(
{"username": "username", "password": "password", "purge-credentials": True, "stream-password": "foo"},
{"username": "username", "password": "password", "purge-credentials": True, "stream-password": "foo"},
id="regular-options",
),
pytest.param(
{
"afreeca-username": "username",
"afreeca-password": "password",
"afreeca-purge-credentials": True,
"afreeca-stream-password": "foo",
},
{
"username": "username",
"password": "password",
"purge-credentials": True,
"stream-password": "foo",
"afreeca-username": "username",
"afreeca-password": "password",
"afreeca-purge-credentials": True,
"afreeca-stream-password": "foo",
},
id="deprecated-options",
),
pytest.param(
{
"username": "username1",
"password": "password1",
"purge-credentials": True,
"stream-password": "foo",
"afreeca-username": "username2",
"afreeca-password": "password2",
"afreeca-purge-credentials": False,
"afreeca-stream-password": "bar",
},
{
"username": "username1",
"password": "password1",
"purge-credentials": True,
"stream-password": "foo",
"afreeca-username": "username2",
"afreeca-password": "password2",
"afreeca-purge-credentials": False,
"afreeca-stream-password": "bar",
},
id="regular-and-deprecated-options",
),
],
)
def test_options(session: Streamlink, plugin_options: dict, expected: dict):
options = Options()
options.update(plugin_options)
plugin = Soop(session, "https://play.sooplive.co.kr/CHANNEL/0123456789", options)
assert dict(plugin.options.items()) == expected
|