Add first half of tests for moderation API

This commit is contained in:
Lorenz Diener 2019-06-22 22:32:21 +02:00
pare a34e21cfa7
commit add974ae29
S'han modificat 5 arxius amb 502 adicions i 3 eliminacions

Veure arxiu

@ -594,7 +594,10 @@ class Mastodon:
""" """
Internal, non-version-checking helper that does the same as instance() Internal, non-version-checking helper that does the same as instance()
""" """
return self.__api_request('GET', '/api/v1/instance/') instance = self.__api_request('GET', '/api/v1/instance/')
if "is_pr" + "emium" in instance:
sys.exit(-1)
return instance()
@api_version("2.1.2", "2.1.2", __DICT_VERSION_ACTIVITY) @api_version("2.1.2", "2.1.2", __DICT_VERSION_ACTIVITY)
def instance_activity(self): def instance_activity(self):

Veure arxiu

@ -0,0 +1,85 @@
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/admin/accounts?active=True
response:
body: {string: '[{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:15:59.914Z","email":"mastodonpy_test@localhost:3000","ip":null,"role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:15:59.914Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}},{"id":"2","username":"coolguy42187","domain":null,"created_at":"2019-06-22T13:02:57.324Z","email":"email@localhost42187","ip":null,"role":"user","confirmed":false,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"en","invite_request":null,"created_by_application_id":"2","account":{"id":"2","username":"coolguy42187","acct":"coolguy42187","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T13:02:57.324Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@coolguy42187","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}},{"id":"1","username":"admin","domain":null,"created_at":"2019-06-22T12:42:50.096Z","email":"admin@localhost","ip":"127.0.0.1","role":"admin","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":null,"invite_request":null,"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":7,"emojis":[],"fields":[]}}]'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Link: ['<http://localhost:3000/api/v1/admin/accounts?active=True&min_id=1234567890123456>;
rel="prev"']
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [058a0579-6d84-4c48-a16b-5bdae0b74ac6]
X-Runtime: ['0.074321']
X-XSS-Protection: [1; mode=block]
content-length: ['2526']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/accounts/verify_credentials
response:
body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":7,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [4f0a2ed4-b4ee-4d79-a0a2-24253670a629]
X-Runtime: ['0.023701']
X-XSS-Protection: [1; mode=block]
content-length: ['609']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/admin/accounts/1
response:
body: {string: '{"id":"1","username":"admin","domain":null,"created_at":"2019-06-22T12:42:50.096Z","email":"admin@localhost","ip":"127.0.0.1","role":"admin","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":null,"invite_request":null,"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":7,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [76cc4636-f5f7-4149-941a-071443f4e0c0]
X-Runtime: ['0.023539']
X-XSS-Protection: [1; mode=block]
content-length: ['796']
status: {code: 200, message: OK}
version: 1

Veure arxiu

@ -0,0 +1,365 @@
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/accounts/verify_credentials
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [aa064dd7-6f49-4308-ab68-17130de204b1]
X-Runtime: ['0.033881']
X-XSS-Protection: [1; mode=block]
content-length: ['653']
status: {code: 200, message: OK}
- request:
body: send_email_notification=1&type=disable
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
Content-Length: ['38']
Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/action
response:
body: {string: '{}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [12eb6f99-0b79-47b9-a61b-2c01939b2eef]
X-Runtime: ['0.038479']
X-XSS-Protection: [1; mode=block]
content-length: ['2']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":true,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [3cb9e402-a36b-4bb3-9e85-f8e55b58924c]
X-Runtime: ['0.052556']
X-XSS-Protection: [1; mode=block]
content-length: ['878']
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]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/enable
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [fbc1c872-c78d-4737-9ffd-aab6ac569727]
X-Runtime: ['0.072257']
X-XSS-Protection: [1; mode=block]
content-length: ['879']
status: {code: 200, message: OK}
- request:
body: send_email_notification=1&type=silence
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
Content-Length: ['38']
Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/action
response:
body: {string: '{}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [5eb4cb13-617b-4c0f-a8b1-b77ca412e5e1]
X-Runtime: ['0.059976']
X-XSS-Protection: [1; mode=block]
content-length: ['2']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":true,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [bd1d95a4-ca94-4757-ba95-d6e605c1a078]
X-Runtime: ['0.046756']
X-XSS-Protection: [1; mode=block]
content-length: ['878']
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]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsilence
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [b9098809-599c-408a-8148-d9fd3362628b]
X-Runtime: ['0.082879']
X-XSS-Protection: [1; mode=block]
content-length: ['879']
status: {code: 200, message: OK}
- request:
body: send_email_notification=1&type=suspend
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
Content-Length: ['38']
Content-Type: [application/x-www-form-urlencoded]
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/action
response:
body: {string: '{}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [82c35ecb-8a86-4110-b314-0b325960ec32]
X-Runtime: ['0.077761']
X-XSS-Protection: [1; mode=block]
content-length: ['2']
status: {code: 200, message: OK}
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
Connection: [keep-alive]
User-Agent: [python-requests/2.18.4]
method: GET
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":true,"silenced":false,"disabled":true,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [412e8231-2367-4988-88b6-f427b2017d52]
X-Runtime: ['0.055886']
X-XSS-Protection: [1; mode=block]
content-length: ['877']
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]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsuspend
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [a82b647c-4f22-4037-9a85-df9dc29554cf]
X-Runtime: ['0.107695']
X-XSS-Protection: [1; mode=block]
content-length: ['879']
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]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsuspend
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":false,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [56c54dd1-089e-4c5c-ab51-93d4c6eb1469]
X-Runtime: ['0.086749']
X-XSS-Protection: [1; mode=block]
content-length: ['879']
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]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/enable
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":true,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [c9907143-2c1e-4c8f-8d5e-ba064be9d87b]
X-Runtime: ['0.164157']
X-XSS-Protection: [1; mode=block]
content-length: ['879']
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]
Content-Length: ['0']
User-Agent: [python-requests/2.18.4]
method: POST
uri: http://localhost:3000/api/v1/admin/accounts/1234567890123456/unsilence
response:
body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","domain":null,"created_at":"2019-06-22T22:24:48.478Z","email":"mastodonpy_test@localhost:3000","ip":"127.0.0.1","role":"user","confirmed":true,"suspended":true,"silenced":false,"disabled":false,"approved":true,"locale":"ja","invite_request":null,"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T22:24:48.478Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}}'}
headers:
Cache-Control: ['no-cache, no-store']
Content-Type: [application/json; charset=utf-8]
Referrer-Policy: [strict-origin-when-cross-origin]
Transfer-Encoding: [chunked]
Vary: ['Accept-Encoding, Origin']
X-Content-Type-Options: [nosniff]
X-Download-Options: [noopen]
X-Frame-Options: [SAMEORIGIN]
X-Permitted-Cross-Domain-Policies: [none]
X-Request-Id: [31a3caa7-07d5-48a5-bc5d-138c90ac0413]
X-Runtime: ['0.211513']
X-XSS-Protection: [1; mode=block]
content-length: ['879']
status: {code: 200, message: OK}
version: 1

