Add and document health API. Fixes #202
This commit is contained in:
pare
ef8e3cec6a
commit
e60a3f1892
S'han modificat 4 arxius amb 42 adicions i 0 eliminacions
|
@ -843,6 +843,7 @@ current instance.
|
|||
.. automethod:: Mastodon.instance
|
||||
.. automethod:: Mastodon.instance_activity
|
||||
.. automethod:: Mastodon.instance_peers
|
||||
.. automethod:: Mastodon.instance_health
|
||||
|
||||
Reading data: Timelines
|
||||
-----------------------
|
||||
|
|
|
@ -654,6 +654,13 @@ class Mastodon:
|
|||
"""
|
||||
return self.__api_request('GET', '/api/v1/instance/peers')
|
||||
|
||||
@api_version("3.0.0", "3.0.0", "3.0.0")
|
||||
def instance_health(self):
|
||||
"""
|
||||
Basic health check. Returns True if healthy, False if not.
|
||||
"""
|
||||
return self.__api_request('GET', '/health', parse=False).decode("utf-8") == "success"
|
||||
|
||||
###
|
||||
# Reading data: Timelines
|
||||
##
|
||||
|
|
30
tests/cassettes/test_health.yaml
Normal file
30
tests/cassettes/test_health.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
|
||||
Connection: [keep-alive]
|
||||
User-Agent: [python-requests/2.18.4]
|
||||
method: GET
|
||||
uri: http://localhost:3000/health
|
||||
response:
|
||||
body: {string: success}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [text/plain; charset=utf-8]
|
||||
Last-Modified: ['Sat, 12 Oct 2019 18:23:49 GMT']
|
||||
Referrer-Policy: [strict-origin-when-cross-origin]
|
||||
Transfer-Encoding: [chunked]
|
||||
Vary: [Accept-Encoding]
|
||||
X-Content-Type-Options: [nosniff]
|
||||
X-Download-Options: [noopen]
|
||||
X-Frame-Options: [SAMEORIGIN]
|
||||
X-Permitted-Cross-Domain-Policies: [none]
|
||||
X-Request-Id: [13fff315-deaa-47c3-9138-d61d02c5063e]
|
||||
X-Runtime: ['0.311003']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['7']
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
|
@ -32,3 +32,7 @@ def test_low_version(api_low_version):
|
|||
@pytest.mark.vcr()
|
||||
def test_emoji(api):
|
||||
assert len(api.custom_emojis()) == 0
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_health(api):
|
||||
assert api.instance_health() == True
|
||||
|
|
Loading…
Referencia en una nova incidència