Skip to content

Commit

Permalink
Add flush_history() method
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Oct 8, 2023
1 parent 7882c6f commit 1004928
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions miniflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def _get_params(self, **kwargs) -> Optional[Dict]:
def _get_modification_params(self, **kwargs) -> Dict:
return {k: v for k, v in kwargs.items() if v is not None}

def flush_history(self) -> bool:
endpoint = self._get_endpoint("/flush-history")
response = requests.delete(
endpoint, headers=self._headers, auth=self._auth, timeout=self._timeout
)
return response.status_code == 202

def get_version(self) -> Dict:
endpoint = self._get_endpoint("/version")
response = requests.get(
Expand Down
22 changes: 21 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,31 @@ def test_base_url_with_trailing_slash(self):
headers=None,
auth=("username", "password"),
data=mock.ANY,
timeout=30,
timeout=30.0,
)

self.assertEqual(result, expected_result)

def test_flush_history(self):
requests = _get_request_mock()

response = mock.Mock()
response.status_code = 202

requests.delete.return_value = response

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

requests.delete.assert_called_once_with(
"http://localhost/v1/flush-history",
headers={"X-Auth-Token": "secret"},
auth=None,
timeout=30.0,
)

self.assertTrue(result)

def test_get_version(self):
requests = _get_request_mock()
expected_result = {
Expand Down

0 comments on commit 1004928

Please sign in to comment.