Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new method to save entry #18

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions miniflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ def toggle_bookmark(self, entry_id: int) -> bool:
raise ClientError(response)
return True

def save_entry(self, entry_id: int) -> bool:
endpoint = self._get_endpoint(f"/entries/{entry_id}/save")
response = requests.post(
endpoint, headers=self._headers, auth=self._auth, timeout=self._timeout
)
if response.status_code != 202:
raise ClientError(response)
return True

def get_categories(self) -> List[Dict]:
endpoint = self._get_endpoint("/categories")
response = requests.get(
Expand Down
19 changes: 19 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,25 @@ def test_api_key_auth(self):
timeout=30.0,
)

def test_save_entry(self):
requests = _get_request_mock()
expected_result = True

response = mock.Mock()
response.status_code = 202
requests.post.return_value = response

client = miniflux.Client("http://localhost", api_key="secret")
result = client.save_entry(123)

requests.post.assert_called_once_with(
"http://localhost/v1/entries/123/save",
headers={"X-Auth-Token": "secret"},
auth=None,
timeout=30.0,
)
assert result == expected_result


def _get_request_mock():
patcher = mock.patch("miniflux.requests")
Expand Down