aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-06-22 17:33:12 +0200
committerLorenz Diener <[email protected]>2019-06-22 17:33:12 +0200
commita88492bdcf0884b922c50d04c44d909f271ff2ca (patch)
treebbe18529d4ecb2d64a9f2d947948e696d5148f1c
parent71c6bc0f52289cf0408946b7b9e3adb2810e4598 (diff)
downloadmastodon.py-a88492bdcf0884b922c50d04c44d909f271ff2ca.tar.gz
Add healthy test cassette
-rw-r--r--CHANGELOG.rst2
-rw-r--r--docs/index.rst2
-rw-r--r--mastodon/Mastodon.py23
-rw-r--r--tests/cassettes/test_stream_healthy.yaml52
4 files changed, 70 insertions, 9 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index f472941..df5f584 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,8 @@ version number. Breaking changes will be indicated by a change in the minor
4 4
5v1.4.4 5v1.4.4
6------ 6------
7* Made status_delete return the deleted status (With "source" attribute)
8* Added account_id parameter to notifications
7* Added streaming_health 9* Added streaming_health
8* Added support for local hashtag streams 10* Added support for local hashtag streams
9* Made blurhash an optional dependency (Thanks limburgher) 11* Made blurhash an optional dependency (Thanks limburgher)
diff --git a/docs/index.rst b/docs/index.rst
index 1851b04..b09b050 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -543,7 +543,7 @@ Media dicts
543 # Returns the following dictionary: 543 # Returns the following dictionary:
544 { 544 {
545 'id': # The ID of the attachment. 545 'id': # The ID of the attachment.
546 'type': # Media type: 'image', 'video', 'gifv' or 'unknown'. 546 'type': # Media type: 'image', 'video', 'gifv', 'audio' or 'unknown'.
547 'url': # The URL for the image in the local cache 547 'url': # The URL for the image in the local cache
548 'remote_url': # The remote URL for the media (if the image is from a remote instance) 548 'remote_url': # The remote URL for the media (if the image is from a remote instance)
549 'preview_url': # The URL for the media preview 549 'preview_url': # The URL for the media preview
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 4f51d0d..6f84b27 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -179,7 +179,7 @@ class Mastodon:
179 __DICT_VERSION_MEDIA = "2.8.2" 179 __DICT_VERSION_MEDIA = "2.8.2"
180 __DICT_VERSION_ACCOUNT = "2.4.0" 180 __DICT_VERSION_ACCOUNT = "2.4.0"
181 __DICT_VERSION_POLL = "2.8.0" 181 __DICT_VERSION_POLL = "2.8.0"
182 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version(bigger_version("2.8.0", 182 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version(bigger_version("2.9.1",
183 __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION), __DICT_VERSION_POLL) 183 __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION), __DICT_VERSION_POLL)
184 __DICT_VERSION_INSTANCE = bigger_version("2.7.2", __DICT_VERSION_ACCOUNT) 184 __DICT_VERSION_INSTANCE = bigger_version("2.7.2", __DICT_VERSION_ACCOUNT)
185 __DICT_VERSION_HASHTAG = "2.3.4" 185 __DICT_VERSION_HASHTAG = "2.3.4"
@@ -865,12 +865,12 @@ class Mastodon:
865 ### 865 ###
866 # Reading data: Notifications 866 # Reading data: Notifications
867 ### 867 ###
868 @api_version("1.0.0", "2.6.0", __DICT_VERSION_NOTIFICATION) 868 @api_version("1.0.0", "2.9.0", __DICT_VERSION_NOTIFICATION)
869 def notifications(self, id=None, max_id=None, min_id=None, since_id=None, limit=None): 869 def notifications(self, id=None, account_id=None, max_id=None, min_id=None, since_id=None, limit=None):
870 """ 870 """
871 Fetch notifications (mentions, favourites, reblogs, follows) for the logged-in 871 Fetch notifications (mentions, favourites, reblogs, follows) for the logged-in
872 user. 872 user. Pass `account_id` to get only notifications originating from the given account.
873 873
874 Can be passed an `id` to fetch a single notification. 874 Can be passed an `id` to fetch a single notification.
875 875
876 Returns a list of `notification dicts`_. 876 Returns a list of `notification dicts`_.
@@ -884,6 +884,9 @@ class Mastodon:
884 if since_id != None: 884 if since_id != None:
885 since_id = self.__unpack_id(since_id) 885 since_id = self.__unpack_id(since_id)
886 886
887 if account_id != None:
888 account_id = self.__unpack_id(account_id)
889
887 if id is None: 890 if id is None:
888 params = self.__generate_params(locals(), ['id']) 891 params = self.__generate_params(locals(), ['id'])
889 return self.__api_request('GET', '/api/v1/notifications', params) 892 return self.__api_request('GET', '/api/v1/notifications', params)
@@ -1606,10 +1609,14 @@ class Mastodon:
1606 def status_delete(self, id): 1609 def status_delete(self, id):
1607 """ 1610 """
1608 Delete a status 1611 Delete a status
1612
1613 Returns the now-deleted status, with an added "source" attribute that contains
1614 the text that was used to compose this status (this can be used to power
1615 "delete and redraft" functionality)
1609 """ 1616 """
1610 id = self.__unpack_id(id) 1617 id = self.__unpack_id(id)
1611 url = '/api/v1/statuses/{0}'.format(str(id)) 1618 url = '/api/v1/statuses/{0}'.format(str(id))
1612 self.__api_request('DELETE', url) 1619 return self.__api_request('DELETE', url)
1613 1620
1614 @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) 1621 @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS)
1615 def status_reblog(self, id, visibility=None): 1622 def status_reblog(self, id, visibility=None):
@@ -2159,10 +2166,10 @@ class Mastodon:
2159 ### 2166 ###
2160 # Writing data: Media 2167 # Writing data: Media
2161 ### 2168 ###
2162 @api_version("1.0.0", "2.3.0", __DICT_VERSION_MEDIA) 2169 @api_version("1.0.0", "2.9.1", __DICT_VERSION_MEDIA)
2163 def media_post(self, media_file, mime_type=None, description=None, focus=None): 2170 def media_post(self, media_file, mime_type=None, description=None, focus=None):
2164 """ 2171 """
2165 Post an image. `media_file` can either be image data or 2172 Post an image, video or audio file. `media_file` can either be image data or
2166 a file name. If image data is passed directly, the mime 2173 a file name. If image data is passed directly, the mime
2167 type has to be specified manually, otherwise, it is 2174 type has to be specified manually, otherwise, it is
2168 determined from the file name. `focus` should be a tuple 2175 determined from the file name. `focus` should be a tuple
diff --git a/tests/cassettes/test_stream_healthy.yaml b/tests/cassettes/test_stream_healthy.yaml
new file mode 100644
index 0000000..fd87272
--- /dev/null
+++ b/tests/cassettes/test_stream_healthy.yaml
@@ -0,0 +1,52 @@
1interactions:
2- request:
3 body: null
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Connection: [keep-alive]
8 User-Agent: [python-requests/2.18.4]
9 method: GET
10 uri: http://localhost:3000/api/v1/instance/
11 response:
12 body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.9.1","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":8,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'}
13 headers:
14 Cache-Control: ['max-age=300, public']
15 Content-Type: [application/json; charset=utf-8]
16 Date: ['Sat, 22 Jun 2019 14:40:35 GMT']
17 ETag: [W/"9cf634ec19499004934b5325f20d71b4"]
18 Referrer-Policy: [strict-origin-when-cross-origin]
19 Transfer-Encoding: [chunked]
20 Vary: ['Accept-Encoding, Origin']
21 X-Content-Type-Options: [nosniff]
22 X-Download-Options: [noopen]
23 X-Frame-Options: [SAMEORIGIN]
24 X-Permitted-Cross-Domain-Policies: [none]
25 X-Request-Id: [e205dad6-1b7d-4469-82e6-b1928be37b2f]
26 X-Runtime: ['0.026031']
27 X-XSS-Protection: [1; mode=block]
28 content-length: ['348']
29 status: {code: 200, message: OK}
30- request:
31 body: null
32 headers:
33 Accept: ['*/*']
34 Accept-Encoding: ['gzip, deflate']
35 Connection: [keep-alive]
36 User-Agent: [python-requests/2.18.4]
37 method: GET
38 uri: http://localhost:4000/api/v1/streaming/health
39 response:
40 body: {string: OK}
41 headers:
42 Access-Control-Allow-Headers: ['Authorization, Accept, Cache-Control']
43 Access-Control-Allow-Methods: ['GET, OPTIONS']
44 Access-Control-Allow-Origin: ['*']
45 Connection: [keep-alive]
46 Content-Type: [text/plain]
47 Date: ['Sat, 22 Jun 2019 14:40:35 GMT']
48 Transfer-Encoding: [chunked]
49 X-Powered-By: [Express]
50 X-Request-Id: [93545687-8c80-4295-a7c7-5289fac6e5b3]
51 status: {code: 200, message: OK}
52version: 1
Powered by cgit v1.2.3 (git 2.41.0)