diff options
author | Lorenz Diener <[email protected]> | 2018-07-30 21:14:40 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2018-07-30 21:14:40 +0200 |
commit | ba3c2a8605806916bf4124daa1afcea4d3a7c9b9 (patch) | |
tree | c91ed12762b3a2a0cf86b15a0afc9bafb461fd51 /tests | |
parent | 5148658d9ae2cbd66985a42f3cf3e90bad51553b (diff) | |
download | mastodon.py-ba3c2a8605806916bf4124daa1afcea4d3a7c9b9.tar.gz |
Add follow suggestions test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cassettes/test_follow_suggestions.yaml | 89 | ||||
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rw-r--r-- | tests/test_account.py | 11 |
3 files changed, 101 insertions, 1 deletions
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 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
4 | headers: | ||
5 | Accept: ['*/*'] | ||
6 | Accept-Encoding: ['gzip, deflate'] | ||
7 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
8 | Connection: [keep-alive] | ||
9 | User-Agent: [python-requests/2.18.4] | ||
10 | method: GET | ||
11 | uri: http://localhost:3000/api/v1/suggestions | ||
12 | response: | ||
13 | body: {string: '[{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John | ||
14 | Lennon","locked":true,"bot":false,"created_at":"2018-07-13T23:02:25.260Z","note":"\u003cp\u003eI | ||
15 | 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!!!"}]}]'} | ||
16 | headers: | ||
17 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
18 | Content-Type: [application/json; charset=utf-8] | ||
19 | ETag: [W/"a8a5830de1c455c106d49ae63b3c3214"] | ||
20 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
21 | Transfer-Encoding: [chunked] | ||
22 | Vary: ['Accept-Encoding, Origin'] | ||
23 | X-Content-Type-Options: [nosniff] | ||
24 | X-Download-Options: [noopen] | ||
25 | X-Frame-Options: [SAMEORIGIN] | ||
26 | X-Permitted-Cross-Domain-Policies: [none] | ||
27 | X-Request-Id: [83a1b7b5-e8c7-4879-a409-dd0952636e47] | ||
28 | X-Runtime: ['0.024926'] | ||
29 | X-XSS-Protection: [1; mode=block] | ||
30 | content-length: ['875'] | ||
31 | status: {code: 200, message: OK} | ||
32 | - request: | ||
33 | body: null | ||
34 | headers: | ||
35 | Accept: ['*/*'] | ||
36 | Accept-Encoding: ['gzip, deflate'] | ||
37 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
38 | Connection: [keep-alive] | ||
39 | Content-Length: ['0'] | ||
40 | User-Agent: [python-requests/2.18.4] | ||
41 | method: DELETE | ||
42 | uri: http://localhost:3000/api/v1/suggestions/1234567890123456 | ||
43 | response: | ||
44 | body: {string: '{}'} | ||
45 | headers: | ||
46 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
47 | Content-Type: [application/json; charset=utf-8] | ||
48 | ETag: [W/"00bcb22f763257dc53dacce85525334a"] | ||
49 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
50 | Transfer-Encoding: [chunked] | ||
51 | Vary: ['Accept-Encoding, Origin'] | ||
52 | X-Content-Type-Options: [nosniff] | ||
53 | X-Download-Options: [noopen] | ||
54 | X-Frame-Options: [SAMEORIGIN] | ||
55 | X-Permitted-Cross-Domain-Policies: [none] | ||
56 | X-Request-Id: [99ccadef-2880-4390-a915-84ed54c08ee8] | ||
57 | X-Runtime: ['0.026851'] | ||
58 | X-XSS-Protection: [1; mode=block] | ||
59 | content-length: ['2'] | ||
60 | status: {code: 200, message: OK} | ||
61 | - request: | ||
62 | body: null | ||
63 | headers: | ||
64 | Accept: ['*/*'] | ||
65 | Accept-Encoding: ['gzip, deflate'] | ||
66 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
67 | Connection: [keep-alive] | ||
68 | User-Agent: [python-requests/2.18.4] | ||
69 | method: GET | ||
70 | uri: http://localhost:3000/api/v1/suggestions | ||
71 | response: | ||
72 | body: {string: '[]'} | ||
73 | headers: | ||
74 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
75 | Content-Type: [application/json; charset=utf-8] | ||
76 | ETag: [W/"2754f9333f4794de1152cb8dcf004ea0"] | ||
77 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
78 | Transfer-Encoding: [chunked] | ||
79 | Vary: ['Accept-Encoding, Origin'] | ||
80 | X-Content-Type-Options: [nosniff] | ||
81 | X-Download-Options: [noopen] | ||
82 | X-Frame-Options: [SAMEORIGIN] | ||
83 | X-Permitted-Cross-Domain-Policies: [none] | ||
84 | X-Request-Id: [1a00fb51-a5e5-4d8e-afe4-180c7c145b4c] | ||
85 | X-Runtime: ['0.015997'] | ||
86 | X-XSS-Protection: [1; mode=block] | ||
87 | content-length: ['2'] | ||
88 | status: {code: 200, message: OK} | ||
89 | 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 @@ | |||
1 | import pytest | 1 | import pytest |
2 | 2 | ||
3 | def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.4.0", version_check_mode="created"): | 3 | def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.4.3", version_check_mode="created"): |
4 | import mastodon | 4 | import mastodon |
5 | return mastodon.Mastodon( | 5 | return mastodon.Mastodon( |
6 | api_base_url='http://localhost:3000', | 6 | 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): | |||
162 | assert not status2 in pinned | 162 | assert not status2 in pinned |
163 | finally: | 163 | finally: |
164 | api.status_unpin(status['id']) | 164 | api.status_unpin(status['id']) |
165 | |||
166 | @pytest.mark.vcr() | ||
167 | def test_follow_suggestions(api): | ||
168 | suggestions = api.suggestions() | ||
169 | assert(suggestions) | ||
170 | assert(len(suggestions) > 0) | ||
171 | |||
172 | api.suggestion_delete(suggestions[0]) | ||
173 | suggestions2 = api.suggestions() | ||
174 | assert(len(suggestions2) < len(suggestions)) | ||
175 | |||