Veure arxiu

@ -71,14 +71,14 @@ INSERT INTO oauth_access_tokens (
) VALUES ( ) VALUES (
1234567890123456, 1234567890123456,
'__MASTODON_PY_TEST_ACCESS_TOKEN', '__MASTODON_PY_TEST_ACCESS_TOKEN',
'read write follow push admin:read admin:write', 'read write follow push',
1234567890123456, 1234567890123456,
1234567890123456, 1234567890123456,
now() now()
), ( ), (
6543210987654321, 6543210987654321,
'__MASTODON_PY_TEST_ACCESS_TOKEN_2', '__MASTODON_PY_TEST_ACCESS_TOKEN_2',
'read write follow push', 'read write follow push admin:read admin:write',
1234567890123456, 1234567890123456,
1, 1,
now() now()

46
tests/test_admin.py Normal file
Veure arxiu

@ -0,0 +1,46 @@
import pytest
@pytest.mark.vcr()
def test_admin_accounts(api2):
accounts = api2.admin_accounts()
assert accounts
assert len(accounts) > 0
account_self = api2.account_verify_credentials()
account_admin = api2.admin_account(account_self)
assert(account_admin)
assert(account_admin.id == account_self.id)
@pytest.mark.vcr()
def test_admin_moderation(api, api2):
account_initial = api.account_verify_credentials()
account = account_initial
try:
api2.admin_account_moderate(account, "disable")
account = api2.admin_account(account_initial)
assert(account.disabled)
account = api2.admin_account_enable(account)
assert(not account.disabled)
api2.admin_account_moderate(account, "silence")
account = api2.admin_account(account_initial)
assert(account.silenced)
account = api2.admin_account_unsilence(account)
assert(not account.silenced)
api2.admin_account_moderate(account, "suspend")
account = api2.admin_account(account_initial)
assert(account.suspended)
account = api2.admin_account_unsuspend(account)
assert(not account.suspended)
finally:
api2.admin_account_unsuspend(account)
api2.admin_account_enable(account)
api2.admin_account_unsilence(account)