refactor version decorator, skip certain tests on 3.8 and below

pull/397/head
halcy 2025-02-15 14:21:56 +02:00
rodzic 745d60057e
commit 1e1bc0cf78
28 zmienionych plików z 8956 dodań i 298 usunięć

16
TODO.md
Wyświetl plik

@ -2,17 +2,15 @@ API relevant changes since last release / "to implement" list:
Refer to mastodon changelog and API docs for details when implementing, add or modify tests where needed
4.0.0 and beyond
----------------
* [ ] Document all the endpoints we need to add
4.4.0 TODOs
-----------
* [ ] to be collected here
4.3.0 TODOs
-----------
* ?????
General improvements that would be good to do before doing another release
--------------------------------------------------------------------------
* [x] Split mastodon.py into parts in some way that makes sense, it's getting very unwieldy
* [x] Fix the CI (forever task)
* [ ] Get test coverage like, real high
* [x] Add all those streaming events??
* [x] Document return values (skipping this for a bit to then do it at the end with tooling)
* [x] Do this with models properly, that would be cool as heck
* [x] Add links to mastodon docs to entities and endpoints
* [ ] Also add links to tests to the docstrings so people can see usage examples

Wyświetl plik

@ -14,7 +14,7 @@ from mastodon.return_types import AccountCreationError, Account, IdType, Status,
from datetime import datetime
class Mastodon(Internals):
@api_version("2.7.0", "2.7.0", "3.4.0")
@api_version("2.7.0", "2.7.0")
def create_account(self, username: str, password: str, email: str, agreement: bool = False, reason: Optional[str] = None,
locale: str = "en", scopes: List[str] = _DEFAULT_SCOPES, to_file: Optional[str] = None,
return_detailed_error: bool = False) -> Union[Optional[str], Tuple[Optional[str], AccountCreationError]]:
@ -108,7 +108,7 @@ class Mastodon(Internals):
else:
return response['access_token']
@api_version("3.4.0", "3.4.0", "3.4.0")
@api_version("3.4.0", "3.4.0")
def email_resend_confirmation(self):
"""
Requests a re-send of the users confirmation mail for an unconfirmed logged in user.
@ -120,7 +120,7 @@ class Mastodon(Internals):
###
# Reading data: Accounts
###
@api_version("1.0.0", "1.0.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "1.0.0")
def account(self, id: Union[Account, IdType]) -> Account:
"""
Fetch account information by user `id`.
@ -130,24 +130,24 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/accounts/{id}')
@api_version("4.3.0", "4.3.0", _DICT_VERSION_ACCOUNT)
@api_version("4.3.0", "4.3.0")
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]
ids = [self.__unpack_id(id, dateconv=True) 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")
def account_verify_credentials(self) -> Account:
"""
Fetch logged-in user's account information. Returns the version of the Account object with `source` field.
"""
return self.__api_request('GET', '/api/v1/accounts/verify_credentials')
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.1.0")
def me(self) -> Account:
"""
Get this user's account. Synonym for `account_verify_credentials()`, does exactly
@ -156,7 +156,7 @@ class Mastodon(Internals):
"""
return self.account_verify_credentials()
@api_version("1.0.0", "2.8.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.8.0")
def account_statuses(self, id: Union[Account, IdType], only_media: bool = False, pinned: bool = False, exclude_replies: bool = False,
exclude_reblogs: bool = False, tagged: Optional[str] = None, max_id: Optional[Union[Status, IdType, datetime]] = None,
min_id: Optional[Union[Status, IdType, datetime]] = None, since_id: Optional[Union[Status, IdType, datetime]] = None,
@ -199,7 +199,7 @@ class Mastodon(Internals):
return self.__api_request('GET', f'/api/v1/accounts/{id}/statuses', params)
@api_version("1.0.0", "2.6.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.6.0")
def account_following(self, id: Union[Account, IdType], max_id: Optional[Union[Account, IdType]] = None,
min_id: Optional[Union[Account, IdType]] = None, since_id: Optional[Union[Account, IdType]] = None,
limit: Optional[int] = None) -> PaginatableList[Account]:
@ -210,7 +210,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'], dateconv=True)
return self.__api_request('GET', f'/api/v1/accounts/{id}/following', params)
@api_version("1.0.0", "2.6.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.6.0")
def account_followers(self, id: Union[Account, IdType], max_id: Optional[Union[Account, IdType]] = None,
min_id: Optional[Union[Account, IdType]] = None, since_id: Optional[Union[Account, IdType]] = None,
limit: Optional[int] = None) -> PaginatableList[Account]:
@ -221,7 +221,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'], dateconv=True)
return self.__api_request('GET', f'/api/v1/accounts/{id}/followers', params)
@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "1.4.0")
def account_relationships(self, id: Union[List[Union[Account, IdType]], Union[Account, IdType]], with_suspended: Optional[bool] = None) -> NonPaginatableList[Relationship]:
"""
Fetch relationship (following, followed_by, blocking, follow requested) of
@ -234,7 +234,7 @@ class Mastodon(Internals):
return self.__api_request('GET', '/api/v1/accounts/relationships',
params)
@api_version("1.0.0", "2.8.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.8.0")
def account_search(self, q: str, limit: Optional[int] = None, following: bool = False, resolve: bool = False, offset: Optional[int] = None) -> NonPaginatableList[Account]:
"""
Fetch matching accounts. Will lookup an account remotely if the search term is
@ -251,7 +251,7 @@ class Mastodon(Internals):
return self.__api_request('GET', '/api/v1/accounts/search', params)
@api_version("2.1.0", "2.1.0", _DICT_VERSION_LIST)
@api_version("2.1.0", "2.1.0")
def account_lists(self, id: Union[Account, IdType]) -> NonPaginatableList[UserList]:
"""
Get all of the logged-in user's lists which the specified user is
@ -261,7 +261,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'])
return self.__api_request('GET', f'/api/v1/accounts/{id}/lists', params)
@api_version("3.4.0", "3.4.0", _DICT_VERSION_ACCOUNT)
@api_version("3.4.0", "3.4.0")
def account_lookup(self, acct: str) -> Account:
"""
Look up an account from user@instance form (@instance allowed but not required for
@ -271,7 +271,7 @@ class Mastodon(Internals):
"""
return self.__api_request('GET', '/api/v1/accounts/lookup', self.__generate_params(locals()))
@api_version("3.5.0", "3.5.0", _DICT_VERSION_FAMILIAR_FOLLOWERS)
@api_version("3.5.0", "3.5.0")
def account_familiar_followers(self, id: Union[List[Union[Account, IdType]], Union[Account, IdType]]) -> NonPaginatableList[FamiliarFollowers]:
"""
Find followers for the account given by id (can be a list) that also follow the
@ -283,7 +283,7 @@ class Mastodon(Internals):
###
# Writing data: Accounts
###
@api_version("1.0.0", "3.3.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "3.3.0")
def account_follow(self, id: Union[Account, IdType], reblogs: bool =True, notify: bool = False) -> Relationship:
"""
Follow a user.
@ -301,7 +301,7 @@ class Mastodon(Internals):
return self.__api_request('POST', f'/api/v1/accounts/{id}/follow', params)
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.1.0")
def follows(self, uri: str) -> Relationship:
"""
Follow a remote user with username given in username@domain form.
@ -316,7 +316,7 @@ class Mastodon(Internals):
raise MastodonNotFoundError("User not found")
return self.account_follow(acct)
@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "1.4.0")
def account_unfollow(self, id: Union[Account, IdType]) -> Relationship:
"""
Unfollow a user.
@ -326,7 +326,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/unfollow')
@api_version("3.5.0", "3.5.0", _DICT_VERSION_RELATIONSHIP)
@api_version("3.5.0", "3.5.0")
def account_remove_from_followers(self, id: Union[Account, IdType]) -> Relationship:
"""
Remove a user from the logged in users followers (i.e. make them unfollow the logged in
@ -337,7 +337,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/remove_from_followers')
@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "1.4.0")
def account_block(self, id: Union[Account, IdType]) -> Relationship:
"""
Block a user.
@ -347,7 +347,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/block')
@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "1.4.0")
def account_unblock(self, id: Union[Account, IdType]) -> Relationship:
"""
Unblock a user.
@ -357,7 +357,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/unblock')
@api_version("1.1.0", "2.4.3", _DICT_VERSION_RELATIONSHIP)
@api_version("1.1.0", "2.4.3")
def account_mute(self, id: Union[Account, IdType], notifications: bool = True, duration: Optional[int] = None) -> Relationship:
"""
Mute a user.
@ -372,7 +372,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'])
return self.__api_request('POST', f'/api/v1/accounts/{id}/mute', params)
@api_version("1.1.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.1.0", "1.4.0")
def account_unmute(self, id: Union[Account, IdType]) -> Relationship:
"""
Unmute a user.
@ -382,7 +382,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/unmute')
@api_version("1.1.1", "3.1.0", _DICT_VERSION_ACCOUNT)
@api_version("1.1.1", "3.1.0")
def account_update_credentials(self, display_name: Optional[str] = None, note: Optional[str] = None,
avatar: Optional[PathOrFile] = None, avatar_mime_type: Optional[str] = None,
header: Optional[PathOrFile] = None, header_mime_type: Optional[str] = None,
@ -431,7 +431,7 @@ class Mastodon(Internals):
params = self.__generate_params(params_initial)
return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params, files=files)
@api_version("2.5.0", "2.5.0", _DICT_VERSION_RELATIONSHIP)
@api_version("2.5.0", "2.5.0")
def account_pin(self, id: Union[Account, IdType]) -> Relationship:
"""
Pin / endorse a user.
@ -441,7 +441,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/pin')
@api_version("2.5.0", "2.5.0", _DICT_VERSION_RELATIONSHIP)
@api_version("2.5.0", "2.5.0")
def account_unpin(self, id: Union[Account, IdType]) -> Relationship:
"""
Unpin / un-endorse a user.
@ -451,7 +451,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/unpin')
@api_version("3.2.0", "3.2.0", _DICT_VERSION_RELATIONSHIP)
@api_version("3.2.0", "3.2.0")
def account_note_set(self, id: Union[Account, IdType], comment: str) -> Account:
"""
Set a note (visible to the logged in user only) for the given account.
@ -462,7 +462,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ["id"])
return self.__api_request('POST', f'/api/v1/accounts/{id}/note', params)
@api_version("3.3.0", "3.3.0", _DICT_VERSION_HASHTAG)
@api_version("3.3.0", "3.3.0")
def account_featured_tags(self, id: Union[Account, IdType]) -> NonPaginatableList[Tag]:
"""
Get an account's featured hashtags.
@ -470,14 +470,14 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/accounts/{id}/featured_tags')
@api_version("4.2.0", "4.2.0", _DICT_VERSION_ACCOUNT)
@api_version("4.2.0", "4.2.0")
def account_delete_avatar(self):
"""
Delete the logged-in user's avatar.
"""
self.__api_request('DELETE', '/api/v1/profile/avatar')
@api_version("4.2.0", "4.2.0", _DICT_VERSION_ACCOUNT)
@api_version("4.2.0", "4.2.0")
def account_delete_header(self):
"""
Delete the logged-in user's header.

Wyświetl plik

@ -15,7 +15,7 @@ class Mastodon(Internals):
###
# Moderation API
###
@api_version("2.9.1", "4.0.0", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "4.0.0")
def admin_accounts_v2(self, origin: Optional[str] = None, by_domain: Optional[str] = None, status: Optional[str] = None, username: Optional[str] = None,
display_name: Optional[str] = None, email: Optional[str] = None, ip: Optional[str] = None, permissions: Optional[str] = None,
invited_by: Union[Account, IdType] = None, role_ids: Optional[List[IdType]] = None, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None,
@ -61,7 +61,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), dateconv=True)
return self.__api_request('GET', '/api/v2/admin/accounts', params)
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_accounts(self, remote: bool = False, by_domain: Optional[str] = None, status: str = 'active', username: Optional[str] = None,
display_name: Optional[str] = None, email: Optional[str] = None, ip: Optional[str] = None, staff_only: bool = False,
max_id: Optional[IdType] = None, min_id: Optional[IdType] = None, since_id: Optional[IdType] = None,
@ -87,7 +87,7 @@ class Mastodon(Internals):
since_id=since_id
)
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_accounts_v1(self, remote: bool = False, by_domain: Optional[str] = None, status: str = 'active', username: Optional[str] = None,
display_name: Optional[str] = None, email: Optional[str] = None, ip: Optional[str] = None, staff_only: bool = False,
max_id: Optional[IdType] = None, min_id: Optional[IdType] = None, since_id: Optional[IdType] = None,
@ -134,7 +134,7 @@ class Mastodon(Internals):
return self.__api_request('GET', '/api/v1/admin/accounts', params)
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_account(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Fetches a single :ref:`admin account dict <admin account dict>` for the user with the given id.
@ -142,7 +142,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/admin/accounts/{id}')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_account_enable(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Reenables login for a local account for which login has been disabled.
@ -152,7 +152,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/enable')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_account_approve(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Approves a pending account.
@ -162,7 +162,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/approve')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_account_reject(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Rejects and deletes a pending account.
@ -172,7 +172,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/reject')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_account_unsilence(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Unsilences an account.
@ -182,7 +182,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/unsilence')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("2.9.1", "2.9.1")
def admin_account_unsuspend(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Unsuspends an account.
@ -192,7 +192,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/unsuspend')
@api_version("3.3.0", "3.3.0", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("3.3.0", "3.3.0")
def admin_account_delete(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Delete a local user account.
@ -202,7 +202,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('DELETE', f'/api/v1/admin/accounts/{id}')
@api_version("3.3.0", "3.3.0", _DICT_VERSION_ADMIN_ACCOUNT)
@api_version("3.3.0", "3.3.0")
def admin_account_unsensitive(self, id: Union[Account, AdminAccount, IdType]) -> AdminAccount:
"""
Unmark an account as force-sensitive.
@ -212,7 +212,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/unsensitive')
@api_version("2.9.1", "2.9.1", "2.9.1")
@api_version("2.9.1", "2.9.1")
def admin_account_moderate(self, id: Union[Account, AdminAccount, IdType], action: Optional[str] = None, report_id: Optional[Union[AdminReport, PrimitiveIdType]] = None,
warning_preset_id: Optional[PrimitiveIdType] = None, text: Optional[str] = None, send_email_notification: Optional[bool] = True):
"""
@ -249,7 +249,7 @@ class Mastodon(Internals):
self.__api_request('POST', f'/api/v1/admin/accounts/{id}/action', params)
@api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT)
@api_version("2.9.1", "2.9.1")
def admin_reports(self, resolved: Optional[bool] = False, account_id: Optional[Union[Account, AdminAccount, IdType]] = None,
target_account_id: Optional[Union[Account, AdminAccount, IdType]] = None, max_id: Optional[IdType] = None,
min_id: Optional[IdType] = None, since_id: Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[AdminReport]:
@ -273,7 +273,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/admin/reports', params)
@api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT)
@api_version("2.9.1", "2.9.1")
def admin_report(self, id: Union[AdminReport, IdType]) -> AdminReport:
"""
Fetches the report with the given id.
@ -281,7 +281,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/admin/reports/{id}')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT)
@api_version("2.9.1", "2.9.1")
def admin_report_assign(self, id: Union[AdminReport, IdType]) -> AdminReport:
"""
Assigns the given report to the logged-in user.
@ -291,7 +291,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/reports/{id}/assign_to_self')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT)
@api_version("2.9.1", "2.9.1")
def admin_report_unassign(self, id: Union[AdminReport, IdType]) -> AdminReport:
"""
Unassigns the given report from the logged-in user.
@ -301,7 +301,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/reports/{id}/unassign')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT)
@api_version("2.9.1", "2.9.1")
def admin_report_reopen(self, id: Union[AdminReport, IdType]) -> AdminReport:
"""
Reopens a closed report.
@ -311,7 +311,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/reports/{id}/reopen')
@api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT)
@api_version("2.9.1", "2.9.1")
def admin_report_resolve(self, id: Union[AdminReport, IdType]) -> AdminReport:
"""
Marks a report as resolved (without taking any action).
@ -321,7 +321,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/admin/reports/{id}/resolve')
@api_version("3.5.0", "3.5.0", _DICT_VERSION_HASHTAG)
@api_version("3.5.0", "3.5.0")
def admin_trending_tags(self, limit: Optional[int] = None) -> NonPaginatableList[Tag]:
"""
Admin version of :ref:`trending_tags() <trending_tags()>`. Includes unapproved tags.
@ -331,7 +331,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/admin/trends/tags', params)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS)
@api_version("3.5.0", "3.5.0")
def admin_trending_statuses(self) -> NonPaginatableList[Status]:
"""
Admin version of :ref:`trending_statuses() <trending_statuses()>`. Includes unapproved tags.
@ -341,7 +341,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/admin/trends/statuses', params)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_CARD)
@api_version("3.5.0", "3.5.0")
def admin_trending_links(self) -> NonPaginatableList[PreviewCard]:
"""
Admin version of :ref:`trending_links() <trending_links()>`. Includes unapproved tags.
@ -351,7 +351,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/admin/trends/links', params)
@api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK)
@api_version("4.0.0", "4.0.0")
def admin_domain_blocks(self, id: Optional[IdType] = None, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None,
since_id: Optional[IdType] = None, limit: Optional[int] = None) -> Union[AdminDomainBlock, PaginatableList[AdminDomainBlock]]:
"""
@ -368,7 +368,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['limit'])
return self.__api_request('GET', '/api/v1/admin/domain_blocks/', params)
@api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK)
@api_version("4.0.0", "4.0.0")
def admin_create_domain_block(self, domain: str, severity: Optional[str] = None, reject_media: Optional[bool] = None,
reject_reports: Optional[bool] = None, private_comment: Optional[str] = None,
public_comment: Optional[str] = None, obfuscate: Optional[bool] = None) -> AdminDomainBlock:
@ -397,7 +397,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/admin/domain_blocks/', params)
@api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK)
@api_version("4.0.0", "4.0.0")
def admin_update_domain_block(self, id, severity: Optional[str] = None, reject_media: Optional[bool] = None, reject_reports: Optional[bool] = None,
private_comment: Optional[str] = None, public_comment: Optional[str] = None, obfuscate: Optional[bool] = None) -> AdminDomainBlock:
"""
@ -424,7 +424,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ["id"])
return self.__api_request('PUT', f'/api/v1/admin/domain_blocks/{id}', params)
@api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK)
@api_version("4.0.0", "4.0.0")
def admin_delete_domain_block(self, id = Union[AdminDomainBlock, IdType]):
"""
Removes moderation action against a given domain. Requires scope `admin:write:domain_blocks`.
@ -439,7 +439,7 @@ class Mastodon(Internals):
else:
raise MastodonIllegalArgumentError("You must provide an id of an existing domain block to remove it.")
@api_version("3.5.0", "3.5.0", _DICT_VERSION_ADMIN_MEASURE)
@api_version("3.5.0", "3.5.0")
def admin_measures(self, start_at, end_at, active_users: bool = False, new_users: bool = False, interactions: bool = False, opened_reports: bool = False, resolved_reports: bool = False,
tag_accounts: Optional[Union[Tag, IdType]] = None, tag_uses: Optional[Union[Tag, IdType]] = None, tag_servers: Optional[Union[Tag, IdType]] = None,
instance_accounts: Optional[str] = None, instance_media_attachments: Optional[str] = None, instance_reports: Optional[str] = None,
@ -495,7 +495,7 @@ class Mastodon(Internals):
return self.__api_request('POST', '/api/v1/admin/measures', params, use_json=True)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_ADMIN_DIMENSION)
@api_version("3.5.0", "3.5.0")
def admin_dimensions(self, start_at: datetime, end_at: datetime, limit: Optional[int] = None, languages: bool = False, sources: bool = False,
servers: bool = False, space_usage: bool = False, software_versions: bool = False, tag_servers: Optional[Union[Tag, IdType]] = None,
tag_languages: Optional[Union[Tag, IdType]] = None, instance_accounts: Optional[str] = None, instance_languages: Optional[str] = None) -> NonPaginatableList[AdminDimension]:
@ -548,7 +548,7 @@ class Mastodon(Internals):
return self.__api_request('POST', '/api/v1/admin/dimensions', params, use_json=True)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_ADMIN_RETENTION)
@api_version("3.5.0", "3.5.0")
def admin_retention(self, start_at: datetime, end_at: datetime, frequency: str = "day") -> NonPaginatableList[AdminRetention]:
"""
Gets user retention statistics (at `frequency` - "day" or "month" - granularity) between `start_at` and `end_at`.
@ -563,7 +563,7 @@ class Mastodon(Internals):
}
return self.__api_request('POST', '/api/v1/admin/retention', params)
@api_version("4.0.0", "4.0.0", "4.0.0")
@api_version("4.0.0", "4.0.0")
def admin_canonical_email_blocks(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None,
since_id: Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[AdminCanonicalEmailBlock]:
"""
@ -574,7 +574,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/admin/canonical_email_blocks', params)
@api_version("4.0.0", "4.0.0", "4.0.0")
@api_version("4.0.0", "4.0.0")
def admin_canonical_email_block(self, id: IdType) -> AdminCanonicalEmailBlock:
"""
Fetch a single canonical email block by ID. Requires scope `admin:read:canonical_email_blocks`.
@ -584,7 +584,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/admin/canonical_email_blocks/{id}')
@api_version("4.0.0", "4.0.0", "4.0.0")
@api_version("4.0.0", "4.0.0")
def admin_test_canonical_email_block(self, email: str) -> NonPaginatableList[AdminCanonicalEmailBlock]:
"""
Canonicalize and hash an email address, returning all matching canonical email blocks. Requires scope `admin:read:canonical_email_blocks`.
@ -592,7 +592,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/admin/canonical_email_blocks/test', params)
@api_version("4.0.0", "4.0.0", "4.0.0")
@api_version("4.0.0", "4.0.0")
def admin_create_canonical_email_block(self, email: Optional[str] = None, canonical_email_hash: Optional[str] = None) -> AdminCanonicalEmailBlock:
"""
Block a canonical email. Requires scope `admin:write:canonical_email_blocks`.
@ -614,7 +614,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/admin/canonical_email_blocks', params)
@api_version("4.0.0", "4.0.0", "4.0.0")
@api_version("4.0.0", "4.0.0")
def admin_delete_canonical_email_block(self, id: IdType) -> AdminCanonicalEmailBlock:
"""
Delete a canonical email block by ID. Requires scope `admin:write:canonical_email_blocks`.

