File: test_nicolive.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 (34 lines) | stat: -rw-r--r-- 1,147 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
import argparse

import pytest

from streamlink.plugins.nicolive import NicoLive
from tests.plugins import PluginCanHandleUrl


class TestPluginCanHandleUrlNicoLive(PluginCanHandleUrl):
    __plugin__ = NicoLive

    should_match = [
        "https://live.nicovideo.jp/watch/lv123",
        "https://live2.nicovideo.jp/watch/lv123",
        "https://live2.nicovideo.jp/watch/lv123?ref=rtrec&zroute=recent",
        "https://live.nicovideo.jp/watch/co456?ref=community",
        "https://live.nicovideo.jp/watch/co456",
        "https://live.nicovideo.jp/watch/user/789",
    ]


class TestNicoLiveArguments:
    @pytest.fixture()
    def parser(self):
        parser = argparse.ArgumentParser()
        for parg in NicoLive.arguments or []:
            parser.add_argument(parg.argument_name("nicolive"), **parg.options)

        return parser

    @pytest.mark.parametrize("timeshift_offset", ["123", "123.45"])
    def test_timeshift_offset(self, parser: argparse.ArgumentParser, timeshift_offset: str):
        parsed = parser.parse_args(["--niconico-timeshift-offset", timeshift_offset])
        assert parsed.niconico_timeshift_offset == 123