From 73c1e9e2d99bc76ffe4320b0a9045562613789ac Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sat, 12 Oct 2019 19:05:46 +0200 Subject: Add me()-function to return user account. Fixes #184 --- tests/cassettes/test_verify_credentials.yaml | 56 ++++++++++++++++++++++++++++ tests/test_account.py | 8 +++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/cassettes/test_verify_credentials.yaml (limited to 'tests') diff --git a/tests/cassettes/test_verify_credentials.yaml b/tests/cassettes/test_verify_credentials.yaml new file mode 100644 index 0000000..b694c7f --- /dev/null +++ b/tests/cassettes/test_verify_credentials.yaml @@ -0,0 +1,56 @@ +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":false,"bot":false,"created_at":"2019-06-22T23:11:52.441Z","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":1,"statuses_count":2,"last_status_at":"2019-10-11T21:50:54.637Z","source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[],"follow_requests_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: [8827e9e0-5d9c-4a85-a171-ac8e07b78716] + X-Runtime: ['0.075559'] + X-XSS-Protection: [1; mode=block] + content-length: ['724'] + 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/accounts/verify_credentials + response: + body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T23:11:52.441Z","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":1,"statuses_count":2,"last_status_at":"2019-10-11T21:50:54.637Z","source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[],"follow_requests_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: [7b015ff5-ebbe-4cfe-a7a2-4ebfc946a566] + X-Runtime: ['0.024838'] + X-XSS-Protection: [1; mode=block] + content-length: ['724'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/test_account.py b/tests/test_account.py index 9821c13..55f766f 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -7,7 +7,13 @@ def test_account(api): account = api.account(1) assert account - +@pytest.mark.vcr() +def test_verify_credentials(api): + account_a = api.account_verify_credentials() + account_b = api.me() + + assert account_a.id == account_b.id + @pytest.mark.vcr() def test_account_following(api): following = api.account_following(1) -- cgit v1.2.3