Wyświetl plik

@ -414,7 +414,7 @@ class Mastodon(Internals):
###
# Reading data: Apps
###
@api_version("2.0.0", "2.7.2", _DICT_VERSION_APPLICATION)
@api_version("2.0.0", "2.7.2")
def app_verify_credentials(self) -> Application:
"""
Fetch information about the current application.

Wyświetl plik

@ -11,7 +11,7 @@ class Mastodon(Internals):
###
# Reading data: Conversations
###
@api_version("2.6.0", "2.6.0", _DICT_VERSION_CONVERSATION)
@api_version("2.6.0", "2.6.0")
def conversations(self, max_id: Optional[Union[Conversation, IdType]] = None, min_id: Optional[Union[Conversation, IdType]] = None, since_id:
Optional[Union[Conversation, IdType]] = None, limit: Optional[int] = None) -> PaginatableList[Conversation]:
"""
@ -23,7 +23,7 @@ class Mastodon(Internals):
###
# Writing data: Conversations
###
@api_version("2.6.0", "2.6.0", _DICT_VERSION_CONVERSATION)
@api_version("2.6.0", "2.6.0")
def conversations_read(self, id: Union[Conversation, IdType]):
"""
Marks a single conversation as read.

Wyświetl plik

@ -10,7 +10,7 @@ class Mastodon(Internals):
###
# Reading data: Endorsements
###
@api_version("2.5.0", "2.5.0", _DICT_VERSION_ACCOUNT)
@api_version("2.5.0", "2.5.0")
def endorsements(self) -> NonPaginatableList[Account]:
"""
Fetch list of users endorsed by the logged-in user.

Wyświetl plik

