Add conversation fetching

This commit is contained in:
Lorenz Diener 2019-04-28 13:47:43 +02:00
pare 8e0d8a5c4e
commit 06df1c281e
S'han modificat 5 arxius amb 209 adicions i 8 eliminacions

Veure arxiu

@ -329,6 +329,23 @@ Mention dicts
'id': # Mentioned users (local) account ID 'id': # Mentioned users (local) account ID
} }
Conversation dicts
~~~~~~~~~~~~~~~~~~
.. _conversation dict:
.. code-block:: python
mastodon.conversations()[0]
# Returns the following dictionary:
{
'id': # The ID of this conversation object
'unread': # Boolean indicating whether this conversation has yet to be
# read by the user
'accounts': # List of accounts (other than the logged-in account) that
# are part of this conversation
'last_status': # The newest status in this conversation
}
Hashtag dicts Hashtag dicts
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
.. _hashtag dict: .. _hashtag dict:
@ -718,6 +735,7 @@ and local timelines.
.. _timeline_hashtag(): .. _timeline_hashtag():
.. automethod:: Mastodon.timeline_hashtag .. automethod:: Mastodon.timeline_hashtag
.. automethod:: Mastodon.timeline_list .. automethod:: Mastodon.timeline_list
.. automethod:: Mastodon.conversations
Reading data: Statuses Reading data: Statuses
---------------------- ----------------------

Veure arxiu

