def subject(self, **params): with requests_mock.Mocker() as mock: mock.get("https://api.twitch.tv/kraken/users?login=foo", json={"users": [{ "_id": 1234 }]}) mock.get( "https://api.twitch.tv/kraken/streams/1234", json={"stream": None} if params.pop("offline", False) else { "stream": { "stream_type": params.pop("stream_type", "live"), "broadcast_platform": params.pop("broadcast_platform", "live"), "channel": { "broadcaster_software": params.pop("broadcaster_software", "") } } }) session = Streamlink() Twitch.bind(session, "tests.plugins.test_twitch") plugin = Twitch("https://www.twitch.tv/foo") plugin.options.set("disable-reruns", params.pop("disable", True)) return plugin._check_for_rerun()
def subject(self, **params): with patch("streamlink.plugins.twitch.TwitchAPI.stream_metadata") as mock: mock.return_value = None if params.pop("offline", False) else {"type": params.pop("stream_type", "live")} session = Streamlink() Twitch.bind(session, "tests.plugins.test_twitch") plugin = Twitch("https://www.twitch.tv/foo") plugin.options.set("disable-reruns", params.pop("disable", True)) return plugin._check_for_rerun()