From ba3c2a8605806916bf4124daa1afcea4d3a7c9b9 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Mon, 30 Jul 2018 21:14:40 +0200 Subject: Add follow suggestions test --- tests/cassettes/test_follow_suggestions.yaml | 89 ++++++++++++++++++++++++++++ tests/conftest.py | 2 +- tests/test_account.py | 11 ++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 tests/cassettes/test_follow_suggestions.yaml (limited to 'tests') diff --git a/tests/cassettes/test_follow_suggestions.yaml b/tests/cassettes/test_follow_suggestions.yaml new file mode 100644 index 0000000..f8b82a0 --- /dev/null +++ b/tests/cassettes/test_follow_suggestions.yaml @@ -0,0 +1,89 @@ +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/suggestions + response: + body: {string: '[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"bot":false,"created_at":"2018-07-13T23:02:25.260Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg","followers_count":0,"following_count":0,"statuses_count":90,"emojis":[],"fields":[{"name":"bread","value":"toasty."},{"name":"lasagna","value":"no!!!"}]}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"a8a5830de1c455c106d49ae63b3c3214"] + 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: [83a1b7b5-e8c7-4879-a409-dd0952636e47] + X-Runtime: ['0.024926'] + X-XSS-Protection: [1; mode=block] + content-length: ['875'] + 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.18.4] + method: DELETE + uri: http://localhost:3000/api/v1/suggestions/1234567890123456 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"00bcb22f763257dc53dacce85525334a"] + 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: [99ccadef-2880-4390-a915-84ed54c08ee8] + X-Runtime: ['0.026851'] + 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.18.4] + method: GET + uri: http://localhost:3000/api/v1/suggestions + response: + body: {string: '[]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"2754f9333f4794de1152cb8dcf004ea0"] + 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: [1a00fb51-a5e5-4d8e-afe4-180c7c145b4c] + X-Runtime: ['0.015997'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/conftest.py b/tests/conftest.py index 49eb453..7346d31 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ import pytest -def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.4.0", version_check_mode="created"): +def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.4.3", version_check_mode="created"): import mastodon return mastodon.Mastodon( api_base_url='http://localhost:3000', diff --git a/tests/test_account.py b/tests/test_account.py index 0a2e870..71ceb66 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -162,3 +162,14 @@ def test_account_pinned(status, status2, api): assert not status2 in pinned finally: api.status_unpin(status['id']) + +@pytest.mark.vcr() +def test_follow_suggestions(api): + suggestions = api.suggestions() + assert(suggestions) + assert(len(suggestions) > 0) + + api.suggestion_delete(suggestions[0]) + suggestions2 = api.suggestions() + assert(len(suggestions2) < len(suggestions)) + -- cgit v1.2.3