remove duplicate functions

pull/397/head
halcy 2025-02-15 18:05:20 +02:00
rodzic 37189e84bc
commit 76de4a8912
3 zmienionych plików z 4 dodań i 268 usunięć

Wyświetl plik

@ -319,6 +319,8 @@ class Mastodon(Internals):
Admin version of :ref:`trending_tags() <trending_tags()>`. Includes unapproved tags.
The returned list is sorted, descending, by the instance's trending algorithm.
Returns a regular Tag without admin attributes between Mastodon.py v4.0.0 and v4.1.0 due to a bug.
"""
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/admin/trends/tags', params)
@ -700,29 +702,6 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
self.__api_request('DELETE', f'/api/v1/admin/email_domain_blocks/{id}')
@api_version("3.5.0", "3.5.0")
def admin_trending_links(self) -> NonPaginatableList[PreviewCard]:
"""
Fetch trending links, including unapproved and unreviewed ones. Requires scope `admin:read`.
"""
return self.__api_request('GET', '/api/v1/admin/trends/links')
@api_version("3.5.0", "3.5.0")
def admin_trending_statuses(self) -> NonPaginatableList[Status]:
"""
Fetch trending statuses, including unapproved and unreviewed ones. Requires scope `admin:read`.
"""
return self.__api_request('GET', '/api/v1/admin/trends/statuses')
@api_version("3.5.0", "4.1.0")
def admin_trending_tags(self) -> NonPaginatableList[Tag]:
"""
Fetch trending tags, including unapproved and unreviewed ones. Requires scope `admin:read`.
Returns a regular Tag without admin attributes between Mastodon.py v4.0.0 and v4.1.0 due to a bug.
"""
return self.__api_request('GET', '/api/v1/admin/trends/tags')
@api_version("4.2.0", "4.2.0")
def admin_approve_trending_link(self, id: Union[PreviewCard, IdType]) -> PreviewCard:
"""

Wyświetl plik

@ -1,238 +0,0 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
Connection:
- keep-alive
User-Agent:
- tests/v311
method: GET
uri: http://localhost:3000/api/v1/admin/trends/tags
response:
body:
string: '[]'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '2'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.04, sql.active_record;dur=0.86, cache_generate.active_support;dur=1.59,
cache_write.active_support;dur=0.11, instantiation.active_record;dur=0.29,
start_processing.action_controller;dur=0.01, render.active_model_serializers;dur=0.04,
process_action.action_controller;dur=22.31
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-RateLimit-Limit:
- '300'
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-13T22:00:00.999188Z'
X-Request-Id:
- ead883ad-0f5c-4e20-8434-3a4a6d90037e
X-Runtime:
- '0.041461'
X-XSS-Protection:
- '0'
vary:
- Authorization, Origin
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
Connection:
- keep-alive
User-Agent:
- tests/v311
method: GET
uri: http://localhost:3000/api/v1/admin/trends/statuses
response:
body:
string: '[]'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '2'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.04, sql.active_record;dur=2.29, cache_generate.active_support;dur=1.54,
cache_write.active_support;dur=0.10, instantiation.active_record;dur=0.28,
start_processing.action_controller;dur=0.00, render.active_model_serializers;dur=0.04,
process_action.action_controller;dur=27.11
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-RateLimit-Limit:
- '300'
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-13T22:00:00.042879Z'
X-Request-Id:
- 4c60559f-e07e-4261-9268-fd3802d67a1c
X-Runtime:
- '0.045720'
X-XSS-Protection:
- '0'
vary:
- Authorization, Accept-Language, Origin
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
Connection:
- keep-alive
User-Agent:
- tests/v311
method: GET
uri: http://localhost:3000/api/v1/admin/trends/links
response:
body:
string: '[]'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '2'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.04, sql.active_record;dur=4.14, cache_generate.active_support;dur=1.57,
cache_write.active_support;dur=0.11, instantiation.active_record;dur=0.26,
start_processing.action_controller;dur=0.00, render.active_model_serializers;dur=0.04,
process_action.action_controller;dur=30.35
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-RateLimit-Limit:
- '300'
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-13T22:00:00.096615Z'
X-Request-Id:
- 542d5e6d-46c2-411f-845a-14cbc4b00560
X-Runtime:
- '0.053313'
X-XSS-Protection:
- '0'
vary:
- Authorization, Accept-Language, Origin
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2
Connection:
- keep-alive
User-Agent:
- tests/v311
method: GET
uri: http://localhost:3000/api/v1/admin/trends/tags?limit=5
response:
body:
string: '[]'
headers:
Cache-Control:
- private, no-store
Content-Length:
- '2'
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'; form-action 'none'
Content-Type:
- application/json; charset=utf-8
ETag:
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
Referrer-Policy:
- strict-origin-when-cross-origin
Server-Timing:
- cache_read.active_support;dur=0.05, sql.active_record;dur=8.99, cache_generate.active_support;dur=4.99,
cache_write.active_support;dur=0.12, instantiation.active_record;dur=0.42,
start_processing.action_controller;dur=0.00, render.active_model_serializers;dur=0.05,
process_action.action_controller;dur=37.07
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-RateLimit-Limit:
- '300'
X-RateLimit-Remaining:
- '299'
X-RateLimit-Reset:
- '2025-02-13T22:00:00.148901Z'
X-Request-Id:
- d71eb8d1-ffd9-492e-be08-4448ffb7c9ff
X-Runtime:
- '0.052562'
X-XSS-Protection:
- '0'
vary:
- Authorization, Origin
status:
code: 200
message: OK
version: 1

Wyświetl plik

@ -156,7 +156,8 @@ def test_admin_trends(api2):
assert isinstance(api2.admin_trending_statuses(), list)
assert isinstance(api2.admin_trending_links(), list)
assert isinstance(api2.admin_trending_tags(limit=5), list)
# The management functions are unfortunately not really testable easily.
@pytest.mark.skip(reason="reject / accept of account requests isn't really testable without modifying instance settings. anyone want to fumble those into the DB setup and write this test, please do.")
def test_admin_accountrequests(api2):
pass
@ -295,9 +296,3 @@ def test_admin_email_domain_blocks(api2):
all_blocks_after_delete = api2.admin_email_domain_blocks()
assert not any(block.id == created_block.id for block in all_blocks_after_delete)
@pytest.mark.vcr()
def test_admin_trends(api2):
assert isinstance(api2.admin_trending_tags(), list)
assert isinstance(api2.admin_trending_statuses(), list)
assert isinstance(api2.admin_trending_links(), list)