diff --git a/LICENSE.txt b/LICENSE.txt
index aa951f9..821d033 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2018-2024 Frédéric Guillot
+Copyright (c) Frédéric Guillot
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f387bea
--- /dev/null
+++ b/README.md
@@ -0,0 +1,103 @@
+Miniflux Python API Client
+==========================
+
+Python client library for [Miniflux](https://miniflux.app).
+
+Requirements
+------------
+
+- Miniflux >= 2.0.49
+- Python >= 3.8
+- requests
+
+This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting.
+
+Installation
+------------
+
+```bash
+python3 -m pip install miniflux
+```
+
+Running Tests
+-------------
+
+```bash
+python3 -m unittest -v
+```
+
+Examples
+--------
+
+```python
+import miniflux
+
+# Creating a client using username / password authentication
+client = miniflux.Client("https://miniflux.example.org", username="my_username", password="my_secret_password")
+
+# Use an API Key (preferred method)
+client = miniflux.Client("https://miniflux.example.org", api_key="My secret API token")
+
+# Get all feeds
+feeds = client.get_feeds()
+
+# Refresh a feed
+client.refresh_feed(123)
+
+# Discover subscriptions from a website
+subscriptions = client.discover("https://example.org")
+
+# Create a new feed, with a personalized user agent and with the crawler enabled
+feed_id = client.create_feed("http://example.org/feed.xml", category_id=42, crawler=True, user_agent="GoogleBot")
+
+# Fetch 10 starred entries
+entries = client.get_entries(starred=True, limit=10)
+
+# Fetch last 5 feed entries
+feed_entries = client.get_feed_entries(123, direction='desc', order='published_at', limit=5)
+
+# Fetch entries that belongs to a category with status unread and read
+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")
+
+# Update a feed category
+client.update_feed(123, category_id=456)
+
+# OPML Export
+opml = client.export_feeds()
+
+# OPML import
+client.import_feeds(opml_data)
+
+# Get application version
+client.get_version()
+
+# Flush history
+client.flush_history()
+
+# Get current user
+myself = client.me()
+```
+
+You can also use a context manager:
+
+```python
+import miniflux
+
+with miniflux.Client("https://miniflux.domain.tld", api_key="secret") as clt:
+ clt.me()
+```
+
+Look at [miniflux.py](https://github.com/miniflux/python-client/blob/main/miniflux.py) for the complete list of methods.
+
+Author
+------
+
+Frédéric Guillot
+
+License
+-------
+
+This library is distributed under MIT License.
diff --git a/README.rst b/README.rst
deleted file mode 100644
index f12206c..0000000
--- a/README.rst
+++ /dev/null
@@ -1,98 +0,0 @@
-Miniflux Python API Client
-==========================
-
-.. image:: https://badge.fury.io/py/miniflux.svg
- :target: https://badge.fury.io/py/miniflux
-
-Python client library for Miniflux API.
-
-Requirements
-------------
-
-- Miniflux >= 2.0.49
-- Python >= 3.8
-- requests
-
-This project uses `Ruff `_ for linting and formatting.
-
-Installation
-------------
-
-.. code:: bash
-
- python3 -m pip install miniflux
-
-Running Tests
--------------
-
-.. code:: bash
-
- python3 -m unittest -v
-
-Usage Example
--------------
-
-.. code:: python
-
- import miniflux
-
- # Creating a client using username / password authentication
- client = miniflux.Client("https://miniflux.example.org", username="my_username", password="my_secret_password")
-
- # Use an API Key (preferred method)
- client = miniflux.Client("https://miniflux.example.org", api_key="My secret API token")
-
- # Get all feeds
- feeds = client.get_feeds()
-
- # Refresh a feed
- client.refresh_feed(123)
-
- # Discover subscriptions from a website
- subscriptions = client.discover("https://example.org")
-
- # Create a new feed, with a personalized user agent and with the crawler enabled
- feed_id = client.create_feed("http://example.org/feed.xml", category_id=42, crawler=True, user_agent="GoogleBot")
-
- # Fetch 10 starred entries
- entries = client.get_entries(starred=True, limit=10)
-
- # Fetch last 5 feed entries
- feed_entries = client.get_feed_entries(123, direction='desc', order='published_at', limit=5)
-
- # Fetch entries that belongs to a category with status unread and read
- 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")
-
- # Update a feed category
- client.update_feed(123, category_id=456)
-
- # OPML Export
- opml = client.export_feeds()
-
- # OPML import
- client.import_feeds(opml_data)
-
- # Get application version
- client.get_version()
-
- # Flush history
- client.flush_history()
-
- # Get current user
- myself = client.me()
-
-
-Look at `miniflux.py `_ to get the complete list of methods.
-
-Author
-------
-
-Frédéric Guillot
-
-License
--------
-
-This library is distributed under MIT License.
diff --git a/miniflux.py b/miniflux.py
index 2e4cfa0..47e0b7e 100644
--- a/miniflux.py
+++ b/miniflux.py
@@ -1,6 +1,6 @@
# The MIT License (MIT)
#
-# Copyright (c) 2018-2024 Frederic Guillot
+# Copyright (c) Frederic Guillot
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -110,16 +110,16 @@ def __init__(
timeout: float = 30.0,
api_key: Optional[str] = None,
user_agent: str = DEFAULT_USER_AGENT,
- session: requests.Session = requests.Session()
+ session: requests.Session = requests.Session(),
):
self._base_url = base_url
self._timeout = timeout
self._session = session
- auth : Optional[tuple] = (
+ auth: Optional[tuple] = (
(username or "", password or "") if not api_key else None
)
-
+
self._session.headers.update({"User-Agent": user_agent})
if api_key:
self._session.headers.update({"X-Auth-Token": api_key})
@@ -166,9 +166,7 @@ def flush_history(self) -> bool:
bool: True if the operation was successfully scheduled, False otherwise.
"""
endpoint = self._get_endpoint("/flush-history")
- response = self._session.delete(
- endpoint, timeout=self._timeout
- )
+ response = self._session.delete(endpoint, timeout=self._timeout)
if response.status_code == 202:
return True
self._handle_error_response(response)
@@ -183,9 +181,7 @@ def get_version(self) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/version")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -200,9 +196,7 @@ def me(self) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/me")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -228,9 +222,7 @@ def export_feeds(self) -> str:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/export")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.text
self._handle_error_response(response)
@@ -292,9 +284,7 @@ def get_category_feeds(self, category_id: int) -> List[dict]:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/categories/{category_id}/feeds")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -309,9 +299,7 @@ def get_feeds(self) -> List[dict]:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/feeds")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -328,9 +316,7 @@ def get_feed(self, feed_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/feeds/{feed_id}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -347,9 +333,7 @@ def get_feed_icon(self, feed_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/feeds/{feed_id}/icon")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -366,9 +350,7 @@ def get_icon(self, icon_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/icons/{icon_id}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -445,9 +427,7 @@ def refresh_all_feeds(self) -> bool:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/feeds/refresh")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code >= 400:
self._handle_error_response(response)
return True
@@ -464,9 +444,7 @@ def refresh_feed(self, feed_id: int) -> bool:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/feeds/{feed_id}/refresh")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code >= 400:
self._handle_error_response(response)
return True
@@ -483,9 +461,7 @@ def refresh_category(self, category_id: int) -> bool:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/categories/{category_id}/refresh")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code >= 400:
self._handle_error_response(response)
return True
@@ -500,9 +476,7 @@ def delete_feed(self, feed_id: int) -> None:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/feeds/{feed_id}")
- response = self._session.delete(
- endpoint, timeout=self._timeout
- )
+ response = self._session.delete(endpoint, timeout=self._timeout)
if response.status_code != 204:
self._handle_error_response(response)
@@ -519,9 +493,7 @@ def get_feed_entry(self, feed_id: int, entry_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/feeds/{feed_id}/entries/{entry_id}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -560,9 +532,7 @@ def mark_feed_entries_as_read(self, feed_id: int) -> None:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/feeds/{feed_id}/mark-all-as-read")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code != 204:
self._handle_error_response(response)
@@ -578,9 +548,7 @@ def get_entry(self, entry_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/entries/{entry_id}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -671,9 +639,7 @@ def fetch_entry_content(self, entry_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/entries/{entry_id}/fetch-content")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -690,9 +656,7 @@ def toggle_bookmark(self, entry_id: int) -> bool:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/entries/{entry_id}/bookmark")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code >= 400:
self._handle_error_response(response)
return True
@@ -709,9 +673,7 @@ def save_entry(self, entry_id: int) -> bool:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/entries/{entry_id}/save")
- response = self._session.post(
- endpoint, timeout=self._timeout
- )
+ response = self._session.post(endpoint, timeout=self._timeout)
if response.status_code != 202:
self._handle_error_response(response)
return True
@@ -728,9 +690,7 @@ def get_enclosure(self, enclosure_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/enclosures/{enclosure_id}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -770,9 +730,7 @@ def get_categories(self) -> List[dict]:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/categories")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -790,9 +748,7 @@ def get_category_entry(self, category_id: int, entry_id: int) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/categories/{category_id}/entries/{entry_id}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -874,9 +830,7 @@ def delete_category(self, category_id: int) -> None:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/categories/{category_id}")
- response = self._session.delete(
- endpoint, timeout=self._timeout
- )
+ response = self._session.delete(endpoint, timeout=self._timeout)
if response.status_code != 204:
self._handle_error_response(response)
@@ -890,9 +844,7 @@ def mark_category_entries_as_read(self, category_id: int) -> None:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/categories/{category_id}/mark-all-as-read")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code != 204:
self._handle_error_response(response)
@@ -906,9 +858,7 @@ def get_users(self) -> List[dict]:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/users")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -941,9 +891,7 @@ def get_user_by_username(self, username: str) -> dict:
def _get_user(self, user_id_or_username: Union[str, int]) -> dict:
endpoint = self._get_endpoint(f"/users/{user_id_or_username}")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -1004,9 +952,7 @@ def delete_user(self, user_id: int) -> None:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/users/{user_id}")
- response = self._session.delete(
- endpoint, timeout=self._timeout
- )
+ response = self._session.delete(endpoint, timeout=self._timeout)
if response.status_code != 204:
self._handle_error_response(response)
@@ -1020,9 +966,7 @@ def mark_user_entries_as_read(self, user_id: int) -> None:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint(f"/users/{user_id}/mark-all-as-read")
- response = self._session.put(
- endpoint, timeout=self._timeout
- )
+ response = self._session.put(endpoint, timeout=self._timeout)
if response.status_code != 204:
self._handle_error_response(response)
@@ -1036,9 +980,7 @@ def get_feed_counters(self) -> dict:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/feeds/counters")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()
self._handle_error_response(response)
@@ -1053,9 +995,7 @@ def get_integrations_status(self) -> bool:
ClientError: If the request fails.
"""
endpoint = self._get_endpoint("/integrations/status")
- response = self._session.get(
- endpoint, timeout=self._timeout
- )
+ response = self._session.get(endpoint, timeout=self._timeout)
if response.status_code == 200:
return response.json()["has_integrations"]
self._handle_error_response(response)
diff --git a/pyproject.toml b/pyproject.toml
index 610102e..3419f91 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
name = "miniflux"
version = "1.1.2"
description = "Client library for Miniflux"
-readme = "README.rst"
+readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE.txt"}
keywords = ["rss", "atom", "rdf", "jsonfeed", "feed", "miniflux"]
diff --git a/tests/test_client.py b/tests/test_client.py
index 7cd17b1..d8878bf 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -1,6 +1,6 @@
# The MIT License (MIT)
#
-# Copyright (c) 2018-2024 Frederic Guillot
+# Copyright (c) Frederic Guillot
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -76,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(
@@ -103,7 +105,7 @@ def test_flush_history(self):
"http://localhost/v1/flush-history",
timeout=30.0,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
self.assertTrue(result)
def test_get_version(self):
@@ -132,7 +134,7 @@ def test_get_version(self):
"http://localhost/v1/version",
timeout=30.0,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
self.assertEqual(result, expected_result)
def test_get_me(self):
@@ -146,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(
@@ -165,7 +169,9 @@ 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()
@@ -183,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(
@@ -213,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",
@@ -247,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/")
@@ -263,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(
@@ -283,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(
@@ -303,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)
@@ -325,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(
@@ -350,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(
@@ -375,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(
@@ -396,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(
@@ -426,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(
@@ -456,7 +484,9 @@ 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)
+ client = miniflux.Client(
+ "http://localhost", "username", "password", session=session
+ )
result = client.create_feed(
"http://example.org/feed", 123, username="foobar", password="secret"
)
@@ -488,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(
@@ -518,7 +550,9 @@ 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)
+ client = miniflux.Client(
+ "http://localhost", "username", "password", session=session
+ )
result = client.create_feed(
"http://example.org/feed", 123, crawler=False, user_agent="GoogleBot"
)
@@ -551,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(
@@ -580,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(
@@ -601,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(
@@ -622,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(
@@ -643,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(
@@ -664,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(
@@ -686,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(
@@ -713,7 +761,7 @@ def test_mark_feed_as_read(self):
"http://localhost/v1/feeds/123/mark-all-as-read",
timeout=30,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
def test_mark_category_entries_as_read(self):
session = requests.Session()
@@ -731,7 +779,7 @@ def test_mark_category_entries_as_read(self):
"http://localhost/v1/categories/123/mark-all-as-read",
timeout=30,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
def test_mark_user_entries_as_read(self):
session = requests.Session()
@@ -749,7 +797,7 @@ def test_mark_user_entries_as_read(self):
"http://localhost/v1/users/123/mark-all-as-read",
timeout=30,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
def test_get_entry(self):
session = requests.Session()
@@ -762,7 +810,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(
@@ -783,7 +833,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(
@@ -804,7 +856,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(
@@ -827,7 +881,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(
@@ -849,7 +905,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(
@@ -871,7 +929,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(
@@ -893,7 +953,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(
@@ -913,7 +975,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)
@@ -929,7 +993,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(
@@ -950,7 +1016,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(
@@ -973,7 +1041,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()
@@ -999,7 +1069,7 @@ def test_api_key_auth(self):
"http://localhost/v1/export",
timeout=30.0,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
def test_save_entry(self):
session = requests.Session()
@@ -1017,7 +1087,7 @@ def test_save_entry(self):
"http://localhost/v1/entries/123/save",
timeout=30.0,
)
- self.assertEqual(session.headers.get('X-Auth-Token'), 'secret')
+ self.assertEqual(session.headers.get("X-Auth-Token"), "secret")
self.assertEqual(result, expected_result)
def test_get_category_entry(self):
@@ -1031,7 +1101,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(
@@ -1052,7 +1124,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(
@@ -1074,7 +1148,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(
@@ -1100,7 +1176,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(
@@ -1124,7 +1202,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(
@@ -1151,7 +1231,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(
@@ -1170,7 +1252,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(
@@ -1190,7 +1274,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(
@@ -1210,7 +1296,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()
@@ -1225,7 +1313,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()
@@ -1240,7 +1330,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()
@@ -1255,7 +1347,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()
@@ -1270,7 +1364,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()
@@ -1278,7 +1374,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()
@@ -1298,5 +1396,3 @@ def test_context_manager_exit_on_error(self):
client.get_version()
session.close.assert_called()
-
-