Merge branch 'master' of github.com:halcy/Mastodon.py

pull/397/head
halcy 2025-02-13 23:35:58 +02:00
commit 8a6e4c43ea
6 zmienionych plików z 30 dodań i 9 usunięć

Wyświetl plik

@ -15,6 +15,7 @@ Reading
.. automethod:: Mastodon.account .. automethod:: Mastodon.account
.. automethod:: Mastodon.account_search .. automethod:: Mastodon.account_search
.. automethod:: Mastodon.account_lookup .. automethod:: Mastodon.account_lookup
.. automethod:: Mastodon.accounts
.. automethod:: Mastodon.featured_tags .. automethod:: Mastodon.featured_tags
.. automethod:: Mastodon.featured_tag_suggestions .. automethod:: Mastodon.featured_tag_suggestions

Wyświetl plik

@ -1,8 +1,8 @@
Every function on a huge CTRL-F-able page Every function on a huge CTRL-F-able page
========================================= =========================================
.. py:module:: mastodon .. py:module:: mastodon
.. py:class: Mastodon .. py:class: Mastodon
.. automethod:: Mastodon.retrieve_mastodon_version .. automethod:: Mastodon.retrieve_mastodon_version
.. automethod:: Mastodon.verify_minimum_version .. automethod:: Mastodon.verify_minimum_version
.. automethod:: Mastodon.create_app .. automethod:: Mastodon.create_app
@ -51,6 +51,7 @@ Every function on a huge CTRL-F-able page
.. automethod:: Mastodon.account .. automethod:: Mastodon.account
.. automethod:: Mastodon.account_search .. automethod:: Mastodon.account_search
.. automethod:: Mastodon.account_lookup .. automethod:: Mastodon.account_lookup
.. automethod:: Mastodon.accounts
.. automethod:: Mastodon.featured_tags .. automethod:: Mastodon.featured_tags
.. automethod:: Mastodon.featured_tag_suggestions .. automethod:: Mastodon.featured_tag_suggestions
.. automethod:: Mastodon.account_featured_tags .. automethod:: Mastodon.account_featured_tags
@ -184,5 +185,5 @@ Every function on a huge CTRL-F-able page
.. automethod:: Mastodon.admin_delete_domain_block .. automethod:: Mastodon.admin_delete_domain_block
.. automethod:: Mastodon.admin_measures .. automethod:: Mastodon.admin_measures
.. automethod:: Mastodon.admin_dimensions .. automethod:: Mastodon.admin_dimensions
.. automethod:: Mastodon.admin_retention .. automethod:: Mastodon.admin_retention

Wyświetl plik

@ -130,6 +130,16 @@ class Mastodon(Internals):
id = self.__unpack_id(id) id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/accounts/{id}') return self.__api_request('GET', f'/api/v1/accounts/{id}')
@api_version("4.3.0", "4.3.0", _DICT_VERSION_ACCOUNT)
def accounts(self, ids: List[Union[Account, IdType]]) -> List[Account]:
"""
Fetch information from multiple accounts by a list of user `id`.
Does not require authentication for publicly visible accounts.
"""
ids = [self.__unpack_id(id) for id in ids]
return self.__api_request('GET', '/api/v1/accounts', {"id[]": ids})
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT) @api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
def account_verify_credentials(self) -> Account: def account_verify_credentials(self) -> Account:
""" """

Wyświetl plik

@ -56,6 +56,6 @@ class Mastodon(Internals):
Set multiple to True to allow people to choose more than one answer. Set Set multiple to True to allow people to choose more than one answer. Set
hide_totals to True to hide the results of the poll until it has expired. hide_totals to True to hide the results of the poll until it has expired.
""" """
poll_params = locals() poll_params = locals().copy()
del poll_params["self"] del poll_params["self"]
return poll_params return poll_params

Wyświetl plik

@ -336,7 +336,7 @@ class Mastodon(Internals):
are replying to, removing every other mentioned user from the are replying to, removing every other mentioned user from the
conversation. conversation.
""" """
keyword_args = locals() keyword_args = locals().copy()
del keyword_args["self"] del keyword_args["self"]
del keyword_args["to_status"] del keyword_args["to_status"]
del keyword_args["untag"] del keyword_args["untag"]

Wyświetl plik

@ -8,6 +8,15 @@ def test_account(api):
account = api.account(api.account_verify_credentials()) account = api.account(api.account_verify_credentials())
assert account assert account
@pytest.mark.vcr()
def test_accounts(api):
account_ids = [
api.account_lookup("mastodonpy_test").id,
api.account_lookup("mastodonpy_test_2").id
]
accounts = api.accounts(account_ids)
assert len(accounts) == 2
@pytest.mark.vcr() @pytest.mark.vcr()
def test_verify_credentials(api): def test_verify_credentials(api):
account_a = api.account_verify_credentials() account_a = api.account_verify_credentials()