diff --git a/README.md b/README.md index 0a9fe84..570fdee 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,9 @@ entries = client.get_entries(category_id=456, status=['read', 'unread']) # Update entry title and content client.update_entry(entry_id=1234, title="New title", content="New content") +# Import an entry with a Unix timestamp +client.import_entry(feed_id=123, url="https://example.org/article", published_at=1736200000) + # Update a feed category client.update_feed(123, category_id=456) @@ -136,6 +139,7 @@ The following methods are available on the `miniflux.Client` object: - `flush_history()` - `get_feed_entry(feed_id: int, entry_id: int)` - `get_feed_entries(feed_id: int, **kwargs)` +- `import_entry(feed_id: int, url: str, **kwargs)` - `mark_feed_entries_as_read(feed_id: int)` - `get_entry(entry_id: int)` - `get_entries(**kwargs)` diff --git a/miniflux.py b/miniflux.py index fadba57..ac94fc6 100644 --- a/miniflux.py +++ b/miniflux.py @@ -133,10 +133,14 @@ def __init__( ValueError: If neither `api_key` nor both `username` and `password` are provided. """ if not base_url.startswith(("http://", "https://")): - raise ValueError("base_url must be a valid URL starting with http:// or https://") + raise ValueError( + "base_url must be a valid URL starting with http:// or https://" + ) if not api_key and not (username and password): - raise ValueError("Either api_key or both username and password must be provided") + raise ValueError( + "Either api_key or both username and password must be provided" + ) self._base_url = base_url.rstrip("/") self._timeout = timeout @@ -387,7 +391,9 @@ def get_icon_by_feed_id(self, feed_id: int) -> dict: """ return self.get_feed_icon(feed_id) - def create_feed(self, feed_url: str, category_id: Optional[int] = None, **kwargs) -> int: + def create_feed( + self, feed_url: str, category_id: Optional[int] = None, **kwargs + ) -> int: """ Create a new feed. @@ -537,6 +543,69 @@ def get_feed_entries(self, feed_id: int, **kwargs) -> dict: return response.json() self._handle_error_response(response) + def import_entry( + self, + feed_id: int, + url: str, + title: Optional[str] = None, + author: Optional[str] = None, + content: Optional[str] = None, + published_at: Optional[int] = None, + status: Optional[str] = None, + starred: Optional[bool] = None, + tags: Optional[List[str]] = None, + external_id: Optional[str] = None, + comments_url: Optional[str] = None, + ) -> dict: + """ + Import an entry into the given feed. + + Args: + feed_id (int): The feed ID. + url (str): The entry URL (required by the API). + title (str): The entry title. + author (str): The entry author. + content (str): The entry content. + published_at (int): The publication date as a Unix timestamp. + status (str): The entry status (read, unread or removed). + starred (bool): Whether the entry is starred. + tags (list[str]): Optional list of tags. + external_id (str): Optional external identifier. + comments_url (str): Optional comments URL. + Returns: + dict: The created entry identifier or existing entry identifier. + Raises: + ValueError: If the URL is empty. + ClientError: If the request fails. + """ + if not url: + raise ValueError("url is required") + + endpoint = self._get_endpoint(f"/feeds/{feed_id}/entries/import") + data = self._get_modification_params( + **{ + "url": url, + "title": title, + "author": author, + "content": content, + "published_at": published_at, + "status": status, + "starred": starred, + "tags": tags, + "external_id": external_id, + "comments_url": comments_url, + } + ) + + response = self._session.post( + endpoint, + data=json.dumps(data), + timeout=self._timeout, + ) + if response.status_code in (200, 201): + return response.json() + self._handle_error_response(response) + def mark_feed_entries_as_read(self, feed_id: int) -> None: """ Mark all entries as read in the given feed. @@ -590,7 +659,9 @@ def get_entries(self, **kwargs) -> dict: return response.json() self._handle_error_response(response) - def update_entry(self, entry_id: int, title: Optional[str] = None, content: Optional[str] = None) -> dict: + def update_entry( + self, entry_id: int, title: Optional[str] = None, content: Optional[str] = None + ) -> dict: """ Update an entry. @@ -710,7 +781,9 @@ def get_enclosure(self, enclosure_id: int) -> dict: return response.json() self._handle_error_response(response) - def update_enclosure(self, enclosure_id: int, media_progression: Optional[int] = None) -> bool: + def update_enclosure( + self, enclosure_id: int, media_progression: Optional[int] = None + ) -> bool: """ Update an enclosure. diff --git a/pyproject.toml b/pyproject.toml index 037fa9d..b20fdc6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "miniflux" -version = "1.1.4" +version = "1.1.5" description = "Client library for Miniflux" readme = "README.md" requires-python = ">=3.8" diff --git a/tests/test_client.py b/tests/test_client.py index c85ca5b..afb2bba 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -65,7 +65,9 @@ def test_get_error_with_bad_response(self): def test_base_url_with_trailing_slash(self): session = requests.Session() - expected_result = [{"url": "http://example.org/feed", "title": "Example", "type": "RSS"}] + expected_result = [ + {"url": "http://example.org/feed", "title": "Example", "type": "RSS"} + ] response = mock.Mock() response.status_code = 200 @@ -74,7 +76,9 @@ def test_base_url_with_trailing_slash(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost/", "username", "password", session=session) + client = miniflux.Client( + "http://localhost/", "username", "password", session=session + ) result = client.discover("http://example.org/") session.post.assert_called_once_with( @@ -144,7 +148,9 @@ def test_get_me(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.me() session.get.assert_called_once_with( @@ -163,14 +169,18 @@ def test_get_me_with_server_error(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(ClientError): client.me() def test_discover(self): session = requests.Session() - expected_result = [{"url": "http://example.org/feed", "title": "Example", "type": "RSS"}] + expected_result = [ + {"url": "http://example.org/feed", "title": "Example", "type": "RSS"} + ] response = mock.Mock() response.status_code = 200 @@ -179,7 +189,9 @@ def test_discover(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.discover("http://example.org/") session.post.assert_called_once_with( @@ -198,7 +210,9 @@ def test_discover(self): def test_discover_with_credentials(self): session = requests.Session() - expected_result = [{"url": "http://example.org/feed", "title": "Example", "type": "RSS"}] + expected_result = [ + {"url": "http://example.org/feed", "title": "Example", "type": "RSS"} + ] response = mock.Mock() response.status_code = 200 @@ -207,7 +221,9 @@ def test_discover_with_credentials(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.discover( "http://example.org/", username="foobar", @@ -241,7 +257,9 @@ def test_discover_with_server_error(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(ClientError): client.discover("http://example.org/") @@ -257,7 +275,9 @@ def test_export(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.export() session.get.assert_called_once_with( @@ -277,7 +297,9 @@ def test_import(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) client.import_feeds(input_data) session.post.assert_called_once_with( @@ -297,7 +319,9 @@ def test_import_failure(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(ClientError): client.import_feeds(input_data) @@ -319,7 +343,9 @@ def test_get_feed(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_feed(123) session.get.assert_called_once_with( @@ -344,7 +370,9 @@ def test_get_feed_icon(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_icon_by_feed_id(123) session.get.assert_called_once_with( @@ -369,7 +397,9 @@ def test_get_icon(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_icon(11) session.get.assert_called_once_with( @@ -390,7 +420,9 @@ def test_create_feed(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.create_feed("http://example.org/feed", 123) session.post.assert_called_once_with( @@ -420,7 +452,9 @@ def test_create_feed_with_no_category(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.create_feed("http://example.org/feed") session.post.assert_called_once_with( @@ -450,8 +484,12 @@ def test_create_feed_with_credentials(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) - result = client.create_feed("http://example.org/feed", 123, username="foobar", password="secret") + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) + result = client.create_feed( + "http://example.org/feed", 123, username="foobar", password="secret" + ) session.post.assert_called_once_with( "http://localhost/v1/feeds", @@ -480,7 +518,9 @@ def test_create_feed_with_crawler_enabled(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.create_feed("http://example.org/feed", 123, crawler=True) session.post.assert_called_once_with( @@ -510,8 +550,12 @@ def test_create_feed_with_custom_user_agent_and_crawler_disabled(self): session.post = mock.Mock() session.post.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) - result = client.create_feed("http://example.org/feed", 123, crawler=False, user_agent="GoogleBot") + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) + result = client.create_feed( + "http://example.org/feed", 123, crawler=False, user_agent="GoogleBot" + ) session.post.assert_called_once_with( "http://localhost/v1/feeds", @@ -541,7 +585,9 @@ def test_update_feed(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.update_feed(123, crawler=True, username="test") session.put.assert_called_once_with( @@ -570,7 +616,9 @@ def test_refresh_all_feeds(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.refresh_all_feeds() session.put.assert_called_once_with( @@ -591,7 +639,9 @@ def test_refresh_feed(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.refresh_feed(123) session.put.assert_called_once_with( @@ -612,7 +662,9 @@ def test_refresh_category(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.refresh_category(123) session.put.assert_called_once_with( @@ -633,7 +685,9 @@ def test_get_feed_entry(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_feed_entry(123, 456) session.get.assert_called_once_with( @@ -654,7 +708,9 @@ def test_get_feed_entries(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_feed_entries(123) session.get.assert_called_once_with( @@ -676,7 +732,9 @@ def test_get_feed_entries_with_direction_param(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_feed_entries(123, direction="asc") session.get.assert_called_once_with( @@ -687,6 +745,113 @@ def test_get_feed_entries_with_direction_param(self): assert result == expected_result + def test_import_entry(self): + session = requests.Session() + expected_result = {"id": 1790} + + response = mock.Mock() + response.status_code = 201 + response.json.return_value = expected_result + + session.post = mock.Mock() + session.post.return_value = response + + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) + result = client.import_entry( + 123, + url="http://example.org/article.html", + title="Entry Title", + starred=True, + tags=["tag1", "tag2"], + ) + + session.post.assert_called_once_with( + "http://localhost/v1/feeds/123/entries/import", + data=mock.ANY, + timeout=30, + ) + + _, kwargs = session.post.call_args + payload = json.loads(kwargs.get("data")) + + self.assertEqual(payload.get("url"), "http://example.org/article.html") + self.assertEqual(payload.get("title"), "Entry Title") + self.assertTrue(payload.get("starred")) + self.assertEqual(payload.get("tags"), ["tag1", "tag2"]) + self.assertEqual(result, expected_result) + + def test_import_entry_with_published_at_timestamp(self): + session = requests.Session() + expected_result = {"id": 1790} + published_at = int(time.time()) + + response = mock.Mock() + response.status_code = 201 + response.json.return_value = expected_result + + session.post = mock.Mock() + session.post.return_value = response + + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) + result = client.import_entry( + 123, + url="http://example.org/article.html", + published_at=published_at, + ) + + session.post.assert_called_once_with( + "http://localhost/v1/feeds/123/entries/import", + data=mock.ANY, + timeout=30, + ) + + _, kwargs = session.post.call_args + payload = json.loads(kwargs.get("data")) + + self.assertEqual(payload.get("published_at"), published_at) + self.assertEqual(result, expected_result) + + def test_import_entry_when_existing(self): + session = requests.Session() + expected_result = {"id": 1790} + + response = mock.Mock() + response.status_code = 200 + response.json.return_value = expected_result + + session.post = mock.Mock() + session.post.return_value = response + + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) + result = client.import_entry(123, url="http://example.org/article.html") + + session.post.assert_called_once_with( + "http://localhost/v1/feeds/123/entries/import", + data=mock.ANY, + timeout=30, + ) + + _, kwargs = session.post.call_args + payload = json.loads(kwargs.get("data")) + + self.assertEqual(payload.get("url"), "http://example.org/article.html") + self.assertEqual(result, expected_result) + + def test_import_entry_without_url(self): + session = requests.Session() + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) + + with self.assertRaises(ValueError): + client.import_entry(123, url="") + def test_mark_feed_as_read(self): session = requests.Session() @@ -752,7 +917,9 @@ def test_get_entry(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_entry(123) session.get.assert_called_once_with( @@ -773,7 +940,9 @@ def test_fetch_entry_content(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.fetch_entry_content(123) session.get.assert_called_once_with( @@ -794,7 +963,9 @@ def test_get_entries(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_entries(status="unread", limit=10, offset=5) session.get.assert_called_once_with( @@ -817,7 +988,9 @@ def test_get_entries_with_before_param(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_entries(before=param_value) session.get.assert_called_once_with( @@ -839,7 +1012,9 @@ def test_get_entries_with_starred_param(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_entries(starred=True) session.get.assert_called_once_with( @@ -861,7 +1036,9 @@ def test_get_entries_with_starred_param_at_false(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_entries(starred=False, after_entry_id=123) session.get.assert_called_once_with( @@ -883,7 +1060,9 @@ def test_get_user_by_id(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_user_by_id(123) session.get.assert_called_once_with( @@ -903,7 +1082,9 @@ def test_get_inexisting_user(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(ResourceNotFound): client.get_user_by_id(123) @@ -919,7 +1100,9 @@ def test_get_user_by_username(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_user_by_username("foobar") session.get.assert_called_once_with( @@ -940,7 +1123,9 @@ def test_update_user(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.update_user(123, theme="black", language="fr_FR") session.put.assert_called_once_with( @@ -963,7 +1148,9 @@ def test_timeout(self): session.get = mock.Mock() session.get.side_effect = Timeout() - client = miniflux.Client("http://localhost", "username", "password", 1.0, session=session) + client = miniflux.Client( + "http://localhost", "username", "password", 1.0, session=session + ) with self.assertRaises(Timeout): client.export() @@ -1021,7 +1208,9 @@ def test_get_category_entry(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_category_entry(123, 456) session.get.assert_called_once_with( @@ -1042,7 +1231,9 @@ def test_get_category_entries(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_category_entries(123) session.get.assert_called_once_with( @@ -1064,7 +1255,9 @@ def test_update_entry_title(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.update_entry(entry_id=123, title="New title") session.put.assert_called_once_with( @@ -1090,7 +1283,9 @@ def test_update_entry_content(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.update_entry(entry_id=123, content="New content") session.put.assert_called_once_with( @@ -1114,7 +1309,9 @@ def test_update_entries_status(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.update_entries(entry_ids=[123, 456], status="read") session.put.assert_called_once_with( @@ -1141,7 +1338,9 @@ def test_get_enclosure(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_enclosure(123) session.get.assert_called_once_with( @@ -1160,7 +1359,9 @@ def test_update_enclosure(self): session.put = mock.Mock() session.put.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) self.assertTrue(client.update_enclosure(123, media_progression=42)) session.put.assert_called_once_with( @@ -1180,7 +1381,9 @@ def test_get_integrations_status(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) result = client.get_integrations_status() session.get.assert_called_once_with( @@ -1261,7 +1464,9 @@ def test_not_found_response(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(ResourceNotFound): client.get_version() @@ -1276,7 +1481,9 @@ def test_unauthorized_response(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(AccessUnauthorized): client.get_version() @@ -1291,7 +1498,9 @@ def test_forbidden_response(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(AccessForbidden): client.get_version() @@ -1306,7 +1515,9 @@ def test_bad_request_response(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(BadRequest): client.get_version() @@ -1321,7 +1532,9 @@ def test_server_error_response(self): session.get = mock.Mock() session.get.return_value = response - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) with self.assertRaises(ServerError): client.get_version() @@ -1329,7 +1542,9 @@ def test_server_error_response(self): def test_session_closed(self): session = mock.Mock() - client = miniflux.Client("http://localhost", "username", "password", session=session) + client = miniflux.Client( + "http://localhost", "username", "password", session=session + ) client.close() session.close.assert_called() @@ -1342,7 +1557,9 @@ def test_context_manager_exit_on_error(self): session = mock.Mock() session.get.return_value = response - with miniflux.Client("http://localhost", "username", "password", session=session) as client: + with miniflux.Client( + "http://localhost", "username", "password", session=session + ) as client: with self.assertRaises(ServerError): client.get_version()