@ -12,7 +12,7 @@ class Mastodon(Internals):
###
# Reading data: Favourites
###
@api_version("1.0.0", "2.6.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.6.0")
def favourites(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None,
since_id: Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[Status]:
"""
@ -27,7 +27,7 @@ class Mastodon(Internals):
###
# Reading data: Bookmarks
###
@api_version("3.1.0", "3.1.0", _DICT_VERSION_STATUS)
@api_version("3.1.0", "3.1.0")
def bookmarks(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None,
since_id: Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[Status]:
"""

Wyświetl plik

@ -17,14 +17,14 @@ class Mastodon(Internals):
###
# Reading data: Keyword filters
###
@api_version("2.4.3", "2.4.3", _DICT_VERSION_FILTER)
@api_version("2.4.3", "2.4.3")
def filters(self) -> Union[NonPaginatableList[Filter], NonPaginatableList[FilterV2]]:
"""
Fetch all of the logged-in user's filters.
"""
return self.__api_request('GET', '/api/v1/filters')
@api_version("2.4.3", "2.4.3", _DICT_VERSION_FILTER)
@api_version("2.4.3", "2.4.3")
def filter(self, id: Union[Filter, FilterV2, IdType]) -> Union[Filter, FilterV2]:
"""
Fetches information about the filter with the specified `id`.
@ -34,7 +34,7 @@ class Mastodon(Internals):
# TODO: Add v2 filter support
# TODO: test this properly
@api_version("2.4.3", "2.4.3", _DICT_VERSION_FILTER)
@api_version("2.4.3", "2.4.3")
def filters_apply(self, objects: Union[PaginatableList[Status], PaginatableList[Notification]], filters: Union[NonPaginatableList[Filter], NonPaginatableList[FilterV2]], context: str) -> Union[PaginatableList[Status], PaginatableList[Notification]]:
"""
Helper function: Applies a list of filters to a list of either statuses
@ -71,7 +71,7 @@ class Mastodon(Internals):
###
# Writing data: Keyword filters
###
@api_version("2.4.3", "2.4.3", _DICT_VERSION_FILTER)
@api_version("2.4.3", "2.4.3")
def filter_create(self, phrase: str, context: str, irreversible: bool = False, whole_word: bool = True, expires_in: Optional[int] = None) -> Union[Filter, FilterV2]:
"""
Creates a new keyword filter. `phrase` is the phrase that should be
@ -97,7 +97,7 @@ class Mastodon(Internals):
return self.__api_request('POST', '/api/v1/filters', params)
@api_version("2.4.3", "2.4.3", _DICT_VERSION_FILTER)
@api_version("2.4.3", "2.4.3")
def filter_update(self, id: Union[Filter, FilterV2, IdType], phrase: Optional[str] = None, context: Optional[str] = None, irreversible: Optional[bool] = None, whole_word: Optional[bool] = None, expires_in: Optional[int] = None) -> Union[Filter, FilterV2]:
"""
Updates the filter with the given `id`. Parameters are the same
@ -109,7 +109,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'])
return self.__api_request('PUT', f'/api/v1/filters/{id}', params)
@api_version("2.4.3", "2.4.3", "2.4.3")
@api_version("2.4.3", "2.4.3")
def filter_delete(self, id: Union[Filter, FilterV2, IdType]):
"""
Deletes the filter with the given `id`.

Wyświetl plik

@ -14,7 +14,7 @@ class Mastodon(Internals):
###
# Reading data: Featured hashtags
###
@api_version("3.0.0", "3.0.0", _DICT_VERSION_FEATURED_TAG)
@api_version("3.0.0", "3.0.0")
def featured_tags(self) -> NonPaginatableList[FeaturedTag]:
"""
Return the hashtags the logged-in user has set to be featured on
@ -22,7 +22,7 @@ class Mastodon(Internals):
"""
return self.__api_request('GET', '/api/v1/featured_tags')
@api_version("3.0.0", "3.0.0", _DICT_VERSION_HASHTAG)
@api_version("3.0.0", "3.0.0")
def featured_tag_suggestions(self) -> NonPaginatableList[FeaturedTag]:
"""
Returns the logged-in user's 10 most commonly-used hashtags.
@ -32,7 +32,7 @@ class Mastodon(Internals):
###
# Writing data: Featured hashtags
###
@api_version("3.0.0", "3.0.0", _DICT_VERSION_FEATURED_TAG)
@api_version("3.0.0", "3.0.0")
def featured_tag_create(self, name: str) -> FeaturedTag:
"""
Creates a new featured hashtag displayed on the logged-in user's profile.
@ -42,7 +42,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/featured_tags', params)
@api_version("3.0.0", "3.0.0", _DICT_VERSION_FEATURED_TAG)
@api_version("3.0.0", "3.0.0")
def featured_tag_delete(self, id: Union[FeaturedTag, IdType]):
"""
Deletes one of the logged-in user's featured hashtags.
@ -53,7 +53,7 @@ class Mastodon(Internals):
###
# Reading data: Followed tags
###
@api_version("4.0.0", "4.0.0", _DICT_VERSION_HASHTAG)
@api_version("4.0.0", "4.0.0")
def followed_tags(self, max_id: Optional[Union[Tag, IdType, datetime]] = None,
min_id: Optional[Union[Tag, IdType, datetime]] = None, since_id: Optional[Union[Tag, IdType, datetime]] = None,
limit: Optional[int] = None) -> PaginatableList[Tag]:
@ -64,7 +64,7 @@ class Mastodon(Internals):
return self.__api_request('GET', '/api/v1/followed_tags', params)
@api_version("4.0.0", "4.0.0", _DICT_VERSION_HASHTAG)
@api_version("4.0.0", "4.0.0")
def tag(self, hashtag: Union[Tag, str]) -> Tag:
"""
Get information about a single tag.
@ -77,7 +77,7 @@ class Mastodon(Internals):
###
# Writing data: Followed tags
###
@api_version("4.0.0", "4.0.0", _DICT_VERSION_HASHTAG)
@api_version("4.0.0", "4.0.0")
def tag_follow(self, hashtag: Union[Tag, str]) -> Tag:
"""
Follow a tag.
@ -89,7 +89,7 @@ class Mastodon(Internals):
raise MastodonIllegalArgumentError("Hashtag parameter should omit leading #")
return self.__api_request('POST', f'/api/v1/tags/{hashtag}/follow')
@api_version("4.0.0", "4.0.0", _DICT_VERSION_HASHTAG)
@api_version("4.0.0", "4.0.0")
def tag_unfollow(self, hashtag: Union[Tag, str]) -> Tag:
"""
Unfollow a tag.

Wyświetl plik

@ -14,7 +14,7 @@ class Mastodon(Internals):
###
# Reading data: Instances
###
@api_version("1.1.0", "2.3.0", _DICT_VERSION_INSTANCE)
@api_version("1.1.0", "2.3.0")
def instance_v1(self) -> Instance:
"""
Retrieve basic information about the instance, including the URI and administrative contact email.
@ -33,7 +33,7 @@ class Mastodon(Internals):
instance = self.__api_request('GET', '/api/v1/instance/', override_type=Instance)
return instance
@api_version("4.0.0", "4.0.0", _DICT_VERSION_INSTANCE)
@api_version("4.0.0", "4.0.0")
def instance_v2(self) -> InstanceV2:
"""
Retrieve basic information about the instance, including the URI and administrative contact email.
@ -42,7 +42,7 @@ class Mastodon(Internals):
"""
return self.__api_request('GET', '/api/v2/instance/')
@api_version("1.1.0", "4.0.0", _DICT_VERSION_INSTANCE)
@api_version("1.1.0", "4.0.0")
def instance(self) -> Union[InstanceV2, Instance]:
"""
Retrieve basic information about the instance, including the URI and administrative contact email.
@ -57,7 +57,7 @@ class Mastodon(Internals):
else:
return self.instance_v1()
@api_version("2.1.2", "2.1.2", _DICT_VERSION_ACTIVITY)
@api_version("2.1.2", "2.1.2")
def instance_activity(self) -> NonPaginatableList[Activity]:
"""
Retrieve activity stats about the instance. May be disabled by the instance administrator - throws
@ -67,7 +67,7 @@ class Mastodon(Internals):
"""
return self.__api_request('GET', '/api/v1/instance/activity')
@api_version("2.1.2", "2.1.2", "2.1.2")
@api_version("2.1.2", "2.1.2")
def instance_peers(self) -> NonPaginatableList[str]:
"""
Retrieve the instances that this instance knows about. May be disabled by the instance administrator - throws
@ -77,7 +77,7 @@ class Mastodon(Internals):
"""
return self.__api_request('GET', '/api/v1/instance/peers')
@api_version("3.0.0", "3.0.0", "3.0.0")
@api_version("3.0.0", "3.0.0")
def instance_health(self) -> bool:
"""
Basic health check. Returns True if healthy, False if not.
@ -85,7 +85,7 @@ class Mastodon(Internals):
status = self.__api_request('GET', '/health', parse=False).decode("utf-8")
return status in ["OK", "success"]
@api_version("3.0.0", "3.0.0", "3.0.0")
@api_version("3.0.0", "3.0.0")
def instance_nodeinfo(self, schema: str = "http://nodeinfo.diaspora.software/ns/schema/2.0") -> Nodeinfo:
"""
Retrieves the instance's nodeinfo information.
@ -115,7 +115,7 @@ class Mastodon(Internals):
parse = urlparse(schema_url)
return self.__api_request('GET', parse.path + parse.params + parse.query + parse.fragment)
@api_version("3.4.0", "3.4.0", _DICT_VERSION_INSTANCE)
@api_version("3.4.0", "3.4.0")
def instance_rules(self) -> NonPaginatableList[Rule]:
"""
Retrieve instance rules.
@ -125,7 +125,7 @@ class Mastodon(Internals):
###
# Reading data: Directory
###
@api_version("3.0.0", "3.0.0", _DICT_VERSION_ACCOUNT)
@api_version("3.0.0", "3.0.0")
def directory(self, offset: Optional[int] = None, limit: Optional[int] = None,
order: Optional[str] = None, local: Optional[bool] = None) -> NonPaginatableList[Account]:
"""
@ -149,7 +149,7 @@ class Mastodon(Internals):
###
# Reading data: Emoji
###
@api_version("2.1.0", "2.1.0", _DICT_VERSION_EMOJI)
@api_version("2.1.0", "2.1.0")
def custom_emojis(self) -> NonPaginatableList[CustomEmoji]:
"""
Fetch the list of custom emoji the instance has installed.
@ -161,7 +161,7 @@ class Mastodon(Internals):
##
# Reading data: Announcements
##
@api_version("3.1.0", "3.1.0", _DICT_VERSION_ANNOUNCEMENT)
@api_version("3.1.0", "3.1.0")
def announcements(self) -> NonPaginatableList[Announcement]:
"""
Fetch currently active announcements.
@ -173,7 +173,7 @@ class Mastodon(Internals):
###
# Writing data: Annoucements
###
@api_version("3.1.0", "3.1.0", "3.1.0")
@api_version("3.1.0", "3.1.0")
def announcement_dismiss(self, id: Union[Announcement, IdType]):
"""
Set the given annoucement to read.
@ -181,7 +181,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
self.__api_request('POST', f'/api/v1/announcements/{id}/dismiss')
@api_version("3.1.0", "3.1.0", "3.1.0")
@api_version("3.1.0", "3.1.0")
def announcement_reaction_create(self, id: Union[Announcement, IdType], reaction: str):
"""
Add a reaction to an announcement. `reaction` can either be a unicode emoji
@ -194,7 +194,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
self.__api_request('PUT', f'/api/v1/announcements/{id}/reactions/{reaction}')
@api_version("3.1.0", "3.1.0", "3.1.0")
@api_version("3.1.0", "3.1.0")
def announcement_reaction_delete(self, id: Union[Announcement, IdType], reaction: str):
"""
Remove a reaction to an announcement.

Wyświetl plik

@ -12,14 +12,14 @@ class Mastodon(Internals):
###
# Reading data: Lists
###
@api_version("2.1.0", "2.1.0", _DICT_VERSION_LIST)
@api_version("2.1.0", "2.1.0")
def lists(self) -> NonPaginatableList[UserList]:
"""
Fetch a list of all the Lists by the logged-in user.
"""
return self.__api_request('GET', '/api/v1/lists')
@api_version("2.1.0", "2.1.0", _DICT_VERSION_LIST)
@api_version("2.1.0", "2.1.0")
def list(self, id: Union[UserList, IdType]) -> UserList:
"""
Fetch info about a specific list.
@ -27,7 +27,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/lists/{id}')
@api_version("2.1.0", "2.6.0", _DICT_VERSION_ACCOUNT)
@api_version("2.1.0", "2.6.0")
def list_accounts(self, id: Union[UserList, IdType], max_id: Optional[Union[UserList, IdType]] = None,
min_id: Optional[Union[UserList, IdType]] = None, since_id: Optional[Union[UserList, IdType]] = None,
limit: Optional[int] = None) -> PaginatableList[Account]:
@ -41,7 +41,7 @@ class Mastodon(Internals):
###
# Writing data: Lists
###
@api_version("2.1.0", "2.1.0", _DICT_VERSION_LIST)
@api_version("2.1.0", "2.1.0")
def list_create(self, title: str) -> UserList:
"""
Create a new list with the given `title`.
@ -49,7 +49,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('POST', '/api/v1/lists', params)
@api_version("2.1.0", "2.1.0", _DICT_VERSION_LIST)
@api_version("2.1.0", "2.1.0")
def list_update(self, id: Union[UserList, IdType], title: str) -> UserList:
"""
Update info about a list, where "info" is really the lists `title`.
@ -60,7 +60,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'])
return self.__api_request('PUT', f'/api/v1/lists/{id}', params)
@api_version("2.1.0", "2.1.0", "2.1.0")
@api_version("2.1.0", "2.1.0")
def list_delete(self, id: Union[UserList, IdType]):
"""
Delete a list.
@ -68,7 +68,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
self.__api_request('DELETE', f'/api/v1/lists/{id}')
@api_version("2.1.0", "2.1.0", "2.1.0")
@api_version("2.1.0", "2.1.0")
def list_accounts_add(self, id: Union[UserList, IdType], account_ids: List[Union[Account, IdType]]):
"""
Add the account(s) given in `account_ids` to the list.
@ -79,7 +79,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'])
self.__api_request('POST', f'/api/v1/lists/{id}/accounts', params)
@api_version("2.1.0", "2.1.0", "2.1.0")
@api_version("2.1.0", "2.1.0")
def list_accounts_delete(self, id: Union[UserList, IdType], account_ids: List[Union[Account, IdType]]):
"""
Remove the account(s) given in `account_ids` from the list.

Wyświetl plik

@ -15,7 +15,7 @@ class Mastodon(Internals):
###
# Reading data: Media
###
@api_version("3.1.4", "3.1.4", _DICT_VERSION_MEDIA)
@api_version("3.1.4", "3.1.4")
def media(self, id: Union[MediaAttachment, IdType]) -> MediaAttachment:
"""
Get the updated JSON for one non-attached / in progress media upload belonging
@ -27,7 +27,7 @@ class Mastodon(Internals):
###
# Writing data: Media
###
@api_version("1.0.0", "3.2.0", _DICT_VERSION_MEDIA)
@api_version("1.0.0", "3.2.0")
def media_post(self, media_file: PathOrFile, mime_type: Optional[str] = None, description: Optional[str] = None,
focus: Optional[Tuple[float, float]] = None, file_name: Optional[str] = None,
thumbnail: Optional[PathOrFile] = None, thumbnail_mime_type: Optional[str] = None,
@ -93,7 +93,7 @@ class Mastodon(Internals):
return ret_dict
@api_version("2.3.0", "3.2.0", _DICT_VERSION_MEDIA)
@api_version("2.3.0", "3.2.0")
def media_update(self, id: Union[MediaAttachment, IdType], description: Optional[str] = None,
focus: Optional[Tuple[float, float]] = None, thumbnail: Optional[PathOrFile] = None,
thumbnail_mime_type=None) -> MediaAttachment:

Wyświetl plik

@ -12,7 +12,7 @@ class Mastodon(Internals):
###
# Reading data: Notifications
###
@api_version("1.0.0", "3.5.0", _DICT_VERSION_NOTIFICATION)
@api_version("1.0.0", "3.5.0")
def notifications(self, id: Optional[Union[Notification, IdType]] = None, account_id: Optional[Union[Account, IdType]] = None, max_id: Optional[Union[Notification, IdType]] = None,
min_id: Optional[Union[Notification, IdType]] = None, since_id: Optional[Union[Notification, IdType]] = None, limit: Optional[int] = None,
exclude_types: Optional[List[str]] = None, types: Optional[List[str]] = None, mentions_only: Optional[bool] = None) -> PaginatableList[Notification]:
@ -65,14 +65,14 @@ class Mastodon(Internals):
###
# Writing data: Notifications
###
@api_version("1.0.0", "1.0.0", "1.0.0")
@api_version("1.0.0", "1.0.0")
def notifications_clear(self):
"""
Clear out a user's notifications
"""
self.__api_request('POST', '/api/v1/notifications/clear')
@api_version("1.3.0", "2.9.2", "2.9.2")
@api_version("1.3.0", "2.9.2")
def notifications_dismiss(self, id: Union[Notification, IdType]):
"""
Deletes a single notification

Wyświetl plik

@ -11,7 +11,7 @@ class Mastodon(Internals):
###
# Reading data: Polls
###
@api_version("2.8.0", "2.8.0", _DICT_VERSION_POLL)
@api_version("2.8.0", "2.8.0")
def poll(self, id: Union[Poll, IdType]) -> Poll:
"""
Fetch information about the poll with the given id
@ -22,7 +22,7 @@ class Mastodon(Internals):
###
# Writing data: Polls
###
@api_version("2.8.0", "2.8.0", _DICT_VERSION_POLL)
@api_version("2.8.0", "2.8.0")
def poll_vote(self, id: Union[Poll, IdType], choices: Union[int, List[int]]) -> Poll:
"""
Vote in the given poll.
@ -45,7 +45,7 @@ class Mastodon(Internals):
return self.__api_request('POST', f'/api/v1/polls/{id}/votes', params)
@api_version("2.8.0", "2.8.0", _DICT_VERSION_POLL)
@api_version("2.8.0", "2.8.0")
def make_poll(self, options: List[str], expires_in: int, multiple: bool = False, hide_totals: bool = False) -> Poll:
"""
Generate a poll object that can be passed as the `poll` option when posting a status.

Wyświetl plik

@ -15,7 +15,7 @@ class Mastodon(Internals):
###
# Reading data: Preferences
###
@api_version("2.8.0", "2.8.0", _DICT_VERSION_PREFERENCES)
@api_version("2.8.0", "2.8.0")
def preferences(self) -> Preferences:
"""
Fetch the user's preferences, which can be used to set some default options.
@ -26,7 +26,7 @@ class Mastodon(Internals):
##
# Reading data: Read markers
##
@api_version("3.0.0", "3.0.0", _DICT_VERSION_MARKER)
@api_version("3.0.0", "3.0.0")
def markers_get(self, timeline: Union[str, List[str]] = ["home"]) -> Dict[str, Marker]:
"""
Get the last-read-location markers for the specified timelines. Valid timelines
@ -48,7 +48,7 @@ class Mastodon(Internals):
##
# Writing data: Read markers
##
@api_version("3.0.0", "3.0.0", _DICT_VERSION_MARKER)
@api_version("3.0.0", "3.0.0")
def markers_set(self, timelines: Union[str, List[str]], last_read_ids: Union[Status, IdType, List[Status], List[IdType]]) -> Dict[str, Marker]:
"""
Set the "last read" marker(s) for the given timeline(s) to the given id(s)

Wyświetl plik

@ -18,7 +18,7 @@ class Mastodon(Internals):
###
# Reading data: Webpush subscriptions
###
@api_version("2.4.0", "2.4.0", _DICT_VERSION_PUSH)
@api_version("2.4.0", "2.4.0")
def push_subscription(self) -> WebPushSubscription:
"""
Fetch the current push subscription the logged-in user has for this app.
@ -30,7 +30,7 @@ class Mastodon(Internals):
###
# Writing data: Push subscriptions
###
@api_version("2.4.0", "4..0", _DICT_VERSION_PUSH)
@api_version("2.4.0", "4..0")
def push_subscription_set(self, endpoint: str, encrypt_params: WebpushCryptoParamsPubkey, follow_events: Optional[bool] = None,
favourite_events: Optional[bool] = None, reblog_events: Optional[bool] = None,
mention_events: Optional[bool] = None, poll_events: Optional[bool] = None,
@ -115,7 +115,7 @@ class Mastodon(Internals):
return self.__api_request('POST', '/api/v1/push/subscription', params)
@api_version("2.4.0", "2.4.0", _DICT_VERSION_PUSH)
@api_version("2.4.0", "2.4.0")
def push_subscription_update(self, follow_events: Optional[bool] = None,
favourite_events: Optional[bool] = None, reblog_events: Optional[bool] = None,
mention_events: Optional[bool] = None, poll_events: Optional[bool] = None,
@ -168,7 +168,7 @@ class Mastodon(Internals):
return self.__api_request('PUT', '/api/v1/push/subscription', params)
@api_version("2.4.0", "2.4.0", "2.4.0")
@api_version("2.4.0", "2.4.0")
def push_subscription_delete(self):
"""
Remove the current push subscription the logged-in user has for this app.
@ -212,7 +212,7 @@ class Mastodon(Internals):
return priv_dict, pub_dict
@api_version("2.4.0", "2.4.0", _DICT_VERSION_PUSH_NOTIF)
@api_version("2.4.0", "2.4.0")
def push_subscription_decrypt_push(self, data: bytes, decrypt_params: WebpushCryptoParamsPrivkey, encryption_header: str, crypto_key_header: str) -> PushNotification:
"""
Decrypts `data` received in a webpush request. Requires the private key dict

Wyświetl plik

@ -11,7 +11,7 @@ class Mastodon(Internals):
###
# Reading data: Mutes and Blocks
###
@api_version("1.1.0", "2.6.0", _DICT_VERSION_ACCOUNT)
@api_version("1.1.0", "2.6.0")
def mutes(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None, since_id:
Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[Account]:
"""
@ -20,7 +20,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/mutes', params)
@api_version("1.0.0", "2.6.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.6.0")
def blocks(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None, since_id:
Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[Account]:
"""
@ -32,7 +32,7 @@ class Mastodon(Internals):
###
# Reading data: Follow requests
###
@api_version("1.0.0", "2.6.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.6.0")
def follow_requests(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None, since_id:
Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[Account]:
"""
@ -44,7 +44,7 @@ class Mastodon(Internals):
###
# Reading data: Domain blocks
###
@api_version("1.4.0", "2.6.0", "1.4.0")
@api_version("1.4.0", "2.6.0")
def domain_blocks(self, max_id: Optional[IdType] = None, min_id: Optional[IdType] = None, since_id:
Optional[IdType] = None, limit: Optional[int] = None) -> PaginatableList[str]:
"""
@ -58,7 +58,7 @@ class Mastodon(Internals):
###
# Writing data: Follow requests
###
@api_version("1.0.0", "3.0.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "3.0.0")
def follow_request_authorize(self, id: Union[Account, IdType]) -> Relationship:
"""
Accept an incoming follow request from the given Account and returns the updated Relationship.
@ -66,7 +66,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/follow_requests/{id}/authorize')
@api_version("1.0.0", "3.0.0", _DICT_VERSION_RELATIONSHIP)
@api_version("1.0.0", "3.0.0")
def follow_request_reject(self, id: Union[Account, IdType]) -> Relationship:
"""
Reject an incoming follow request from the given Account and returns the updated Relationship.
@ -77,7 +77,7 @@ class Mastodon(Internals):
###
# Writing data: Domain blocks
###
@api_version("1.4.0", "1.4.0", "1.4.0")
@api_version("1.4.0", "1.4.0")
def domain_block(self, domain: str):
"""
Add a block for all statuses originating from the specified domain for the logged-in user.
@ -85,7 +85,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
self.__api_request('POST', '/api/v1/domain_blocks', params)
@api_version("1.4.0", "1.4.0", "1.4.0")
@api_version("1.4.0", "1.4.0")
def domain_unblock(self, domain: str):
"""
Remove a domain block for the logged-in user.

Wyświetl plik

@ -13,7 +13,7 @@ class Mastodon(Internals):
###
# Reading data: Reports
###
@api_version("1.1.0", "1.1.0", _DICT_VERSION_REPORT)
@api_version("1.1.0", "1.1.0")
def reports(self) -> NonPaginatableList[Report]:
"""
Fetch a list of reports made by the logged-in user.
@ -28,7 +28,7 @@ class Mastodon(Internals):
###
# Writing data: Reports
###
@api_version("1.1.0", "3.5.0", _DICT_VERSION_REPORT)
@api_version("1.1.0", "3.5.0")
def report(self, account_id: Union[Account, IdType], status_ids: Optional[Union[Status, IdType]] = None, comment: Optional[str] = None,
forward: bool = False, category: Optional[str] = None, rule_ids: Optional[List[Union[Rule, IdType]]] = None, forward_to_domains: Optional[List[str]] = None) -> Report:
"""

Wyświetl plik

@ -21,7 +21,7 @@ class Mastodon(Internals):
if not self.verify_minimum_version("2.8.0", cached=True):
raise MastodonVersionError("Advanced search parameters require Mastodon 2.8.0+")
@api_version("1.1.0", "2.8.0", _DICT_VERSION_SEARCHRESULT)
@api_version("1.1.0", "2.8.0")
def search(self, q: str, resolve: bool = True, result_type: Optional[str] = None,
account_id: Optional[Union[Account, IdType]] = None, offset: Optional[int] = None,
min_id: Optional[IdType] = None, max_id: Optional[IdType] = None,
@ -55,7 +55,7 @@ class Mastodon(Internals):
self.__ensure_search_params_acceptable(account_id, offset, min_id, max_id)
return self.search_v1(q, resolve=resolve)
@api_version("1.1.0", "2.1.0", "2.1.0")
@api_version("1.1.0", "2.1.0")
def search_v1(self, q: str, resolve: bool = False) -> Search:
"""
Identical to `search_v2()`, except in that it does not return
@ -68,7 +68,7 @@ class Mastodon(Internals):
del params['resolve']
return self.__api_request('GET', '/api/v1/search', params)
@api_version("2.4.1", "2.8.0", _DICT_VERSION_SEARCHRESULT)
@api_version("2.4.1", "2.8.0")
def search_v2(self, q, resolve: bool = True, result_type: Optional[str] = None,
account_id: Optional[Union[Account, IdType]] = None, offset: Optional[int] = None,
min_id: Optional[IdType] = None, max_id: Optional[IdType] = None,

Wyświetl plik

@ -18,7 +18,7 @@ class Mastodon(Internals):
###
# Reading data: Statuses
###
@api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.0.0")
def status(self, id: Union[Status, IdType]) -> Status:
"""
Fetch information about a single toot.
@ -28,17 +28,17 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/statuses/{id}')
@api_version("4.3.0", "4.3.0", _DICT_VERSION_ACCOUNT)
@api_version("4.3.0", "4.3.0")
def statuses(self, ids: List[Union[Status, IdType]]) -> List[Status]:
"""
Fetch information from multiple statuses by a list of status `id`.
Does not require authentication for publicly visible accounts.
"""
ids = [self.__unpack_id(id) for id in ids]
ids = [self.__unpack_id(id, dateconv=True) for id in ids]
return self.__api_request('GET', '/api/v1/statuses', {"id[]": ids})
@api_version("1.0.0", "3.0.0", _DICT_VERSION_CARD)
@api_version("1.0.0", "3.0.0")
def status_card(self, id: Union[Status, IdType]) -> PreviewCard:
"""
Fetch a card associated with a status. A card describes an object (such as an
@ -57,7 +57,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/statuses/{id}/card')
@api_version("1.0.0", "1.0.0", _DICT_VERSION_CONTEXT)
@api_version("1.0.0", "1.0.0")
def status_context(self, id: Union[Status, IdType]) -> Context:
"""
Fetch information about ancestors and descendants of a toot.
@ -67,7 +67,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/statuses/{id}/context')
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.1.0")
def status_reblogged_by(self, id: Union[Status, IdType]) -> NonPaginatableList[Account]:
"""
Fetch a list of users that have reblogged a status.
@ -81,7 +81,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/statuses/{id}/reblogged_by')
@api_version("1.0.0", "2.1.0", _DICT_VERSION_ACCOUNT)
@api_version("1.0.0", "2.1.0")
def status_favourited_by(self, id: Union[Status, IdType]) -> NonPaginatableList[Account]:
"""
Fetch a list of users that have favourited a status.
@ -94,7 +94,7 @@ class Mastodon(Internals):
###
# Reading data: Scheduled statuses
###
@api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
@api_version("2.7.0", "2.7.0")
def scheduled_statuses(self, max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None) -> PaginatableList[ScheduledStatus]:
"""
@ -103,7 +103,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/scheduled_statuses', params)
@api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
@api_version("2.7.0", "2.7.0")
def scheduled_status(self, id: Union[ScheduledStatus, IdType]) -> ScheduledStatus:
"""
Fetch information about the scheduled status with the given id.
@ -201,7 +201,7 @@ class Mastodon(Internals):
# Edit
return self.__api_request('PUT', f'/api/v1/statuses/{self.__unpack_id(edit)}', params, headers=headers, use_json=use_json, override_type=cast_type)
@api_version("1.0.0", "2.8.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.8.0")
def status_post(self, status: str, in_reply_to_id: Optional[Union[Status, IdType]] = None, media_ids: Optional[List[Union[MediaAttachment, IdType]]] = None,
sensitive: bool = False, visibility: Optional[str] = None, spoiler_text: Optional[str] = None, language: Optional[str] = None,
idempotency_key: Optional[str] = None, content_type: Optional[str] = None, scheduled_at: Optional[datetime] = None,
@ -283,7 +283,7 @@ class Mastodon(Internals):
strict_content_type=strict_content_type
)
@api_version("1.0.0", "2.8.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.8.0")
def toot(self, status: str) -> Status:
"""
Synonym for :ref:`status_post() <status_post()>` that only takes the status text as input.
@ -292,7 +292,7 @@ class Mastodon(Internals):
"""
return self.status_post(status)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS)
@api_version("3.5.0", "3.5.0")
def status_update(self, id: Union[Status, IdType], status: Optional[str] = None, spoiler_text: Optional[str] = None,
sensitive: Optional[bool] = None, media_ids: Optional[List[Union[MediaAttachment, IdType]]] = None,
poll: Optional[Union[Poll, IdType]] = None) -> Status:
@ -313,7 +313,7 @@ class Mastodon(Internals):
edit=id
)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS_EDIT)
@api_version("3.5.0", "3.5.0")
def status_history(self, id: Union[StatusEdit, IdType]) -> NonPaginatableList[StatusEdit]:
"""
Returns the edit history of a status as a list of StatusEdit objects, starting
@ -335,7 +335,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f"/api/v1/statuses/{id}/source")
@api_version("1.0.0", "2.8.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.8.0")
def status_reply(self, to_status: Union[Status, IdType], status: str, media_ids: Optional[List[Union[MediaAttachment, IdType]]] = None,
sensitive: bool = False, visibility: Optional[str] = None, spoiler_text: Optional[str] = None, language: Optional[str] = None,
idempotency_key: Optional[str] = None, content_type: Optional[str] = None, scheduled_at: Optional[datetime] = None,
@ -386,7 +386,7 @@ class Mastodon(Internals):
keyword_args["in_reply_to_id"] = to_status.id
return self.status_post(**keyword_args)
@api_version("1.0.0", "1.0.0", "1.0.0")
@api_version("1.0.0", "1.0.0")
def status_delete(self, id: Union[Status, IdType]) -> Status:
"""
Delete a status
@ -398,7 +398,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('DELETE', f'/api/v1/statuses/{id}')
@api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.0.0")
def status_reblog(self, id: Union[Status, IdType], visibility: Optional[str] = None) -> Status:
"""
Reblog / boost a status.
@ -418,7 +418,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/reblog', params)
@api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.0.0")
def status_unreblog(self, id: Union[Status, IdType]) -> Status:
"""
Un-reblog a status.
@ -428,7 +428,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/unreblog')
@api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.0.0")
def status_favourite(self, id: Union[Status, IdType]) -> Status:
"""
Favourite a status.
@ -438,7 +438,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/favourite')
@api_version("1.0.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.0.0", "2.0.0")
def status_unfavourite(self, id: Union[Status, IdType]) -> Status:
"""
Un-favourite a status.
@ -448,7 +448,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/unfavourite')
@api_version("1.4.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.4.0", "2.0.0")
def status_mute(self, id: Union[Status, IdType]) -> Status:
"""
Mute notifications for a status.
@ -458,7 +458,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/mute')
@api_version("1.4.0", "2.0.0", _DICT_VERSION_STATUS)
@api_version("1.4.0", "2.0.0")
def status_unmute(self, id: Union[Status, IdType]) -> Status:
"""
Unmute notifications for a status.
@ -468,7 +468,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/unmute')
@api_version("2.1.0", "2.1.0", _DICT_VERSION_STATUS)
@api_version("2.1.0", "2.1.0")
def status_pin(self, id: Union[Status, IdType]) -> Status:
"""
Pin a status for the logged-in user.
@ -478,7 +478,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/pin')
@api_version("2.1.0", "2.1.0", _DICT_VERSION_STATUS)
@api_version("2.1.0", "2.1.0")
def status_unpin(self, id: Union[Status, IdType]) -> Status:
"""
Unpin a pinned status for the logged-in user.
@ -488,7 +488,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/unpin')
@api_version("3.1.0", "3.1.0", _DICT_VERSION_STATUS)
@api_version("3.1.0", "3.1.0")
def status_bookmark(self, id: Union[Status, IdType]) -> Status:
"""
Bookmark a status as the logged-in user.
@ -498,7 +498,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/statuses/{id}/bookmark')
@api_version("3.1.0", "3.1.0", _DICT_VERSION_STATUS)
@api_version("3.1.0", "3.1.0")
def status_unbookmark(self, id: Union[Status, IdType]) -> Status:
"""
Unbookmark a bookmarked status for the logged-in user.
@ -511,7 +511,7 @@ class Mastodon(Internals):
###
# Writing data: Scheduled statuses
###
@api_version("2.7.0", "2.7.0", _DICT_VERSION_SCHEDULED_STATUS)
@api_version("2.7.0", "2.7.0")
def scheduled_status_update(self, id: Union[Status, IdType], scheduled_at: datetime) -> ScheduledStatus:
"""
Update the scheduled time of a scheduled status.
@ -525,7 +525,7 @@ class Mastodon(Internals):
params = self.__generate_params(locals(), ['id'])
return self.__api_request('PUT', f'/api/v1/scheduled_statuses/{id}', params)
@api_version("2.7.0", "2.7.0", "2.7.0")
@api_version("2.7.0", "2.7.0")
def scheduled_status_delete(self, id: Union[Status, IdType]):
"""
Deletes a scheduled status.

Wyświetl plik

@ -12,7 +12,7 @@ class Mastodon(Internals):
###
# Streaming
###
@api_version("1.1.0", "1.4.2", _DICT_VERSION_STATUS)
@api_version("1.1.0", "1.4.2")
def stream_user(self, listener, run_async=False, timeout=_DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=_DEFAULT_STREAM_RECONNECT_WAIT_SEC):
"""
Streams events that are relevant to the authorized user, i.e. home
@ -20,7 +20,7 @@ class Mastodon(Internals):
"""
return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
@api_version("1.1.0", "1.4.2", _DICT_VERSION_STATUS)
@api_version("1.1.0", "1.4.2")
def stream_public(self, listener, run_async=False, timeout=_DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=_DEFAULT_STREAM_RECONNECT_WAIT_SEC, local=False, remote=False):
"""
Streams public events.
@ -37,7 +37,7 @@ class Mastodon(Internals):
base += '/remote'
return self.__stream(base, listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
@api_version("1.1.0", "1.4.2", _DICT_VERSION_STATUS)
@api_version("1.1.0", "1.4.2")
def stream_local(self, listener, run_async=False, timeout=_DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=_DEFAULT_STREAM_RECONNECT_WAIT_SEC):
"""
Streams local public events.
@ -47,7 +47,7 @@ class Mastodon(Internals):
#return self.__stream('/api/v1/streaming/public/local', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
return self.stream_public(listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec, local=True)
@api_version("1.1.0", "1.4.2", _DICT_VERSION_STATUS)
@api_version("1.1.0", "1.4.2")
def stream_hashtag(self, tag, listener, local=False, run_async=False, timeout=_DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=_DEFAULT_STREAM_RECONNECT_WAIT_SEC):
"""
Stream for all public statuses for the hashtag 'tag' seen by the connected
@ -62,7 +62,7 @@ class Mastodon(Internals):
base += '/local'
return self.__stream(f"{base}?tag={tag}", listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
@api_version("2.1.0", "2.1.0", _DICT_VERSION_STATUS)
@api_version("2.1.0", "2.1.0")
def stream_list(self, id, listener, run_async=False, timeout=_DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=_DEFAULT_STREAM_RECONNECT_WAIT_SEC):
"""
Stream events for the current user, restricted to accounts on the given
@ -71,14 +71,14 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__stream(f"/api/v1/streaming/list?list={id}", listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
@api_version("2.6.0", "2.6.0", _DICT_VERSION_STATUS)
@api_version("2.6.0", "2.6.0")
def stream_direct(self, listener, run_async=False, timeout=_DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=_DEFAULT_STREAM_RECONNECT_WAIT_SEC):
"""
Streams direct message events for the logged-in user, as conversation events.
"""
return self.__stream('/api/v1/streaming/direct', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
@api_version("2.5.0", "2.5.0", "2.5.0")
@api_version("2.5.0", "2.5.0")
def stream_healthy(self) -> bool:
"""
Returns without True if streaming API is okay, False or raises an error otherwise.

Wyświetl plik

@ -11,14 +11,14 @@ class Mastodon(Internals):
###
# Reading data: Follow suggestions
###
@api_version("2.4.3", "2.4.3", _DICT_VERSION_ACCOUNT)
@api_version("2.4.3", "2.4.3")
def suggestions_v1(self) -> NonPaginatableList[Account]:
"""
Fetch follow suggestions for the logged-in user.
"""
return self.__api_request('GET', '/api/v1/suggestions')
@api_version("3.4.0", "3.4.0", _DICT_VERSION_ACCOUNT)
@api_version("3.4.0", "3.4.0")
def suggestions_v2(self) -> NonPaginatableList[Suggestion]:
"""
Fetch follow suggestions for the logged-in user.
@ -41,7 +41,7 @@ class Mastodon(Internals):
###
# Writing data: Follow suggestions
###
@api_version("2.4.3", "2.4.3", _DICT_VERSION_ACCOUNT)
@api_version("2.4.3", "2.4.3")
def suggestion_delete(self, account_id: Union[Account, IdType]):
"""
Remove the user with the given `account_id` from the follow suggestions.

Wyświetl plik

@ -13,7 +13,7 @@ class Mastodon(Internals):
###
# Reading data: Timelines
##
@api_version("1.0.0", "3.1.4", _DICT_VERSION_STATUS)
@api_version("1.0.0", "3.1.4")
def timeline(self, timeline: str = "home", max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None, only_media: bool = False, local: bool = False,
remote: bool = False) -> PaginatableList[Status]:
@ -46,7 +46,7 @@ class Mastodon(Internals):
params = self.__generate_params(params_initial, ['timeline'], dateconv=True)
return self.__api_request('GET', f'/api/v1/timelines/{timeline}', params)
@api_version("1.0.0", "3.1.4", _DICT_VERSION_STATUS)
@api_version("1.0.0", "3.1.4")
def timeline_home(self, max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None, only_media: bool = False, local: bool = False,
remote: bool = False) -> PaginatableList[Status]:
@ -55,7 +55,7 @@ class Mastodon(Internals):
"""
return self.timeline('home', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
@api_version("1.0.0", "3.1.4", _DICT_VERSION_STATUS)
@api_version("1.0.0", "3.1.4")
def timeline_local(self, max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None, only_media: bool = False) -> PaginatableList[Status]:
"""
@ -63,7 +63,7 @@ class Mastodon(Internals):
"""
return self.timeline('local', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media)
@api_version("1.0.0", "3.1.4", _DICT_VERSION_STATUS)
@api_version("1.0.0", "3.1.4")
def timeline_public(self, max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None, only_media: bool = False, local: bool = False,
remote: bool = False) -> PaginatableList[Status]:
@ -72,7 +72,7 @@ class Mastodon(Internals):
"""
return self.timeline('public', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
@api_version("1.0.0", "3.1.4", _DICT_VERSION_STATUS)
@api_version("1.0.0", "3.1.4")
def timeline_hashtag(self, hashtag: str, local: bool = False, max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None, only_media: bool = False,
remote: bool = False) -> PaginatableList[Status]:
@ -85,7 +85,7 @@ class Mastodon(Internals):
hashtag = self.__unpack_id(hashtag, field="name")
return self.timeline(f'tag/{hashtag}', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
@api_version("2.1.0", "3.1.4", _DICT_VERSION_STATUS)
@api_version("2.1.0", "3.1.4")
def timeline_list(self, id: Union[UserList, IdType], max_id: Optional[Union[Status, IdType, datetime]] = None, min_id: Optional[Union[Status, IdType, datetime]] = None,
since_id: Optional[Union[Status, IdType, datetime]] = None, limit: Optional[int] = None, only_media: bool = False, local: bool = False,
remote: bool = False) -> PaginatableList[Status]:

Wyświetl plik

@ -11,7 +11,7 @@ class Mastodon(Internals):
###
# Reading data: Trends
###
@api_version("2.4.3", "3.5.0", _DICT_VERSION_HASHTAG)
@api_version("2.4.3", "3.5.0")
def trends(self, limit: Optional[int] = None):
"""
Old alias for :ref:`trending_tags() <trending_tags()>`
@ -20,7 +20,7 @@ class Mastodon(Internals):
"""
return self.trending_tags(limit=limit)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_HASHTAG)
@api_version("3.5.0", "3.5.0")
def trending_tags(self, limit: Optional[int] = None, lang: Optional[str] = None) -> NonPaginatableList[Tag]:
"""
Fetch trending-hashtag information, if the instance provides such information.
@ -46,7 +46,7 @@ class Mastodon(Internals):
else:
return self.__api_request('GET', '/api/v1/trends', params, lang_override=lang)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS)
@api_version("3.5.0", "3.5.0")
def trending_statuses(self, limit: Optional[int] = None, offset: Optional[int] = None, lang: Optional[str] = None) -> NonPaginatableList[Status]:
"""
Fetch trending-status information, if the instance provides such information.
@ -65,7 +65,7 @@ class Mastodon(Internals):
del params["lang"]
return self.__api_request('GET', '/api/v1/trends/statuses', params, lang_override=lang)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_CARD)
@api_version("3.5.0", "3.5.0")
def trending_links(self, limit: Optional[int] = None, lang: Optional[str] = None) -> NonPaginatableList[PreviewCard]:
"""
Fetch trending-link information, if the instance provides such information.

Wyświetl plik

@ -409,6 +409,10 @@ class Entity():
This `should` be safe to call on any JSON string (no less safe than json.loads),
but I would still recommend to be very careful when using this on untrusted data
and to check that the returned value matches your expectations.
There is currently a bug on specifically python 3.7 and 3.8 where the return value
is not guaranteed to be of the right type. I will probably not fix this, since the versions
are out of support, anyways. However, the data will still be loaded correctly.
"""
# First, parse json normally. Can end up as a dict or a list.
json_result = json.loads(json_str)

Wyświetl plik

@ -24,15 +24,22 @@ def max_version(*version_strings):
return max(version_strings, key=parse_version_string)
def api_version(created_ver, last_changed_ver, return_value_ver):
def api_version(created_ver, last_changed_ver):
"""Version check decorator. Currently only checks Bigger Than."""
def api_min_version_decorator(function):
return_value_ver = None
return_value_type = function.__annotations__.get("return", None)
if return_value_type is not None:
return_value_ver = getattr(return_value_type, "_version", None)
def wrapper(function, self, *args, **kwargs):
if not self.version_check_mode == "none":
if self.version_check_mode == "created":
version = created_ver
else:
version = max_version(last_changed_ver, return_value_ver)
if return_value_ver is not None:
version = max_version(last_changed_ver, return_value_ver)
else:
version = last_changed_ver
major, minor, patch = parse_version_string(version)
if major > self.mastodon_major:
raise MastodonVersionError(f"Version check failed (Need Mastodon instance version {version} to call this endpoint)")
@ -42,7 +49,10 @@ def api_version(created_ver, last_changed_ver, return_value_ver):
raise MastodonVersionError(f"Version check failed (Need Mastodon instance version {version} to call this endpoint). Patch is {self.mastodon_patch}.")
return function(self, *args, **kwargs)
if function.__doc__:
function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver}*"
if return_value_ver is not None:
function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver} (parameters), Mastodon v{return_value_ver} (return value)*"
else:
function.__doc__ += f"\n\n *Added: Mastodon v{created_ver}, last changed: Mastodon v{last_changed_ver}*"
return decorate(function, wrapper)
return api_min_version_decorator

Wyświetl plik

@ -3,6 +3,7 @@ import vcr
from mastodon.return_types import *
from mastodon.types_base import real_issubclass, Entity
from datetime import datetime, timedelta, timezone
import sys
# "never record anything with admin in the URL" filter
def vcr_filter(request):
@ -44,11 +45,13 @@ def test_entity_account(mastodon_base, mastodon_admin):
result = mastodon.account(23972)
assert real_issubclass(type(result), Account), str(type(result)) + ' is not a subclass of Account'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Account), str(type(result)) + ' is not a subclass of Account after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Account), str(type(result)) + ' is not a subclass of Account after to_json/from_json'
result = mastodon.account_verify_credentials()
assert real_issubclass(type(result), Account), str(type(result)) + ' is not a subclass of Account (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Account), str(type(result)) + ' is not a subclass of Account after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Account), str(type(result)) + ' is not a subclass of Account after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -64,7 +67,8 @@ def test_entity_accountfield(mastodon_base, mastodon_admin):
result = mastodon.account(23972).fields[0]
assert real_issubclass(type(result), AccountField), str(type(result)) + ' is not a subclass of AccountField'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AccountField), str(type(result)) + ' is not a subclass of AccountField after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AccountField), str(type(result)) + ' is not a subclass of AccountField after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -80,7 +84,8 @@ def test_entity_role(mastodon_base, mastodon_admin):
result = mastodon.account_verify_credentials().role
assert real_issubclass(type(result), Role), str(type(result)) + ' is not a subclass of Role'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Role), str(type(result)) + ' is not a subclass of Role after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Role), str(type(result)) + ' is not a subclass of Role after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -96,7 +101,8 @@ def test_entity_credentialaccountsource(mastodon_base, mastodon_admin):
result = mastodon.account_verify_credentials()["source"]
assert real_issubclass(type(result), CredentialAccountSource), str(type(result)) + ' is not a subclass of CredentialAccountSource'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), CredentialAccountSource), str(type(result)) + ' is not a subclass of CredentialAccountSource after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), CredentialAccountSource), str(type(result)) + ' is not a subclass of CredentialAccountSource after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -112,11 +118,13 @@ def test_entity_status(mastodon_base, mastodon_admin):
result = mastodon.status(110446223051565765)
assert real_issubclass(type(result), Status), str(type(result)) + ' is not a subclass of Status'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Status), str(type(result)) + ' is not a subclass of Status after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Status), str(type(result)) + ' is not a subclass of Status after to_json/from_json'
result = mastodon.status(110446183735368325)
assert real_issubclass(type(result), Status), str(type(result)) + ' is not a subclass of Status (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Status), str(type(result)) + ' is not a subclass of Status after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Status), str(type(result)) + ' is not a subclass of Status after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -132,11 +140,13 @@ def test_entity_statusedit(mastodon_base, mastodon_admin):
result = mastodon.status_history(110446223051565765)[-1]
assert real_issubclass(type(result), StatusEdit), str(type(result)) + ' is not a subclass of StatusEdit'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), StatusEdit), str(type(result)) + ' is not a subclass of StatusEdit after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), StatusEdit), str(type(result)) + ' is not a subclass of StatusEdit after to_json/from_json'
result = mastodon.status_history(110446183735368325)[-1]
assert real_issubclass(type(result), StatusEdit), str(type(result)) + ' is not a subclass of StatusEdit (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), StatusEdit), str(type(result)) + ' is not a subclass of StatusEdit after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), StatusEdit), str(type(result)) + ' is not a subclass of StatusEdit after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -152,7 +162,8 @@ def test_entity_filterresult(mastodon_base, mastodon_admin):
result = mastodon.status(110447998920481458).filtered[0]
assert real_issubclass(type(result), FilterResult), str(type(result)) + ' is not a subclass of FilterResult'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), FilterResult), str(type(result)) + ' is not a subclass of FilterResult after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), FilterResult), str(type(result)) + ' is not a subclass of FilterResult after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -168,7 +179,8 @@ def test_entity_statusmention(mastodon_base, mastodon_admin):
result = mastodon.status(110446223051565765).mentions[0]
assert real_issubclass(type(result), StatusMention), str(type(result)) + ' is not a subclass of StatusMention'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), StatusMention), str(type(result)) + ' is not a subclass of StatusMention after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), StatusMention), str(type(result)) + ' is not a subclass of StatusMention after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -184,7 +196,8 @@ def test_entity_scheduledstatus(mastodon_base, mastodon_admin):
result = mastodon.status_post("posting in the far future", scheduled_at=datetime(2100,12,12))
assert real_issubclass(type(result), ScheduledStatus), str(type(result)) + ' is not a subclass of ScheduledStatus'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), ScheduledStatus), str(type(result)) + ' is not a subclass of ScheduledStatus after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), ScheduledStatus), str(type(result)) + ' is not a subclass of ScheduledStatus after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -200,7 +213,8 @@ def test_entity_scheduledstatusparams(mastodon_base, mastodon_admin):
result = mastodon.status_post("posting in the far future", scheduled_at=datetime(2100,12,12)).params
assert real_issubclass(type(result), ScheduledStatusParams), str(type(result)) + ' is not a subclass of ScheduledStatusParams'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), ScheduledStatusParams), str(type(result)) + ' is not a subclass of ScheduledStatusParams after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), ScheduledStatusParams), str(type(result)) + ' is not a subclass of ScheduledStatusParams after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -216,7 +230,8 @@ def test_entity_poll(mastodon_base, mastodon_admin):
result = mastodon.status(110446383900387196).poll
assert real_issubclass(type(result), Poll), str(type(result)) + ' is not a subclass of Poll'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Poll), str(type(result)) + ' is not a subclass of Poll after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Poll), str(type(result)) + ' is not a subclass of Poll after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -232,7 +247,8 @@ def test_entity_polloption(mastodon_base, mastodon_admin):
result = mastodon.status(110446383900387196).poll.options[0]
assert real_issubclass(type(result), PollOption), str(type(result)) + ' is not a subclass of PollOption'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), PollOption), str(type(result)) + ' is not a subclass of PollOption after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), PollOption), str(type(result)) + ' is not a subclass of PollOption after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -248,7 +264,8 @@ def test_entity_conversation(mastodon_base, mastodon_admin):
result = mastodon.conversations()[0]
assert real_issubclass(type(result), Conversation), str(type(result)) + ' is not a subclass of Conversation'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Conversation), str(type(result)) + ' is not a subclass of Conversation after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Conversation), str(type(result)) + ' is not a subclass of Conversation after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -264,7 +281,8 @@ def test_entity_tag(mastodon_base, mastodon_admin):
result = mastodon.trending_tags()[0]
assert real_issubclass(type(result), Tag), str(type(result)) + ' is not a subclass of Tag'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Tag), str(type(result)) + ' is not a subclass of Tag after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Tag), str(type(result)) + ' is not a subclass of Tag after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -280,7 +298,8 @@ def test_entity_taghistory(mastodon_base, mastodon_admin):
result = mastodon.trending_tags()[0].history[0]
assert real_issubclass(type(result), TagHistory), str(type(result)) + ' is not a subclass of TagHistory'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), TagHistory), str(type(result)) + ' is not a subclass of TagHistory after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), TagHistory), str(type(result)) + ' is not a subclass of TagHistory after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -296,7 +315,8 @@ def test_entity_customemoji(mastodon_base, mastodon_admin):
result = mastodon.status(110446223051565765).emojis[0]
assert real_issubclass(type(result), CustomEmoji), str(type(result)) + ' is not a subclass of CustomEmoji'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), CustomEmoji), str(type(result)) + ' is not a subclass of CustomEmoji after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), CustomEmoji), str(type(result)) + ' is not a subclass of CustomEmoji after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -312,7 +332,8 @@ def test_entity_application(mastodon_base, mastodon_admin):
result = mastodon.app_verify_credentials()
assert real_issubclass(type(result), Application), str(type(result)) + ' is not a subclass of Application'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Application), str(type(result)) + ' is not a subclass of Application after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Application), str(type(result)) + ' is not a subclass of Application after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -328,7 +349,8 @@ def test_entity_relationship(mastodon_base, mastodon_admin):
result = mastodon.account_relationships(23972)[0]
assert real_issubclass(type(result), Relationship), str(type(result)) + ' is not a subclass of Relationship'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Relationship), str(type(result)) + ' is not a subclass of Relationship after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Relationship), str(type(result)) + ' is not a subclass of Relationship after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -344,7 +366,8 @@ def test_entity_filter(mastodon_base, mastodon_admin):
result = mastodon.filters()[0]
assert real_issubclass(type(result), Filter), str(type(result)) + ' is not a subclass of Filter'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Filter), str(type(result)) + ' is not a subclass of Filter after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Filter), str(type(result)) + ' is not a subclass of Filter after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -355,13 +378,14 @@ def test_entity_filter(mastodon_base, mastodon_admin):
match_on=['method', 'uri'],
cassette_library_dir='tests/cassettes_entity_tests'
)
@pytest.mark.skip(reason="FilterV2 is not yet implemented")
@pytest.mark.skip(reason="FilterV2 is not implemented in Mastodon.py yet")
def test_entity_filterv2(mastodon_base, mastodon_admin):
mastodon = mastodon_base
result = mastodon.filters()[0]
assert real_issubclass(type(result), FilterV2), str(type(result)) + ' is not a subclass of FilterV2'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), FilterV2), str(type(result)) + ' is not a subclass of FilterV2 after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), FilterV2), str(type(result)) + ' is not a subclass of FilterV2 after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -377,7 +401,8 @@ def test_entity_notification(mastodon_base, mastodon_admin):
result = mastodon.notifications()[0]
assert real_issubclass(type(result), Notification), str(type(result)) + ' is not a subclass of Notification'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Notification), str(type(result)) + ' is not a subclass of Notification after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Notification), str(type(result)) + ' is not a subclass of Notification after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -393,7 +418,8 @@ def test_entity_context(mastodon_base, mastodon_admin):
result = mastodon.status_context(110446983926957470)
assert real_issubclass(type(result), Context), str(type(result)) + ' is not a subclass of Context'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Context), str(type(result)) + ' is not a subclass of Context after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Context), str(type(result)) + ' is not a subclass of Context after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -409,7 +435,8 @@ def test_entity_userlist(mastodon_base, mastodon_admin):
result = mastodon.lists()[0]
assert real_issubclass(type(result), UserList), str(type(result)) + ' is not a subclass of UserList'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), UserList), str(type(result)) + ' is not a subclass of UserList after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), UserList), str(type(result)) + ' is not a subclass of UserList after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -425,11 +452,13 @@ def test_entity_mediaattachment(mastodon_base, mastodon_admin):
result = mastodon.status(110447012773105565).media_attachments[0]
assert real_issubclass(type(result), MediaAttachment), str(type(result)) + ' is not a subclass of MediaAttachment'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachment), str(type(result)) + ' is not a subclass of MediaAttachment after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachment), str(type(result)) + ' is not a subclass of MediaAttachment after to_json/from_json'
result = mastodon.status(110447003454258227).media_attachments[0]
assert real_issubclass(type(result), MediaAttachment), str(type(result)) + ' is not a subclass of MediaAttachment (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachment), str(type(result)) + ' is not a subclass of MediaAttachment after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachment), str(type(result)) + ' is not a subclass of MediaAttachment after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -445,11 +474,13 @@ def test_entity_mediaattachmentmetadatacontainer(mastodon_base, mastodon_admin):
result = mastodon.status(110447012773105565).media_attachments[0].meta
assert real_issubclass(type(result), MediaAttachmentMetadataContainer), str(type(result)) + ' is not a subclass of MediaAttachmentMetadataContainer'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentMetadataContainer), str(type(result)) + ' is not a subclass of MediaAttachmentMetadataContainer after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentMetadataContainer), str(type(result)) + ' is not a subclass of MediaAttachmentMetadataContainer after to_json/from_json'
result = mastodon.status(110447003454258227).media_attachments[0].meta
assert real_issubclass(type(result), MediaAttachmentMetadataContainer), str(type(result)) + ' is not a subclass of MediaAttachmentMetadataContainer (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentMetadataContainer), str(type(result)) + ' is not a subclass of MediaAttachmentMetadataContainer after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentMetadataContainer), str(type(result)) + ' is not a subclass of MediaAttachmentMetadataContainer after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -465,7 +496,8 @@ def test_entity_mediaattachmentimagemetadata(mastodon_base, mastodon_admin):
result = mastodon.status(110447003454258227).media_attachments[0].meta.original
assert real_issubclass(type(result), MediaAttachmentImageMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentImageMetadata'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentImageMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentImageMetadata after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentImageMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentImageMetadata after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -481,11 +513,13 @@ def test_entity_mediaattachmentvideometadata(mastodon_base, mastodon_admin):
result = mastodon.status(110447001287656894).media_attachments[0].meta.original
assert real_issubclass(type(result), MediaAttachmentVideoMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentVideoMetadata'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentVideoMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentVideoMetadata after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentVideoMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentVideoMetadata after to_json/from_json'
result = mastodon.status(113358687695262945).media_attachments[0].meta.original
assert real_issubclass(type(result), MediaAttachmentVideoMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentVideoMetadata (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentVideoMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentVideoMetadata after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentVideoMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentVideoMetadata after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -501,7 +535,8 @@ def test_entity_mediaattachmentaudiometadata(mastodon_base, mastodon_admin):
result = mastodon.status(110447012773105565).media_attachments[0].meta.original
assert real_issubclass(type(result), MediaAttachmentAudioMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentAudioMetadata'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentAudioMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentAudioMetadata after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentAudioMetadata), str(type(result)) + ' is not a subclass of MediaAttachmentAudioMetadata after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -517,7 +552,8 @@ def test_entity_mediaattachmentfocuspoint(mastodon_base, mastodon_admin):
result = mastodon.status(110447003454258227).media_attachments[0].meta.focus
assert real_issubclass(type(result), MediaAttachmentFocusPoint), str(type(result)) + ' is not a subclass of MediaAttachmentFocusPoint'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentFocusPoint), str(type(result)) + ' is not a subclass of MediaAttachmentFocusPoint after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentFocusPoint), str(type(result)) + ' is not a subclass of MediaAttachmentFocusPoint after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -533,7 +569,8 @@ def test_entity_mediaattachmentcolors(mastodon_base, mastodon_admin):
result = mastodon.status(110447012773105565).media_attachments[0].meta.colors
assert real_issubclass(type(result), MediaAttachmentColors), str(type(result)) + ' is not a subclass of MediaAttachmentColors'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), MediaAttachmentColors), str(type(result)) + ' is not a subclass of MediaAttachmentColors after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), MediaAttachmentColors), str(type(result)) + ' is not a subclass of MediaAttachmentColors after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -549,7 +586,8 @@ def test_entity_previewcard(mastodon_base, mastodon_admin):
result = mastodon.status_card(110447098625216345)
assert real_issubclass(type(result), PreviewCard), str(type(result)) + ' is not a subclass of PreviewCard'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), PreviewCard), str(type(result)) + ' is not a subclass of PreviewCard after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), PreviewCard), str(type(result)) + ' is not a subclass of PreviewCard after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -565,7 +603,8 @@ def test_entity_previewcardauthor(mastodon_base, mastodon_admin):
result = mastodon.status_card(113481707975926080).authors[0]
assert real_issubclass(type(result), PreviewCardAuthor), str(type(result)) + ' is not a subclass of PreviewCardAuthor'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), PreviewCardAuthor), str(type(result)) + ' is not a subclass of PreviewCardAuthor after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), PreviewCardAuthor), str(type(result)) + ' is not a subclass of PreviewCardAuthor after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -581,7 +620,8 @@ def test_entity_searchv2(mastodon_base, mastodon_admin):
result = mastodon.search("halcy")
assert real_issubclass(type(result), SearchV2), str(type(result)) + ' is not a subclass of SearchV2'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), SearchV2), str(type(result)) + ' is not a subclass of SearchV2 after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), SearchV2), str(type(result)) + ' is not a subclass of SearchV2 after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -597,7 +637,8 @@ def test_entity_instance(mastodon_base, mastodon_admin):
result = mastodon.instance_v1()
assert real_issubclass(type(result), Instance), str(type(result)) + ' is not a subclass of Instance'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Instance), str(type(result)) + ' is not a subclass of Instance after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Instance), str(type(result)) + ' is not a subclass of Instance after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -613,7 +654,8 @@ def test_entity_instanceconfiguration(mastodon_base, mastodon_admin):
result = mastodon.instance_v1().configuration
assert real_issubclass(type(result), InstanceConfiguration), str(type(result)) + ' is not a subclass of InstanceConfiguration'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceConfiguration), str(type(result)) + ' is not a subclass of InstanceConfiguration after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceConfiguration), str(type(result)) + ' is not a subclass of InstanceConfiguration after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -629,11 +671,13 @@ def test_entity_instanceurls(mastodon_base, mastodon_admin):
result = mastodon.instance_v1().urls
assert real_issubclass(type(result), InstanceURLs), str(type(result)) + ' is not a subclass of InstanceURLs'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceURLs), str(type(result)) + ' is not a subclass of InstanceURLs after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceURLs), str(type(result)) + ' is not a subclass of InstanceURLs after to_json/from_json'
result = mastodon.instance_v1().urls
assert real_issubclass(type(result), InstanceURLs), str(type(result)) + ' is not a subclass of InstanceURLs (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceURLs), str(type(result)) + ' is not a subclass of InstanceURLs after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceURLs), str(type(result)) + ' is not a subclass of InstanceURLs after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -649,7 +693,8 @@ def test_entity_instancev2(mastodon_base, mastodon_admin):
result = mastodon.instance_v2()
assert real_issubclass(type(result), InstanceV2), str(type(result)) + ' is not a subclass of InstanceV2'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceV2), str(type(result)) + ' is not a subclass of InstanceV2 after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceV2), str(type(result)) + ' is not a subclass of InstanceV2 after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -665,7 +710,8 @@ def test_entity_instanceicon(mastodon_base, mastodon_admin):
result = mastodon.instance_v2().icon[0]
assert real_issubclass(type(result), InstanceIcon), str(type(result)) + ' is not a subclass of InstanceIcon'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceIcon), str(type(result)) + ' is not a subclass of InstanceIcon after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceIcon), str(type(result)) + ' is not a subclass of InstanceIcon after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -681,7 +727,8 @@ def test_entity_instanceconfigurationv2(mastodon_base, mastodon_admin):
result = mastodon.instance_v2().configuration
assert real_issubclass(type(result), InstanceConfigurationV2), str(type(result)) + ' is not a subclass of InstanceConfigurationV2'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceConfigurationV2), str(type(result)) + ' is not a subclass of InstanceConfigurationV2 after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceConfigurationV2), str(type(result)) + ' is not a subclass of InstanceConfigurationV2 after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -697,7 +744,8 @@ def test_entity_instancevapidkey(mastodon_base, mastodon_admin):
result = mastodon.instance_v2().configuration.vapid
assert real_issubclass(type(result), InstanceVapidKey), str(type(result)) + ' is not a subclass of InstanceVapidKey'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceVapidKey), str(type(result)) + ' is not a subclass of InstanceVapidKey after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceVapidKey), str(type(result)) + ' is not a subclass of InstanceVapidKey after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -713,7 +761,8 @@ def test_entity_instanceurlsv2(mastodon_base, mastodon_admin):
result = mastodon.instance_v2().configuration.urls
assert real_issubclass(type(result), InstanceURLsV2), str(type(result)) + ' is not a subclass of InstanceURLsV2'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceURLsV2), str(type(result)) + ' is not a subclass of InstanceURLsV2 after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceURLsV2), str(type(result)) + ' is not a subclass of InstanceURLsV2 after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -729,7 +778,8 @@ def test_entity_instancethumbnail(mastodon_base, mastodon_admin):
result = mastodon.instance().thumbnail
assert real_issubclass(type(result), InstanceThumbnail), str(type(result)) + ' is not a subclass of InstanceThumbnail'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceThumbnail), str(type(result)) + ' is not a subclass of InstanceThumbnail after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceThumbnail), str(type(result)) + ' is not a subclass of InstanceThumbnail after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -745,7 +795,8 @@ def test_entity_instancethumbnailversions(mastodon_base, mastodon_admin):
result = mastodon.instance().thumbnail.versions
assert real_issubclass(type(result), InstanceThumbnailVersions), str(type(result)) + ' is not a subclass of InstanceThumbnailVersions'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceThumbnailVersions), str(type(result)) + ' is not a subclass of InstanceThumbnailVersions after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceThumbnailVersions), str(type(result)) + ' is not a subclass of InstanceThumbnailVersions after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -761,7 +812,8 @@ def test_entity_instancestatistics(mastodon_base, mastodon_admin):
result = mastodon.instance_v1().stats
assert real_issubclass(type(result), InstanceStatistics), str(type(result)) + ' is not a subclass of InstanceStatistics'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceStatistics), str(type(result)) + ' is not a subclass of InstanceStatistics after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceStatistics), str(type(result)) + ' is not a subclass of InstanceStatistics after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -777,7 +829,8 @@ def test_entity_instanceusage(mastodon_base, mastodon_admin):
result = mastodon.instance().usage
assert real_issubclass(type(result), InstanceUsage), str(type(result)) + ' is not a subclass of InstanceUsage'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceUsage), str(type(result)) + ' is not a subclass of InstanceUsage after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceUsage), str(type(result)) + ' is not a subclass of InstanceUsage after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -793,7 +846,8 @@ def test_entity_instanceusageusers(mastodon_base, mastodon_admin):
result = mastodon.instance().usage.users
assert real_issubclass(type(result), InstanceUsageUsers), str(type(result)) + ' is not a subclass of InstanceUsageUsers'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceUsageUsers), str(type(result)) + ' is not a subclass of InstanceUsageUsers after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceUsageUsers), str(type(result)) + ' is not a subclass of InstanceUsageUsers after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -809,7 +863,8 @@ def test_entity_rule(mastodon_base, mastodon_admin):
result = mastodon.instance().rules[0]
assert real_issubclass(type(result), Rule), str(type(result)) + ' is not a subclass of Rule'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Rule), str(type(result)) + ' is not a subclass of Rule after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Rule), str(type(result)) + ' is not a subclass of Rule after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -825,7 +880,8 @@ def test_entity_instanceregistrations(mastodon_base, mastodon_admin):
result = mastodon.instance_v2().registrations
assert real_issubclass(type(result), InstanceRegistrations), str(type(result)) + ' is not a subclass of InstanceRegistrations'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceRegistrations), str(type(result)) + ' is not a subclass of InstanceRegistrations after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceRegistrations), str(type(result)) + ' is not a subclass of InstanceRegistrations after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -841,7 +897,8 @@ def test_entity_instancecontact(mastodon_base, mastodon_admin):
result = mastodon.instance().contact
assert real_issubclass(type(result), InstanceContact), str(type(result)) + ' is not a subclass of InstanceContact'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceContact), str(type(result)) + ' is not a subclass of InstanceContact after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceContact), str(type(result)) + ' is not a subclass of InstanceContact after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -857,7 +914,8 @@ def test_entity_instanceaccountconfiguration(mastodon_base, mastodon_admin):
result = mastodon.instance().configuration.accounts
assert real_issubclass(type(result), InstanceAccountConfiguration), str(type(result)) + ' is not a subclass of InstanceAccountConfiguration'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceAccountConfiguration), str(type(result)) + ' is not a subclass of InstanceAccountConfiguration after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceAccountConfiguration), str(type(result)) + ' is not a subclass of InstanceAccountConfiguration after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -873,7 +931,8 @@ def test_entity_instancestatusconfiguration(mastodon_base, mastodon_admin):
result = mastodon.instance().configuration.statuses
assert real_issubclass(type(result), InstanceStatusConfiguration), str(type(result)) + ' is not a subclass of InstanceStatusConfiguration'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceStatusConfiguration), str(type(result)) + ' is not a subclass of InstanceStatusConfiguration after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceStatusConfiguration), str(type(result)) + ' is not a subclass of InstanceStatusConfiguration after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -889,7 +948,8 @@ def test_entity_instancetranslationconfiguration(mastodon_base, mastodon_admin):
result = mastodon.instance_v2().configuration.translation
assert real_issubclass(type(result), InstanceTranslationConfiguration), str(type(result)) + ' is not a subclass of InstanceTranslationConfiguration'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceTranslationConfiguration), str(type(result)) + ' is not a subclass of InstanceTranslationConfiguration after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceTranslationConfiguration), str(type(result)) + ' is not a subclass of InstanceTranslationConfiguration after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -905,7 +965,8 @@ def test_entity_instancemediaconfiguration(mastodon_base, mastodon_admin):
result = mastodon.instance().configuration.media_attachments
assert real_issubclass(type(result), InstanceMediaConfiguration), str(type(result)) + ' is not a subclass of InstanceMediaConfiguration'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstanceMediaConfiguration), str(type(result)) + ' is not a subclass of InstanceMediaConfiguration after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstanceMediaConfiguration), str(type(result)) + ' is not a subclass of InstanceMediaConfiguration after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -921,7 +982,8 @@ def test_entity_instancepollconfiguration(mastodon_base, mastodon_admin):
result = mastodon.instance().configuration.polls
assert real_issubclass(type(result), InstancePollConfiguration), str(type(result)) + ' is not a subclass of InstancePollConfiguration'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), InstancePollConfiguration), str(type(result)) + ' is not a subclass of InstancePollConfiguration after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), InstancePollConfiguration), str(type(result)) + ' is not a subclass of InstancePollConfiguration after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -937,7 +999,8 @@ def test_entity_nodeinfo(mastodon_base, mastodon_admin):
result = mastodon.instance_nodeinfo()
assert real_issubclass(type(result), Nodeinfo), str(type(result)) + ' is not a subclass of Nodeinfo'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Nodeinfo), str(type(result)) + ' is not a subclass of Nodeinfo after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Nodeinfo), str(type(result)) + ' is not a subclass of Nodeinfo after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -953,7 +1016,8 @@ def test_entity_nodeinfosoftware(mastodon_base, mastodon_admin):
result = mastodon.instance_nodeinfo().software
assert real_issubclass(type(result), NodeinfoSoftware), str(type(result)) + ' is not a subclass of NodeinfoSoftware'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), NodeinfoSoftware), str(type(result)) + ' is not a subclass of NodeinfoSoftware after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), NodeinfoSoftware), str(type(result)) + ' is not a subclass of NodeinfoSoftware after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -969,7 +1033,8 @@ def test_entity_nodeinfoservices(mastodon_base, mastodon_admin):
result = mastodon.instance_nodeinfo().services
assert real_issubclass(type(result), NodeinfoServices), str(type(result)) + ' is not a subclass of NodeinfoServices'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), NodeinfoServices), str(type(result)) + ' is not a subclass of NodeinfoServices after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), NodeinfoServices), str(type(result)) + ' is not a subclass of NodeinfoServices after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -985,7 +1050,8 @@ def test_entity_nodeinfousage(mastodon_base, mastodon_admin):
result = mastodon.instance_nodeinfo().usage
assert real_issubclass(type(result), NodeinfoUsage), str(type(result)) + ' is not a subclass of NodeinfoUsage'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), NodeinfoUsage), str(type(result)) + ' is not a subclass of NodeinfoUsage after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), NodeinfoUsage), str(type(result)) + ' is not a subclass of NodeinfoUsage after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1001,7 +1067,8 @@ def test_entity_nodeinfousageusers(mastodon_base, mastodon_admin):
result = mastodon.instance_nodeinfo().usage.users
assert real_issubclass(type(result), NodeinfoUsageUsers), str(type(result)) + ' is not a subclass of NodeinfoUsageUsers'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), NodeinfoUsageUsers), str(type(result)) + ' is not a subclass of NodeinfoUsageUsers after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), NodeinfoUsageUsers), str(type(result)) + ' is not a subclass of NodeinfoUsageUsers after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1017,7 +1084,8 @@ def test_entity_nodeinfometadata(mastodon_base, mastodon_admin):
result = mastodon.instance_nodeinfo().metadata
assert real_issubclass(type(result), NodeinfoMetadata), str(type(result)) + ' is not a subclass of NodeinfoMetadata'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), NodeinfoMetadata), str(type(result)) + ' is not a subclass of NodeinfoMetadata after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), NodeinfoMetadata), str(type(result)) + ' is not a subclass of NodeinfoMetadata after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1033,7 +1101,8 @@ def test_entity_activity(mastodon_base, mastodon_admin):
result = mastodon.instance_activity()[0]
assert real_issubclass(type(result), Activity), str(type(result)) + ' is not a subclass of Activity'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Activity), str(type(result)) + ' is not a subclass of Activity after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Activity), str(type(result)) + ' is not a subclass of Activity after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1050,11 +1119,13 @@ def test_entity_adminreport(mastodon_base, mastodon_admin):
result = mastodon.admin_reports()[-1]
assert real_issubclass(type(result), AdminReport), str(type(result)) + ' is not a subclass of AdminReport'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminReport), str(type(result)) + ' is not a subclass of AdminReport after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminReport), str(type(result)) + ' is not a subclass of AdminReport after to_json/from_json'
result = mastodon.admin_reports(resolved=True)[-1]
assert real_issubclass(type(result), AdminReport), str(type(result)) + ' is not a subclass of AdminReport (additional function)'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminReport), str(type(result)) + ' is not a subclass of AdminReport after to_json/from_json (additional function)'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminReport), str(type(result)) + ' is not a subclass of AdminReport after to_json/from_json (additional function)'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1070,7 +1141,8 @@ def test_entity_webpushsubscription(mastodon_base, mastodon_admin):
result = mastodon.push_subscription_set("http://halcy.de/",mastodon.push_subscription_generate_keys()[1],follow_events=True)
assert real_issubclass(type(result), WebPushSubscription), str(type(result)) + ' is not a subclass of WebPushSubscription'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), WebPushSubscription), str(type(result)) + ' is not a subclass of WebPushSubscription after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), WebPushSubscription), str(type(result)) + ' is not a subclass of WebPushSubscription after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1086,7 +1158,8 @@ def test_entity_webpushsubscriptionalerts(mastodon_base, mastodon_admin):
result = mastodon.push_subscription_set("http://halcy.de/",mastodon.push_subscription_generate_keys()[1],follow_events=True).alerts
assert real_issubclass(type(result), WebPushSubscriptionAlerts), str(type(result)) + ' is not a subclass of WebPushSubscriptionAlerts'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), WebPushSubscriptionAlerts), str(type(result)) + ' is not a subclass of WebPushSubscriptionAlerts after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), WebPushSubscriptionAlerts), str(type(result)) + ' is not a subclass of WebPushSubscriptionAlerts after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1102,7 +1175,8 @@ def test_entity_preferences(mastodon_base, mastodon_admin):
result = mastodon.preferences()
assert real_issubclass(type(result), Preferences), str(type(result)) + ' is not a subclass of Preferences'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Preferences), str(type(result)) + ' is not a subclass of Preferences after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Preferences), str(type(result)) + ' is not a subclass of Preferences after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1118,7 +1192,8 @@ def test_entity_featuredtag(mastodon_base, mastodon_admin):
result = mastodon.featured_tags()[0]
assert real_issubclass(type(result), FeaturedTag), str(type(result)) + ' is not a subclass of FeaturedTag'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), FeaturedTag), str(type(result)) + ' is not a subclass of FeaturedTag after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), FeaturedTag), str(type(result)) + ' is not a subclass of FeaturedTag after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1134,7 +1209,8 @@ def test_entity_marker(mastodon_base, mastodon_admin):
result = mastodon.markers_get()["home"]
assert real_issubclass(type(result), Marker), str(type(result)) + ' is not a subclass of Marker'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Marker), str(type(result)) + ' is not a subclass of Marker after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Marker), str(type(result)) + ' is not a subclass of Marker after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1150,7 +1226,8 @@ def test_entity_announcement(mastodon_base, mastodon_admin):
result = mastodon.announcements()[0]
assert real_issubclass(type(result), Announcement), str(type(result)) + ' is not a subclass of Announcement'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Announcement), str(type(result)) + ' is not a subclass of Announcement after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Announcement), str(type(result)) + ' is not a subclass of Announcement after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1166,7 +1243,8 @@ def test_entity_reaction(mastodon_base, mastodon_admin):
result = mastodon.announcements()[0].reactions[0]
assert real_issubclass(type(result), Reaction), str(type(result)) + ' is not a subclass of Reaction'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Reaction), str(type(result)) + ' is not a subclass of Reaction after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Reaction), str(type(result)) + ' is not a subclass of Reaction after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1182,7 +1260,8 @@ def test_entity_familiarfollowers(mastodon_base, mastodon_admin):
result = mastodon.account_familiar_followers(2)[0]
assert real_issubclass(type(result), FamiliarFollowers), str(type(result)) + ' is not a subclass of FamiliarFollowers'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), FamiliarFollowers), str(type(result)) + ' is not a subclass of FamiliarFollowers after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), FamiliarFollowers), str(type(result)) + ' is not a subclass of FamiliarFollowers after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1199,7 +1278,8 @@ def test_entity_adminaccount(mastodon_base, mastodon_admin):
result = mastodon.admin_account(1)
assert real_issubclass(type(result), AdminAccount), str(type(result)) + ' is not a subclass of AdminAccount'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminAccount), str(type(result)) + ' is not a subclass of AdminAccount after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminAccount), str(type(result)) + ' is not a subclass of AdminAccount after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1216,7 +1296,8 @@ def test_entity_adminip(mastodon_base, mastodon_admin):
result = mastodon.admin_account(1).ips[0]
assert real_issubclass(type(result), AdminIp), str(type(result)) + ' is not a subclass of AdminIp'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminIp), str(type(result)) + ' is not a subclass of AdminIp after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminIp), str(type(result)) + ' is not a subclass of AdminIp after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1233,7 +1314,8 @@ def test_entity_adminmeasure(mastodon_base, mastodon_admin):
result = mastodon.admin_measures(datetime.now() - timedelta(hours=24*5), datetime.now(), interactions=True)[0]
assert real_issubclass(type(result), AdminMeasure), str(type(result)) + ' is not a subclass of AdminMeasure'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminMeasure), str(type(result)) + ' is not a subclass of AdminMeasure after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminMeasure), str(type(result)) + ' is not a subclass of AdminMeasure after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1250,7 +1332,8 @@ def test_entity_adminmeasuredata(mastodon_base, mastodon_admin):
result = mastodon.admin_measures(datetime.now() - timedelta(hours=24*5), datetime.now(), active_users=True)[0].data[0]
assert real_issubclass(type(result), AdminMeasureData), str(type(result)) + ' is not a subclass of AdminMeasureData'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminMeasureData), str(type(result)) + ' is not a subclass of AdminMeasureData after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminMeasureData), str(type(result)) + ' is not a subclass of AdminMeasureData after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1267,7 +1350,8 @@ def test_entity_admindimension(mastodon_base, mastodon_admin):
result = mastodon.admin_dimensions(datetime.now() - timedelta(hours=24*5), datetime.now(), languages=True)[0]
assert real_issubclass(type(result), AdminDimension), str(type(result)) + ' is not a subclass of AdminDimension'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminDimension), str(type(result)) + ' is not a subclass of AdminDimension after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminDimension), str(type(result)) + ' is not a subclass of AdminDimension after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1284,7 +1368,8 @@ def test_entity_admindimensiondata(mastodon_base, mastodon_admin):
result = mastodon.admin_dimensions(datetime.now() - timedelta(hours=24*5), datetime.now(), languages=True)[0].data[0]
assert real_issubclass(type(result), AdminDimensionData), str(type(result)) + ' is not a subclass of AdminDimensionData'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminDimensionData), str(type(result)) + ' is not a subclass of AdminDimensionData after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminDimensionData), str(type(result)) + ' is not a subclass of AdminDimensionData after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1301,7 +1386,8 @@ def test_entity_adminretention(mastodon_base, mastodon_admin):
result = mastodon.admin_retention(datetime.now() - timedelta(hours=24*5), datetime.now())[0]
assert real_issubclass(type(result), AdminRetention), str(type(result)) + ' is not a subclass of AdminRetention'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminRetention), str(type(result)) + ' is not a subclass of AdminRetention after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminRetention), str(type(result)) + ' is not a subclass of AdminRetention after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1318,7 +1404,8 @@ def test_entity_admincohort(mastodon_base, mastodon_admin):
result = mastodon.admin_retention(datetime.now() - timedelta(hours=24*5), datetime.now())[0].data[0]
assert real_issubclass(type(result), AdminCohort), str(type(result)) + ' is not a subclass of AdminCohort'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminCohort), str(type(result)) + ' is not a subclass of AdminCohort after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminCohort), str(type(result)) + ' is not a subclass of AdminCohort after to_json/from_json'
@pytest.mark.skip(reason="Admin functions are not tested by default")
@pytest.mark.vcr(
@ -1335,7 +1422,8 @@ def test_entity_admindomainblock(mastodon_base, mastodon_admin):
result = mastodon.admin_domain_blocks()[0]
assert real_issubclass(type(result), AdminDomainBlock), str(type(result)) + ' is not a subclass of AdminDomainBlock'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AdminDomainBlock), str(type(result)) + ' is not a subclass of AdminDomainBlock after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AdminDomainBlock), str(type(result)) + ' is not a subclass of AdminDomainBlock after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1351,7 +1439,8 @@ def test_entity_suggestion(mastodon_base, mastodon_admin):
result = mastodon.suggestions_v2()[0]
assert real_issubclass(type(result), Suggestion), str(type(result)) + ' is not a subclass of Suggestion'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), Suggestion), str(type(result)) + ' is not a subclass of Suggestion after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), Suggestion), str(type(result)) + ' is not a subclass of Suggestion after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1367,7 +1456,8 @@ def test_entity_accountcreationerror(mastodon_base, mastodon_admin):
result = mastodon.create_account('halcy', 'secret', 'invalid email lol', True, return_detailed_error=True)[1]
assert real_issubclass(type(result), AccountCreationError), str(type(result)) + ' is not a subclass of AccountCreationError'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AccountCreationError), str(type(result)) + ' is not a subclass of AccountCreationError after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AccountCreationError), str(type(result)) + ' is not a subclass of AccountCreationError after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1383,7 +1473,8 @@ def test_entity_accountcreationerrordetails(mastodon_base, mastodon_admin):
result = mastodon.create_account('halcy', 'secret', 'invalid email lol', False, return_detailed_error=True)[1].details
assert real_issubclass(type(result), AccountCreationErrorDetails), str(type(result)) + ' is not a subclass of AccountCreationErrorDetails'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AccountCreationErrorDetails), str(type(result)) + ' is not a subclass of AccountCreationErrorDetails after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AccountCreationErrorDetails), str(type(result)) + ' is not a subclass of AccountCreationErrorDetails after to_json/from_json'
@pytest.mark.vcr(
filter_query_parameters=[('access_token', 'DUMMY'), ('client_id', 'DUMMY'), ('client_secret', 'DUMMY')],
@ -1399,4 +1490,6 @@ def test_entity_accountcreationerrordetailsfield(mastodon_base, mastodon_admin):
result = mastodon.create_account('halcy', 'secret', 'invalid email lol', True, return_detailed_error=True)[1].details.email[0]
assert real_issubclass(type(result), AccountCreationErrorDetailsField), str(type(result)) + ' is not a subclass of AccountCreationErrorDetailsField'
result = Entity.from_json(result.to_json())
assert real_issubclass(type(result), AccountCreationErrorDetailsField), str(type(result)) + ' is not a subclass of AccountCreationErrorDetailsField after to_json/from_json'
if sys.version_info >= (3, 9):
assert real_issubclass(type(result), AccountCreationErrorDetailsField), str(type(result)) + ' is not a subclass of AccountCreationErrorDetailsField after to_json/from_json'