@ -127,7 +127,6 @@ class Mastodon:
'read:lists', 'read:lists',
'read:mutes', 'read:mutes',
'read:notifications', 'read:notifications',
'read:reports',
'read:search', 'read:search',
'read:statuses' 'read:statuses'
], ],
@ -179,6 +178,7 @@ class Mastodon:
__DICT_VERSION_PUSH = "2.4.0" __DICT_VERSION_PUSH = "2.4.0"
__DICT_VERSION_PUSH_NOTIF = "2.4.0" __DICT_VERSION_PUSH_NOTIF = "2.4.0"
__DICT_VERSION_FILTER = "2.4.3" __DICT_VERSION_FILTER = "2.4.3"
__DICT_VERSION_CONVERSATION = bigger_version(bigger_version("2.6.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS)
### ###
# Registering apps # Registering apps
@ -649,6 +649,25 @@ class Mastodon:
return self.timeline('list/{0}'.format(id), max_id=max_id, return self.timeline('list/{0}'.format(id), max_id=max_id,
min_id=min_id, since_id=since_id, limit=limit) min_id=min_id, since_id=since_id, limit=limit)
@api_version("2.6.0", "2.6.0", __DICT_VERSION_CONVERSATION)
def conversations(self, max_id=None, min_id=None, since_id=None, limit=None):
"""
Fetches a users conversations.
Returns a list of `conversation dicts`_.
"""
if max_id != None:
max_id = self.__unpack_id(max_id)
if min_id != None:
min_id = self.__unpack_id(min_id)
if since_id != None:
since_id = self.__unpack_id(since_id)
params = self.__generate_params(locals())
return self.__api_request('GET', "/api/v1/conversations/", params)
### ###
# Reading data: Statuses # Reading data: Statuses
### ###
@ -1782,22 +1801,30 @@ class Mastodon:
### ###
# Writing data: Reports # Writing data: Reports
### ###
@api_version("1.1.0", "1.1.0", __DICT_VERSION_REPORT) @api_version("1.1.0", "2.5.0", __DICT_VERSION_REPORT)
def report(self, account_id, status_ids, comment): def report(self, account_id, status_ids = None, comment = None, forward = False):
""" """
Report statuses to the instances administrators. Report statuses to the instances administrators.
Accepts a list of toot IDs associated with the report, and a comment. Accepts a list of toot IDs associated with the report, and a comment.
Set forward to True to forward a report of a remote user to that users
instance as well as sending it to the instance local administrators.
Returns a `report dict`_. Returns a `report dict`_.
""" """
account_id = self.__unpack_id(account_id) account_id = self.__unpack_id(account_id)
if not status_ids is None:
if not isinstance(status_ids, list): if not isinstance(status_ids, list):
status_ids = [status_ids] status_ids = [status_ids]
status_ids = list(map(lambda x: self.__unpack_id(x), status_ids)) status_ids = list(map(lambda x: self.__unpack_id(x), status_ids))
params = self.__generate_params(locals()) params_initial = locals()
if forward == False:
del params_initial['forward']
params = self.__generate_params(params_initial)
return self.__api_request('POST', '/api/v1/reports/', params) return self.__api_request('POST', '/api/v1/reports/', params)
### ###

Veure arxiu

@ -1,4 +1,5 @@
from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError
from mastodon.streaming import StreamListener, CallbackStreamListener from mastodon.streaming import StreamListener, CallbackStreamListener
__all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError'] __all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError',
'MastodonServerError']

Veure arxiu

@ -0,0 +1,143 @@
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/api/v1/accounts/verify_credentials
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Type: [application/json; charset=utf-8]
ETag: [W/"22befe12cde5f76de801140c68ff24d7"]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [f61f2b83-2a73-4874-a883-70240d83b453]
X-Runtime: ['0.021142']
X-XSS-Protection: [1; mode=block]
content-length: ['653']
status: {code: 200, message: OK}
- request:
body: visibility=direct&status=%40admin+ilu+bby+%3B3
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
Connection: [keep-alive]
Content-Length: ['46']
Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/statuses
response:
body: {string: '{"id":"102003581864478788","created_at":"2019-04-28T11:32:19.297Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003581864478788","content":"\u003cp\u003e\u003cspan
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url
mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003581864478788","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py
test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Type: [application/json; charset=utf-8]
ETag: [W/"dc7ff9b9023358ffdcb2a1507e9e77e6"]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [de40a9dc-97f0-4805-a24a-8378f8f37de9]
X-Runtime: ['0.160974']
X-XSS-Protection: [1; mode=block]
content-length: ['1475']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/conversations/
response:
body: {string: '[{"id":"24","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003581864478788","created_at":"2019-04-28T11:32:19.297Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003581864478788","content":"\u003cp\u003e\u003cspan
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url
mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003581864478788","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py
test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"22","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003580476156514","created_at":"2019-04-28T11:31:58.113Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003580476156514","content":"\u003cp\u003e\u003cspan
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url
mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003580476156514","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py
test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"18","unread":true,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003573042670077","created_at":"2019-04-28T11:30:04.687Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003573042670077","content":"\u003cp\u003e\u003cspan
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url
mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003573042670077","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py
test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"14","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003565381731428","created_at":"2019-04-28T11:28:07.791Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003565381731428","content":"\u003cp\u003e\u003cspan
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url
mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
ilu bby ;3\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003565381731428","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py
test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"4","unread":false,"accounts":[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]}],"last_status":{"id":"102003533707396851","created_at":"2019-04-28T11:20:04.478Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"direct","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/102003533707396851","content":"\u003cp\u003e\u003cspan
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@admin\" class=\"u-url
mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
test\u003c/p\u003e","url":"http://localhost/@mastodonpy_test/102003533707396851","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py
test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-04-27T20:56:20.155Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":4,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1","username":"admin","url":"http://localhost/@admin","acct":"admin"}],"tags":[],"emojis":[],"card":null,"poll":null}}]'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Type: [application/json; charset=utf-8]
ETag: [W/"79b5a64acc37c8440422aa5612672686"]
Link: ['<http://localhost:3000/api/v1/conversations?min_id=102003581864478788>;
rel="prev"']
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [b9d855cb-8dcd-4498-ae9c-57a9891c1d19]
X-Runtime: ['0.175062']
X-XSS-Protection: [1; mode=block]
content-length: ['10481']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
Connection: [keep-alive]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: DELETE
uri: http://localhost:3000/api/v1/statuses/102003581864478788
response:
body: {string: '{}'}
headers:
Cache-Control: ['max-age=0, private, must-revalidate']
Content-Type: [application/json; charset=utf-8]
ETag: [W/"0f55e9de51b2e35f7a3eecdfab3e2571"]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [e9e9ed92-a1c4-4bc7-ab9e-5e1a2df23660]
X-Runtime: ['0.024581']
X-XSS-Protection: [1; mode=block]
content-length: ['2']
status: {code: 200, message: OK}
version: 1

Veure arxiu

@ -1,4 +1,5 @@
import pytest import pytest
import time
from mastodon.Mastodon import MastodonAPIError,\ from mastodon.Mastodon import MastodonAPIError,\
MastodonIllegalArgumentError,\ MastodonIllegalArgumentError,\
MastodonUnauthorizedError MastodonUnauthorizedError
@ -38,8 +39,19 @@ def test_hashtag_tl_leading_hash(api):
with pytest.raises(MastodonIllegalArgumentError): with pytest.raises(MastodonIllegalArgumentError):
api.timeline_hashtag('#hoot') api.timeline_hashtag('#hoot')
@pytest.mark.vcr() @pytest.mark.vcr()
def test_home_tl_anonymous_throws(api_anonymous): def test_home_tl_anonymous_throws(api_anonymous):
with pytest.raises(MastodonAPIError): with pytest.raises(MastodonAPIError):
api_anonymous.timeline_home() api_anonymous.timeline_home()
@pytest.mark.vcr()
def test_conversations(api, api2):
account = api.account_verify_credentials()
status = api.status_post("@admin ilu bby ;3", visibility="direct")
time.sleep(2)
conversations = api2.conversations()
api.status_delete(status)
assert conversations
assert status.id in map(lambda x: x.last_status.id, conversations)
assert account.id in map(lambda x: x.accounts[0].id, conversations)