def test_raises_when_api_returns_error(self, mocker: MockRequest) -> None: mocker.patch("panel.tasks.subtitles.requests", MockRequest) with pytest.raises(Exception) as exc: _request_from_api(url="throw_error://something") assert "Opensubtitles.org API returned" in str(exc.value)
def test_returns_empty_list_when_text_not_loads_as_json( self, mocker: MockRequest ) -> None: mocker.patch("panel.tasks.subtitles.requests", MockRequest) mocker.patch("panel.tasks.tests.mocks.MockRequest.text", "lalala") assert _request_from_api(url="https://something") == []