Skip to content

Commit

Permalink
Use /v1/version endpoint instead of /version
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Oct 8, 2023
1 parent 0e9b547 commit 2f55ce2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
10 changes: 6 additions & 4 deletions miniflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +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 get_version(self) -> str:
endpoint = f"{self._base_url}/version"
response = requests.get(endpoint, timeout=self._timeout)
def get_version(self) -> Dict:
endpoint = self._get_endpoint("/version")
response = requests.get(
endpoint, headers=self._headers, auth=self._auth, timeout=self._timeout
)
if response.status_code == 200:
return response.text
return response.json()
raise ClientError(response)

def me(self) -> Dict:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ def test_base_url_with_trailing_slash(self):

self.assertEqual(result, expected_result)

def test_get_version(self):
requests = _get_request_mock()
expected_result = {
"version": "dev",
"commit": "HEAD",
"build_date": "undefined",
"go_version": "go1.21.1",
"compiler": "gc",
"arch": "amd64",
"os": "darwin"
}

response = mock.Mock()
response.status_code = 200
response.json.return_value = expected_result

requests.get.return_value = response

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

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

self.assertEqual(result, expected_result)

def test_get_me(self):
requests = _get_request_mock()
expected_result = {"id": 123, "username": "foobar"}
Expand Down

0 comments on commit 2f55ce2

Please sign in to comment.