From ba2fccc1cf0957387f616da64c20e329eba95263 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sun, 6 May 2018 15:42:38 +0200 Subject: [PATCH] Add lists tests and fix a bug --- mastodon/Mastodon.py | 1 + .../test_list_add_remove_account.yaml | 367 ++++++++++++++++++ tests/cassettes/test_list_by_account.yaml | 184 +++++++++ tests/cassettes/test_list_create.yaml | 80 ++++ tests/cassettes/test_list_timeline.yaml | 244 ++++++++++++ tests/cassettes/test_list_update.yaml | 157 ++++++++ tests/test_lists.py | 61 +++ 7 files changed, 1094 insertions(+) create mode 100644 tests/cassettes/test_list_add_remove_account.yaml create mode 100644 tests/cassettes/test_list_by_account.yaml create mode 100644 tests/cassettes/test_list_create.yaml create mode 100644 tests/cassettes/test_list_timeline.yaml create mode 100644 tests/cassettes/test_list_update.yaml create mode 100644 tests/test_lists.py diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index a2ff65f..6ab9291 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -708,6 +708,7 @@ class Mastodon: Returns a list of `list dicts`_. """ + id = self.__unpack_id(id) params = self.__generate_params(locals(), ['id']) url = '/api/v1/accounts/{0}/lists'.format(str(id)) return self.__api_request('GET', url, params) diff --git a/tests/cassettes/test_list_add_remove_account.yaml b/tests/cassettes/test_list_add_remove_account.yaml new file mode 100644 index 0000000..f0b0ba7 --- /dev/null +++ b/tests/cassettes/test_list_add_remove_account.yaml @@ -0,0 +1,367 @@ +interactions: +- request: + body: title=ham+burglars + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '{"id":"23","title":"ham burglars"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"0bcee380026306b4b8a9913243ef8d50"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [259f3b2e-1a4a-469d-82da-c2c604c4a950] + X-Runtime: ['0.056062'] + X-XSS-Protection: [1; mode=block] + content-length: ['34'] + 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.9.1] + method: GET + uri: http://localhost:3000/api/v1/accounts/verify_credentials + response: + body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":51,"source":{"privacy":"public","sensitive":false,"note":""}}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"52597edacbe583a8c705f06e18236329"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [2d436ac6-f2f9-4b2c-882e-8700462f1360] + X-Runtime: ['0.071364'] + X-XSS-Protection: [1; mode=block] + content-length: ['571'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/follow + response: + body: {string: '{"id":"1","following":true,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"98c147556f83bd7b26490f2eac449592"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [79ef47dd-e003-4d92-b6ba-dfb51011822f] + X-Runtime: ['0.099480'] + X-XSS-Protection: [1; mode=block] + content-length: ['174'] + status: {code: 200, message: OK} +- request: + body: account_ids%5B%5D=1 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"ee6751ce2dc32e165dd24aca071f6eed"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [0a67c0e2-3839-4c48-9d71-6a2a2e53f493] + X-Runtime: ['0.064774'] + 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] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '[{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":51}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"4d3af392a570a5835fef368719dd8061"] + Link: ['; rel="prev"'] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [8fe7676a-8ba8-4eb9-bd43-63889ea9c192] + X-Runtime: ['0.052742'] + X-XSS-Protection: [1; mode=block] + content-length: ['515'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/unfollow + response: + body: {string: '{"id":"1","following":false,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"1e5f6a4b23911d5c2aeb66f774492a0b"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [f9e46470-cfe8-4d23-bbf8-d909a0c9502a] + X-Runtime: ['0.086559'] + X-XSS-Protection: [1; mode=block] + content-length: ['175'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '[]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7762a54b770895c411eb3e681494e743"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [500b6154-3bdb-4cbb-bb99-e87072552943] + X-Runtime: ['0.057220'] + 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] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/follow + response: + body: {string: '{"id":"1","following":true,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"98c147556f83bd7b26490f2eac449592"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [1f5d47f3-591f-4e91-bd77-0942c45caedb] + X-Runtime: ['0.081679'] + X-XSS-Protection: [1; mode=block] + content-length: ['174'] + status: {code: 200, message: OK} +- request: + body: account_ids%5B%5D=1 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"ee6751ce2dc32e165dd24aca071f6eed"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [0f8bc3a7-c8fe-444b-b994-485c98cbda0a] + X-Runtime: ['0.064982'] + 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] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '[{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":51}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"b9836e2f0226339c225639e9cc22ede9"] + Link: ['; rel="prev"'] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [794c2f5c-3edd-4b24-b8e3-bf9b26c021df] + X-Runtime: ['0.048936'] + X-XSS-Protection: [1; mode=block] + content-length: ['515'] + status: {code: 200, message: OK} +- request: + body: account_ids%5B%5D=1 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7d75201dffe84268b8e3844d4dc96e56"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [5b9c340c-9df5-4875-a754-9bd36a6398d2] + X-Runtime: ['0.054353'] + 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] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists/23/accounts + response: + body: {string: '[]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"d136973c02e6e12b3280a000929bdfab"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [6cc121cd-cc66-4795-b9cd-8272b89166ff] + X-Runtime: ['0.050224'] + 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] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/unfollow + response: + body: {string: '{"id":"1","following":false,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"b2c35ec6363918f9324f60b9ce18ad00"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [32c56b5c-a75f-45a3-a7fc-cf048dca9ce2] + X-Runtime: ['0.053228'] + X-XSS-Protection: [1; mode=block] + content-length: ['175'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/lists/23 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7d75201dffe84268b8e3844d4dc96e56"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [6f82b353-ca11-4c04-bd5c-36c02e050462] + X-Runtime: ['0.032468'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_list_by_account.yaml b/tests/cassettes/test_list_by_account.yaml new file mode 100644 index 0000000..d07bfb7 --- /dev/null +++ b/tests/cassettes/test_list_by_account.yaml @@ -0,0 +1,184 @@ +interactions: +- request: + body: title=ham+burglars + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '{"id":"24","title":"ham burglars"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"be955eaf8be280515d5ba0ba9ecb1a50"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [672adb20-033a-4630-82f4-4646ce737155] + X-Runtime: ['0.055324'] + X-XSS-Protection: [1; mode=block] + content-length: ['34'] + 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.9.1] + method: GET + uri: http://localhost:3000/api/v1/accounts/verify_credentials + response: + body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":51,"source":{"privacy":"public","sensitive":false,"note":""}}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"691f6bd96e64ff4fe001604d8861d949"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [d9788143-6fa1-4353-ab46-a4a157265615] + X-Runtime: ['0.059023'] + X-XSS-Protection: [1; mode=block] + content-length: ['571'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/follow + response: + body: {string: '{"id":"1","following":true,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"f91b05337597468badfd19f87dd3fe7d"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [3d70f64d-6d49-403e-b666-a266faa93132] + X-Runtime: ['0.107833'] + X-XSS-Protection: [1; mode=block] + content-length: ['174'] + status: {code: 200, message: OK} +- request: + body: account_ids%5B%5D=1 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists/24/accounts + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7d75201dffe84268b8e3844d4dc96e56"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [75a29c9f-5126-4cb7-b446-b8cbc7800408] + X-Runtime: ['0.069586'] + 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] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/accounts/1/lists + response: + body: {string: '[{"id":"24","title":"ham burglars"}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"47f8168c1f7a8f3d8ff54544f88564d8"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [afb958a3-8002-4cc1-abbf-907d69032264] + X-Runtime: ['0.040643'] + X-XSS-Protection: [1; mode=block] + content-length: ['36'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/unfollow + response: + body: {string: '{"id":"1","following":false,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"b2c35ec6363918f9324f60b9ce18ad00"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [0d09fa82-d5b4-440c-b5aa-4f995cbd452a] + X-Runtime: ['0.097106'] + X-XSS-Protection: [1; mode=block] + content-length: ['175'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/lists/24 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7d75201dffe84268b8e3844d4dc96e56"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [5918aefb-8fa2-465f-b513-5ef9f4036a88] + X-Runtime: ['0.063303'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_list_create.yaml b/tests/cassettes/test_list_create.yaml new file mode 100644 index 0000000..41c9d50 --- /dev/null +++ b/tests/cassettes/test_list_create.yaml @@ -0,0 +1,80 @@ +interactions: +- request: + body: title=ham+burglars + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '{"id":"21","title":"ham burglars"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7a697af6c938508b5253601ebd4dd6e6"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [ace7486c-8c0b-46ef-8dc2-69719035824f] + X-Runtime: ['0.030442'] + X-XSS-Protection: [1; mode=block] + content-length: ['34'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '[{"id":"1","title":"ham burglars"},{"id":"21","title":"ham burglars"}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"158cecd920100143aaaaca0e264e3eff"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [cb76cdf7-a8a4-47ab-b22d-8d605bfcb2e5] + X-Runtime: ['0.019989'] + X-XSS-Protection: [1; mode=block] + content-length: ['70'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/lists/21 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"517599317c4db2fd6c980b4f38eaa967"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [82ba57ca-5026-403f-a024-8b33c87504a2] + X-Runtime: ['0.025599'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_list_timeline.yaml b/tests/cassettes/test_list_timeline.yaml new file mode 100644 index 0000000..ceb2089 --- /dev/null +++ b/tests/cassettes/test_list_timeline.yaml @@ -0,0 +1,244 @@ +interactions: +- request: + body: title=ham+burglars + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '{"id":"25","title":"ham burglars"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"c56ed009e747b046f62c422a4bd0c475"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [fee67ca2-a91f-4d5e-870d-f94f63fdae01] + X-Runtime: ['0.046275'] + X-XSS-Protection: [1; mode=block] + content-length: ['34'] + 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.9.1] + method: GET + uri: http://localhost:3000/api/v1/accounts/verify_credentials + response: + body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":51,"source":{"privacy":"public","sensitive":false,"note":""}}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"6f31f5da2f0f9aeec5ce050c8e439288"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [c7ba1cc0-3315-4847-a0f8-7ca1c8014f53] + X-Runtime: ['0.048756'] + X-XSS-Protection: [1; mode=block] + content-length: ['571'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/follow + response: + body: {string: '{"id":"1","following":true,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"ff571039e7eccffedf0c3baf0ee5835d"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [aecd782a-5218-489a-a801-52be98fab5bb] + X-Runtime: ['0.137542'] + X-XSS-Protection: [1; mode=block] + content-length: ['174'] + status: {code: 200, message: OK} +- request: + body: account_ids%5B%5D=1 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists/25/accounts + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"1040bdd26362a18b29d5084d0ea80fbc"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [327011fb-439c-4d25-b568-5f3b2c3f7d54] + X-Runtime: ['0.073036'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +- request: + body: visibility=public&status=I+have+never+stolen+a+ham+in+my+life. + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] + Connection: [keep-alive] + Content-Length: ['62'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses + response: + body: {string: '{"id":"99982642668365711","created_at":"2018-05-06T13:40:54.415Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99982642668365711","content":"\u003cp\u003eI + have never stolen a ham in my life.\u003c/p\u003e","url":"http://localhost:3000/@admin/99982642668365711","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":52},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"088ca43a6864bf53d809c7cc6be28fbb"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [960b252d-e19e-4c3c-ab13-6ca5e82038e1] + X-Runtime: ['0.239041'] + X-XSS-Protection: [1; mode=block] + content-length: ['1158'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/timelines/list/25 + response: + body: {string: '[{"id":"99982642668365711","created_at":"2018-05-06T13:40:54.415Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99982642668365711","content":"\u003cp\u003eI + have never stolen a ham in my life.\u003c/p\u003e","url":"http://localhost:3000/@admin/99982642668365711","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"created_at":"2018-04-17T21:40:55.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":52},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"db76a989e40e671ea4344ecdaacebe3d"] + Link: ['; + rel="next", ; + rel="prev"'] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [5bd50e1b-667c-4f56-b363-d576b1a7aab2] + X-Runtime: ['0.133037'] + X-XSS-Protection: [1; mode=block] + content-length: ['1145'] + 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.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/statuses/99982642668365711 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"1040bdd26362a18b29d5084d0ea80fbc"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [0aadaf37-9c0a-45e6-ae00-47e47775257f] + X-Runtime: ['0.059188'] + 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] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/accounts/1/unfollow + response: + body: {string: '{"id":"1","following":false,"showing_reblogs":false,"followed_by":false,"blocking":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"a1b7df866f4cd9bb23dfdc00a0f40042"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [eb36fc4f-98cb-430f-ad5c-1efb8e41641b] + X-Runtime: ['0.124516'] + X-XSS-Protection: [1; mode=block] + content-length: ['175'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/lists/25 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"fb2e8895e367561e01e27ebb11075fd3"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [24816eab-335e-4282-92f9-e202b71824f7] + X-Runtime: ['0.041613'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_list_update.yaml b/tests/cassettes/test_list_update.yaml new file mode 100644 index 0000000..e2c64d6 --- /dev/null +++ b/tests/cassettes/test_list_update.yaml @@ -0,0 +1,157 @@ +interactions: +- request: + body: title=ham+burglars + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '{"id":"22","title":"ham burglars"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"0c98211766a89984581c09197affd90c"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [fe851633-a39e-4bbd-8ecd-665d08ad9d69] + X-Runtime: ['0.046417'] + X-XSS-Protection: [1; mode=block] + content-length: ['34'] + status: {code: 200, message: OK} +- request: + body: title=fry+kids + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['14'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: PUT + uri: http://localhost:3000/api/v1/lists/22 + response: + body: {string: '{"id":"22","title":"fry kids"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"6dd7ff39115629170e5815c546666ab8"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [157f5470-3782-40e4-80ac-ea94f8e3f575] + X-Runtime: ['0.051260'] + X-XSS-Protection: [1; mode=block] + content-length: ['30'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '[{"id":"1","title":"ham burglars"},{"id":"22","title":"fry kids"}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"3a312ac5c7092d9a90693c236852fdc9"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [22dae45a-b92a-4ff0-b1a0-50ff690f429a] + X-Runtime: ['0.045067'] + X-XSS-Protection: [1; mode=block] + content-length: ['66'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists + response: + body: {string: '[{"id":"1","title":"ham burglars"},{"id":"22","title":"fry kids"}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"3a312ac5c7092d9a90693c236852fdc9"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [c4381d47-2ef7-40f8-ae75-ce8996886177] + X-Runtime: ['0.036421'] + X-XSS-Protection: [1; mode=block] + content-length: ['66'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/lists/22 + response: + body: {string: '{"id":"22","title":"fry kids"}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"6dd7ff39115629170e5815c546666ab8"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [3e821cd3-7c44-4e3a-8cdf-9fa498f0bb68] + X-Runtime: ['0.020432'] + X-XSS-Protection: [1; mode=block] + content-length: ['30'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/lists/22 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"ee6751ce2dc32e165dd24aca071f6eed"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [a8576f90-288b-4271-af8a-9bcabf3e2df9] + X-Runtime: ['0.032007'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/test_lists.py b/tests/test_lists.py new file mode 100644 index 0000000..61300c8 --- /dev/null +++ b/tests/test_lists.py @@ -0,0 +1,61 @@ +import pytest + +@pytest.fixture() +def mastodon_list(api): + mastodon_list = api.list_create('ham burglars') + yield mastodon_list + api.list_delete(mastodon_list) + +@pytest.mark.vcr() +def test_list_create(api, mastodon_list): + assert mastodon_list in api.lists() + +@pytest.mark.vcr() +def test_list_update(api, mastodon_list): + mastodon_list_modified = api.list_update(mastodon_list, 'fry kids') + assert not mastodon_list in api.lists() + assert mastodon_list_modified in api.lists() + assert api.list(mastodon_list) == mastodon_list_modified + +@pytest.mark.vcr() +def test_list_add_remove_account(api, api2, mastodon_list): + user = api2.account_verify_credentials() + + api.account_follow(user) + api.list_accounts_add(mastodon_list, user) + assert user.id in map(lambda x: x.id, api.list_accounts(mastodon_list)) + + api.account_unfollow(user) + assert len(api.list_accounts(mastodon_list)) == 0 + + api.account_follow(user) + api.list_accounts_add(mastodon_list, user) + assert user.id in map(lambda x: x.id, api.list_accounts(mastodon_list)) + + api.list_accounts_delete(mastodon_list, user) + assert len(api.list_accounts(mastodon_list)) == 0 + + api.account_unfollow(user) + +@pytest.mark.vcr() +def test_list_by_account(api, api2, mastodon_list): + user = api2.account_verify_credentials() + + api.account_follow(user) + api.list_accounts_add(mastodon_list, user) + assert mastodon_list in api.account_lists(user) + api.account_unfollow(user) + +@pytest.mark.vcr() +def test_list_timeline(api, api2, mastodon_list): + user = api2.account_verify_credentials() + + api.account_follow(user) + api.list_accounts_add(mastodon_list, user) + + status = api2.status_post("I have never stolen a ham in my life.", visibility="public") + assert status.id in map(lambda x: x.id, api.timeline_list(mastodon_list)) + + api2.status_delete(status) + api.account_unfollow(user) + \ No newline at end of file