diff options
-rw-r--r-- | docs/index.rst | 8 | ||||
-rw-r--r-- | mastodon/Mastodon.py | 39 | ||||
-rw-r--r-- | tests/cassettes/test_account_pin_unpin.yaml | 233 | ||||
-rw-r--r-- | tests/cassettes/test_mutes.yaml | 6 | ||||
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rw-r--r-- | tests/test_account.py | 31 |
6 files changed, 314 insertions, 5 deletions
diff --git a/docs/index.rst b/docs/index.rst index 7561b6f..a7d2945 100644 --- a/docs/index.rst +++ b/docs/index.rst | |||
@@ -800,6 +800,12 @@ Reading data: Emoji | |||
800 | 800 | ||
801 | .. automethod:: Mastodon.custom_emojis | 801 | .. automethod:: Mastodon.custom_emojis |
802 | 802 | ||
803 | Reading data: Endorsements | ||
804 | -------------------------- | ||
805 | |||
806 | .. automethod:: Mastodon.endorsements | ||
807 | |||
808 | |||
803 | Writing data: Statuses | 809 | Writing data: Statuses |
804 | ---------------------- | 810 | ---------------------- |
805 | These functions allow you to post statuses to Mastodon and to | 811 | These functions allow you to post statuses to Mastodon and to |
@@ -838,6 +844,8 @@ These functions allow you to interact with other accounts: To (un)follow and | |||
838 | .. automethod:: Mastodon.account_unblock | 844 | .. automethod:: Mastodon.account_unblock |
839 | .. automethod:: Mastodon.account_mute | 845 | .. automethod:: Mastodon.account_mute |
840 | .. automethod:: Mastodon.account_unmute | 846 | .. automethod:: Mastodon.account_unmute |
847 | .. automethod:: Mastodon.account_pin | ||
848 | .. automethod:: Mastodon.account_unpin | ||
841 | .. automethod:: Mastodon.account_update_credentials | 849 | .. automethod:: Mastodon.account_update_credentials |
842 | 850 | ||
843 | Writing data: Keyword filters | 851 | Writing data: Keyword filters |
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index d272a33..ca7dbd6 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -924,6 +924,20 @@ class Mastodon: | |||
924 | return self.__api_request('GET', '/api/v1/suggestions') | 924 | return self.__api_request('GET', '/api/v1/suggestions') |
925 | 925 | ||
926 | ### | 926 | ### |
927 | # Reading data: Endorsements | ||
928 | ### | ||
929 | @api_version("2.5.0", "2.5.0", __DICT_VERSION_ACCOUNT) | ||
930 | def endorsements(self): | ||
931 | """ | ||
932 | Fetch list of users endorsemed by the logged-in user. | ||
933 | |||
934 | Returns a list of `user dicts`_. | ||
935 | |||
936 | """ | ||
937 | return self.__api_request('GET', '/api/v1/endorsements') | ||
938 | |||
939 | |||
940 | ### | ||
927 | # Reading data: Searching | 941 | # Reading data: Searching |
928 | ### | 942 | ### |
929 | @api_version("1.1.0", "2.1.0", __DICT_VERSION_SEARCHRESULT) | 943 | @api_version("1.1.0", "2.1.0", __DICT_VERSION_SEARCHRESULT) |
@@ -1463,8 +1477,9 @@ class Mastodon: | |||
1463 | Returns a `relationship dict`_ containing the updated relationship to the user. | 1477 | Returns a `relationship dict`_ containing the updated relationship to the user. |
1464 | """ | 1478 | """ |
1465 | id = self.__unpack_id(id) | 1479 | id = self.__unpack_id(id) |
1480 | params = self.__generate_params(locals(), ['id']) | ||
1466 | url = '/api/v1/accounts/{0}/mute'.format(str(id)) | 1481 | url = '/api/v1/accounts/{0}/mute'.format(str(id)) |
1467 | return self.__api_request('POST', url) | 1482 | return self.__api_request('POST', url, params) |
1468 | 1483 | ||
1469 | @api_version("1.1.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) | 1484 | @api_version("1.1.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1470 | def account_unmute(self, id): | 1485 | def account_unmute(self, id): |
@@ -1545,6 +1560,28 @@ class Mastodon: | |||
1545 | return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params, files=files) | 1560 | return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params, files=files) |
1546 | 1561 | ||
1547 | 1562 | ||
1563 | @api_version("2.5.0", "2.5.0", __DICT_VERSION_RELATIONSHIP) | ||
1564 | def account_pin(self, id): | ||
1565 | """ | ||
1566 | Pin / endorse a user. | ||
1567 | |||
1568 | Returns a `relationship dict`_ containing the updated relationship to the user. | ||
1569 | """ | ||
1570 | id = self.__unpack_id(id) | ||
1571 | url = '/api/v1/accounts/{0}/pin'.format(str(id)) | ||
1572 | return self.__api_request('POST', url) | ||
1573 | |||
1574 | @api_version("2.5.0", "2.5.0", __DICT_VERSION_RELATIONSHIP) | ||
1575 | def account_unpin(self, id): | ||
1576 | """ | ||
1577 | Unpin / un-endorse a user. | ||
1578 | |||
1579 | Returns a `relationship dict`_ containing the updated relationship to the user. | ||
1580 | """ | ||
1581 | id = self.__unpack_id(id) | ||
1582 | url = '/api/v1/accounts/{0}/unpin'.format(str(id)) | ||
1583 | return self.__api_request('POST', url) | ||
1584 | |||
1548 | ### | 1585 | ### |
1549 | # Writing data: Keyword filters | 1586 | # Writing data: Keyword filters |
1550 | ### | 1587 | ### |
diff --git a/tests/cassettes/test_account_pin_unpin.yaml b/tests/cassettes/test_account_pin_unpin.yaml new file mode 100644 index 0000000..eaf3563 --- /dev/null +++ b/tests/cassettes/test_account_pin_unpin.yaml | |||
@@ -0,0 +1,233 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
4 | headers: | ||
5 | Accept: ['*/*'] | ||
6 | Accept-Encoding: ['gzip, deflate'] | ||
7 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] | ||
8 | Connection: [keep-alive] | ||
9 | User-Agent: [python-requests/2.18.4] | ||
10 | method: GET | ||
11 | uri: http://localhost:3000/api/v1/accounts/verify_credentials | ||
12 | response: | ||
13 | body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","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":0,"following_count":0,"statuses_count":0,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'} | ||
14 | headers: | ||
15 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
16 | Content-Type: [application/json; charset=utf-8] | ||
17 | ETag: [W/"0f8b38bbae62fe172a62496fe49e206e"] | ||
18 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
19 | Transfer-Encoding: [chunked] | ||
20 | Vary: ['Accept-Encoding, Origin'] | ||
21 | X-Content-Type-Options: [nosniff] | ||
22 | X-Download-Options: [noopen] | ||
23 | X-Frame-Options: [SAMEORIGIN] | ||
24 | X-Permitted-Cross-Domain-Policies: [none] | ||
25 | X-Request-Id: [692fe5c4-e557-4dd5-99f0-44b812f2e9f3] | ||
26 | X-Runtime: ['0.019931'] | ||
27 | X-XSS-Protection: [1; mode=block] | ||
28 | content-length: ['609'] | ||
29 | status: {code: 200, message: OK} | ||
30 | - request: | ||
31 | body: reblogs=1&id=1 | ||
32 | headers: | ||
33 | Accept: ['*/*'] | ||
34 | Accept-Encoding: ['gzip, deflate'] | ||
35 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
36 | Connection: [keep-alive] | ||
37 | Content-Length: ['14'] | ||
38 | Content-Type: [application/x-www-form-urlencoded] | ||
39 | User-Agent: [python-requests/2.18.4] | ||
40 | method: POST | ||
41 | uri: http://localhost:3000/api/v1/accounts/1/follow | ||
42 | response: | ||
43 | body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'} | ||
44 | headers: | ||
45 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
46 | Content-Type: [application/json; charset=utf-8] | ||
47 | ETag: [W/"1e1fa14c270ff6960152323eda93cc79"] | ||
48 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
49 | Transfer-Encoding: [chunked] | ||
50 | Vary: ['Accept-Encoding, Origin'] | ||
51 | X-Content-Type-Options: [nosniff] | ||
52 | X-Download-Options: [noopen] | ||
53 | X-Frame-Options: [SAMEORIGIN] | ||
54 | X-Permitted-Cross-Domain-Policies: [none] | ||
55 | X-Request-Id: [ad3bfb7e-d816-4b51-8c90-e431d2330775] | ||
56 | X-Runtime: ['0.062775'] | ||
57 | X-XSS-Protection: [1; mode=block] | ||
58 | content-length: ['209'] | ||
59 | status: {code: 200, message: OK} | ||
60 | - request: | ||
61 | body: null | ||
62 | headers: | ||
63 | Accept: ['*/*'] | ||
64 | Accept-Encoding: ['gzip, deflate'] | ||
65 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
66 | Connection: [keep-alive] | ||
67 | Content-Length: ['0'] | ||
68 | User-Agent: [python-requests/2.18.4] | ||
69 | method: POST | ||
70 | uri: http://localhost:3000/api/v1/accounts/1/unpin | ||
71 | response: | ||
72 | body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'} | ||
73 | headers: | ||
74 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
75 | Content-Type: [application/json; charset=utf-8] | ||
76 | ETag: [W/"1e1fa14c270ff6960152323eda93cc79"] | ||
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: [312e2867-4349-4145-8bb0-231e59e3d02c] | ||
85 | X-Runtime: ['0.065496'] | ||
86 | X-XSS-Protection: [1; mode=block] | ||
87 | content-length: ['209'] | ||
88 | status: {code: 200, message: OK} | ||
89 | - request: | ||
90 | body: null | ||
91 | headers: | ||
92 | Accept: ['*/*'] | ||
93 | Accept-Encoding: ['gzip, deflate'] | ||
94 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
95 | Connection: [keep-alive] | ||
96 | Content-Length: ['0'] | ||
97 | User-Agent: [python-requests/2.18.4] | ||
98 | method: POST | ||
99 | uri: http://localhost:3000/api/v1/accounts/1/pin | ||
100 | response: | ||
101 | body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":true}'} | ||
102 | headers: | ||
103 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
104 | Content-Type: [application/json; charset=utf-8] | ||
105 | ETag: [W/"c6dfb53299bc83b46a9edb08d3930925"] | ||
106 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
107 | Transfer-Encoding: [chunked] | ||
108 | Vary: ['Accept-Encoding, Origin'] | ||
109 | X-Content-Type-Options: [nosniff] | ||
110 | X-Download-Options: [noopen] | ||
111 | X-Frame-Options: [SAMEORIGIN] | ||
112 | X-Permitted-Cross-Domain-Policies: [none] | ||
113 | X-Request-Id: [c9dae17d-d180-447b-bb49-4f6d4ce07f40] | ||
114 | X-Runtime: ['0.050245'] | ||
115 | X-XSS-Protection: [1; mode=block] | ||
116 | content-length: ['208'] | ||
117 | status: {code: 200, message: OK} | ||
118 | - request: | ||
119 | body: null | ||
120 | headers: | ||
121 | Accept: ['*/*'] | ||
122 | Accept-Encoding: ['gzip, deflate'] | ||
123 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
124 | Connection: [keep-alive] | ||
125 | User-Agent: [python-requests/2.18.4] | ||
126 | method: GET | ||
127 | uri: http://localhost:3000/api/v1/endorsements | ||
128 | response: | ||
129 | body: {string: '[{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","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":0,"emojis":[],"fields":[]}]'} | ||
130 | headers: | ||
131 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
132 | Content-Type: [application/json; charset=utf-8] | ||
133 | ETag: [W/"ae491d6254719d99832526fc14bfb68b"] | ||
134 | Link: ['<http://localhost:3000/api/v1/endorsements?since_id=1>; rel="prev"'] | ||
135 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
136 | Transfer-Encoding: [chunked] | ||
137 | Vary: ['Accept-Encoding, Origin'] | ||
138 | X-Content-Type-Options: [nosniff] | ||
139 | X-Download-Options: [noopen] | ||
140 | X-Frame-Options: [SAMEORIGIN] | ||
141 | X-Permitted-Cross-Domain-Policies: [none] | ||
142 | X-Request-Id: [855af719-1d1a-4fe0-93e7-b2ff9293a363] | ||
143 | X-Runtime: ['0.018452'] | ||
144 | X-XSS-Protection: [1; mode=block] | ||
145 | content-length: ['525'] | ||
146 | status: {code: 200, message: OK} | ||
147 | - request: | ||
148 | body: null | ||
149 | headers: | ||
150 | Accept: ['*/*'] | ||
151 | Accept-Encoding: ['gzip, deflate'] | ||
152 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
153 | Connection: [keep-alive] | ||
154 | Content-Length: ['0'] | ||
155 | User-Agent: [python-requests/2.18.4] | ||
156 | method: POST | ||
157 | uri: http://localhost:3000/api/v1/accounts/1/unpin | ||
158 | response: | ||
159 | body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'} | ||
160 | headers: | ||
161 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
162 | Content-Type: [application/json; charset=utf-8] | ||
163 | ETag: [W/"1e1fa14c270ff6960152323eda93cc79"] | ||
164 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
165 | Transfer-Encoding: [chunked] | ||
166 | Vary: ['Accept-Encoding, Origin'] | ||
167 | X-Content-Type-Options: [nosniff] | ||
168 | X-Download-Options: [noopen] | ||
169 | X-Frame-Options: [SAMEORIGIN] | ||
170 | X-Permitted-Cross-Domain-Policies: [none] | ||
171 | X-Request-Id: [e750e8c4-eae0-4ed6-9563-00ac35d85daa] | ||
172 | X-Runtime: ['0.025393'] | ||
173 | X-XSS-Protection: [1; mode=block] | ||
174 | content-length: ['209'] | ||
175 | status: {code: 200, message: OK} | ||
176 | - request: | ||
177 | body: null | ||
178 | headers: | ||
179 | Accept: ['*/*'] | ||
180 | Accept-Encoding: ['gzip, deflate'] | ||
181 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
182 | Connection: [keep-alive] | ||
183 | User-Agent: [python-requests/2.18.4] | ||
184 | method: GET | ||
185 | uri: http://localhost:3000/api/v1/endorsements | ||
186 | response: | ||
187 | body: {string: '[]'} | ||
188 | headers: | ||
189 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
190 | Content-Type: [application/json; charset=utf-8] | ||
191 | ETag: [W/"e2dc74be154e07a1d543fffa1604d2ab"] | ||
192 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
193 | Transfer-Encoding: [chunked] | ||
194 | Vary: ['Accept-Encoding, Origin'] | ||
195 | X-Content-Type-Options: [nosniff] | ||
196 | X-Download-Options: [noopen] | ||
197 | X-Frame-Options: [SAMEORIGIN] | ||
198 | X-Permitted-Cross-Domain-Policies: [none] | ||
199 | X-Request-Id: [15996817-bf63-4f5e-a34d-c6cf7702822c] | ||
200 | X-Runtime: ['0.019443'] | ||
201 | X-XSS-Protection: [1; mode=block] | ||
202 | content-length: ['2'] | ||
203 | status: {code: 200, message: OK} | ||
204 | - request: | ||
205 | body: null | ||
206 | headers: | ||
207 | Accept: ['*/*'] | ||
208 | Accept-Encoding: ['gzip, deflate'] | ||
209 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
210 | Connection: [keep-alive] | ||
211 | Content-Length: ['0'] | ||
212 | User-Agent: [python-requests/2.18.4] | ||
213 | method: POST | ||
214 | uri: http://localhost:3000/api/v1/accounts/1/unfollow | ||
215 | response: | ||
216 | body: {string: '{"id":"1","following":false,"showing_reblogs":false,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'} | ||
217 | headers: | ||
218 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
219 | Content-Type: [application/json; charset=utf-8] | ||
220 | ETag: [W/"714cd19713205feb75ce771b61d4564b"] | ||
221 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
222 | Transfer-Encoding: [chunked] | ||
223 | Vary: ['Accept-Encoding, Origin'] | ||
224 | X-Content-Type-Options: [nosniff] | ||
225 | X-Download-Options: [noopen] | ||
226 | X-Frame-Options: [SAMEORIGIN] | ||
227 | X-Permitted-Cross-Domain-Policies: [none] | ||
228 | X-Request-Id: [7710c7c9-40d9-4cd9-b483-2863d00916ff] | ||
229 | X-Runtime: ['0.041778'] | ||
230 | X-XSS-Protection: [1; mode=block] | ||
231 | content-length: ['211'] | ||
232 | status: {code: 200, message: OK} | ||
233 | version: 1 | ||
diff --git a/tests/cassettes/test_mutes.yaml b/tests/cassettes/test_mutes.yaml index 73b8df6..aca7b97 100644 --- a/tests/cassettes/test_mutes.yaml +++ b/tests/cassettes/test_mutes.yaml | |||
@@ -14,7 +14,7 @@ interactions: | |||
14 | headers: | 14 | headers: |
15 | Cache-Control: ['max-age=0, private, must-revalidate'] | 15 | Cache-Control: ['max-age=0, private, must-revalidate'] |
16 | Content-Type: [application/json; charset=utf-8] | 16 | Content-Type: [application/json; charset=utf-8] |
17 | ETag: [W/"90b6becb2b7152e68f928ca54703d5b5"] | 17 | ETag: [W/"0c6c8cc3cb75164dfb4ec124c252008f"] |
18 | Referrer-Policy: [strict-origin-when-cross-origin] | 18 | Referrer-Policy: [strict-origin-when-cross-origin] |
19 | Transfer-Encoding: [chunked] | 19 | Transfer-Encoding: [chunked] |
20 | Vary: ['Accept-Encoding, Origin'] | 20 | Vary: ['Accept-Encoding, Origin'] |
@@ -22,8 +22,8 @@ interactions: | |||
22 | X-Download-Options: [noopen] | 22 | X-Download-Options: [noopen] |
23 | X-Frame-Options: [SAMEORIGIN] | 23 | X-Frame-Options: [SAMEORIGIN] |
24 | X-Permitted-Cross-Domain-Policies: [none] | 24 | X-Permitted-Cross-Domain-Policies: [none] |
25 | X-Request-Id: [1ecc4a5b-3fa6-4aab-9f51-62a63df2668c] | 25 | X-Request-Id: [1bef2ecf-ea12-422d-802a-456ab7096e0b] |
26 | X-Runtime: ['0.021739'] | 26 | X-Runtime: ['0.060542'] |
27 | X-XSS-Protection: [1; mode=block] | 27 | X-XSS-Protection: [1; mode=block] |
28 | content-length: ['2'] | 28 | content-length: ['2'] |
29 | status: {code: 200, message: OK} | 29 | status: {code: 200, message: OK} |
diff --git a/tests/conftest.py b/tests/conftest.py index 3291bbe..66fffdc 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.3", version_check_mode="created"): | 3 | def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.8.0", 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 77a8f48..cd7633d 100644 --- a/tests/test_account.py +++ b/tests/test_account.py | |||
@@ -175,3 +175,34 @@ def test_follow_suggestions(api2, status): | |||
175 | suggestions2 = api2.suggestions() | 175 | suggestions2 = api2.suggestions() |
176 | assert(len(suggestions2) < len(suggestions)) | 176 | assert(len(suggestions2) < len(suggestions)) |
177 | 177 | ||
178 | @pytest.mark.vcr() | ||
179 | def test_account_pin_unpin(api, api2): | ||
180 | user = api2.account_verify_credentials() | ||
181 | |||
182 | # Make sure we are in the correct state | ||
183 | try: | ||
184 | api.account_follow(user) | ||
185 | except: | ||
186 | pass | ||
187 | |||
188 | try: | ||
189 | api.account_unpin(user) | ||
190 | except: | ||
191 | pass | ||
192 | |||
193 | relationship = api.account_pin(user) | ||
194 | endorsed = api.endorsements() | ||
195 | |||
196 | try: | ||
197 | assert relationship | ||
198 | assert relationship['endorsed'] | ||
199 | assert user["id"] in map(lambda x: x["id"], endorsed) | ||
200 | finally: | ||
201 | relationship = api.account_unpin(user) | ||
202 | endorsed2 = api.endorsements() | ||
203 | api.account_unfollow(user) | ||
204 | assert relationship | ||
205 | assert not relationship['endorsed'] | ||
206 | assert not user["id"] in map(lambda x: x["id"], endorsed2) | ||
207 | |||
208 | |||