Implement new notification dismiss behaviour, add test for old behaviour
This commit is contained in:
pare
ec58bd4de8
commit
30eb63261c
S'han modificat 3 arxius amb 69 adicions i 24 eliminacions
|
@ -1795,15 +1795,19 @@ class Mastodon:
|
|||
self.__api_request('POST', '/api/v1/notifications/clear')
|
||||
|
||||
|
||||
@api_version("1.3.0", "1.3.0", "1.3.0")
|
||||
@api_version("1.3.0", "2.9.2", "2.9.2")
|
||||
def notifications_dismiss(self, id):
|
||||
"""
|
||||
Deletes a single notification
|
||||
"""
|
||||
id = self.__unpack_id(id)
|
||||
params = self.__generate_params(locals())
|
||||
self.__api_request('POST', '/api/v1/notifications/dismiss', params)
|
||||
|
||||
|
||||
if self.verify_minimum_version("2.9.2"):
|
||||
url = '/api/v1/notifications/{0}/dismiss'.format(str(id))
|
||||
return self.__api_request('POST', '/api/v1/notifications/dismiss', params)
|
||||
else:
|
||||
params = self.__generate_params(locals())
|
||||
self.__api_request('POST', '/api/v1/notifications/dismiss', params)
|
||||
|
||||
###
|
||||
# Writing data: Conversations
|
||||
|
|
|
@ -12,11 +12,11 @@ interactions:
|
|||
method: POST
|
||||
uri: http://localhost:3000/api/v1/statuses
|
||||
response:
|
||||
body: {string: '{"id":"102317291057725861","created_at":"2019-06-22T21:12:41.706Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102317291057725861","url":"http://localhost/@admin/102317291057725861","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"content":"\u003cp\u003e\u003cspan
|
||||
body: {string: '{"id":"102945481191655042","created_at":"2019-10-11T19:49:42.450Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102945481191655042","url":"http://localhost/@admin/102945481191655042","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"content":"\u003cp\u003e\u003cspan
|
||||
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@mastodonpy_test\" class=\"u-url
|
||||
mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
|
||||
hello!\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py test
|
||||
suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":17,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}'}
|
||||
suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}'}
|
||||
headers:
|
||||
Cache-Control: ['no-cache, no-store']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
|
@ -27,8 +27,8 @@ interactions:
|
|||
X-Download-Options: [noopen]
|
||||
X-Frame-Options: [SAMEORIGIN]
|
||||
X-Permitted-Cross-Domain-Policies: [none]
|
||||
X-Request-Id: [93a5beb9-f93d-4498-a0a6-c08258d72d95]
|
||||
X-Runtime: ['0.229491']
|
||||
X-Request-Id: [116f5b2b-1d95-4382-9c2c-cc392a5f684c]
|
||||
X-Runtime: ['0.211426']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['1488']
|
||||
status: {code: 200, message: OK}
|
||||
|
@ -43,16 +43,22 @@ interactions:
|
|||
method: GET
|
||||
uri: http://localhost:3000/api/v1/notifications
|
||||
response:
|
||||
body: {string: '[{"id":"112","type":"mention","created_at":"2019-06-22T21:12:41.829Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":17,"emojis":[],"fields":[]},"status":{"id":"102317291057725861","created_at":"2019-06-22T21:12:41.706Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102317291057725861","url":"http://localhost/@admin/102317291057725861","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"content":"\u003cp\u003e\u003cspan
|
||||
body: {string: '[{"id":"124","type":"mention","created_at":"2019-10-11T19:49:42.579Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"status":{"id":"102945481191655042","created_at":"2019-10-11T19:49:42.450Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102945481191655042","url":"http://localhost/@admin/102945481191655042","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"content":"\u003cp\u003e\u003cspan
|
||||
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@mastodonpy_test\" class=\"u-url
|
||||
mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
|
||||
hello!\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py test
|
||||
suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":17,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}}]'}
|
||||
suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}},{"id":"120","type":"poll","created_at":"2019-06-22T21:18:06.944Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"status":{"id":"102317292327454763","created_at":"2019-06-22T21:13:01.083Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102317292327454763","url":"http://localhost/@admin/102317292327454763","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"content":"\u003cp\u003enice\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py
|
||||
test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":{"id":"16","expires_at":"2019-06-22T21:18:01.074Z","expired":true,"multiple":false,"votes_count":1,"voted":true,"options":[{"title":"four
|
||||
twenty","votes_count":0},{"title":"sixty-nine","votes_count":1}],"emojis":[]}}},{"id":"115","type":"mention","created_at":"2019-06-22T21:13:26.829Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"status":{"id":"102317294005876209","created_at":"2019-06-22T21:13:26.706Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102317294005876209","url":"http://localhost/@admin/102317294005876209","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"content":"\u003cp\u003e\u003cspan
|
||||
class=\"h-card\"\u003e\u003ca href=\"http://localhost/@mastodonpy_test\" class=\"u-url
|
||||
mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
|
||||
beep beep I\u0026apos;m a jeep\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py
|
||||
test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}}]'}
|
||||
headers:
|
||||
Cache-Control: ['no-cache, no-store']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
Link: ['<http://localhost:3000/api/v1/notifications?max_id=112>; rel="next",
|
||||
<http://localhost:3000/api/v1/notifications?min_id=112>; rel="prev"']
|
||||
Link: ['<http://localhost:3000/api/v1/notifications?max_id=115>; rel="next",
|
||||
<http://localhost:3000/api/v1/notifications?min_id=124>; rel="prev"']
|
||||
Referrer-Policy: [strict-origin-when-cross-origin]
|
||||
Transfer-Encoding: [chunked]
|
||||
Vary: ['Accept-Encoding, Origin']
|
||||
|
@ -60,13 +66,42 @@ interactions:
|
|||
X-Download-Options: [noopen]
|
||||
X-Frame-Options: [SAMEORIGIN]
|
||||
X-Permitted-Cross-Domain-Policies: [none]
|
||||
X-Request-Id: [a381923e-e73f-479f-acea-eae201792ae7]
|
||||
X-Runtime: ['0.095464']
|
||||
X-Request-Id: [e8ea61bd-7565-4392-9a7a-e6152a5635d1]
|
||||
X-Runtime: ['0.126201']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['2089']
|
||||
content-length: ['6180']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: id=112
|
||||
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/instance/
|
||||
response:
|
||||
body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.9.1","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":3,"status_count":21,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=300, public']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
Date: ['Fri, 11 Oct 2019 19:49:42 GMT']
|
||||
ETag: [W/"b6028559f8312dda8add94d97903ca58"]
|
||||
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: [866137ef-767a-4738-aaf8-687d0b5f6062]
|
||||
X-Runtime: ['0.054816']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['349']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: id=124
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
|
@ -89,8 +124,8 @@ interactions:
|
|||
X-Download-Options: [noopen]
|
||||
X-Frame-Options: [SAMEORIGIN]
|
||||
X-Permitted-Cross-Domain-Policies: [none]
|
||||
X-Request-Id: [6d7d73d4-f824-4b47-805f-1552bc92f7d8]
|
||||
X-Runtime: ['0.041361']
|
||||
X-Request-Id: [3e179fba-39e7-4e2c-b58e-db7dc3fa2f03]
|
||||
X-Runtime: ['0.038802']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['2']
|
||||
status: {code: 200, message: OK}
|
||||
|
@ -104,10 +139,10 @@ interactions:
|
|||
Content-Length: ['0']
|
||||
User-Agent: [python-requests/2.18.4]
|
||||
method: DELETE
|
||||
uri: http://localhost:3000/api/v1/statuses/102317291057725861
|
||||
uri: http://localhost:3000/api/v1/statuses/102945481191655042
|
||||
response:
|
||||
body: {string: '{"id":"102317291057725861","created_at":"2019-06-22T21:12:41.706Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102317291057725861","url":"http://localhost/@admin/102317291057725861","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"text":"@mastodonpy_test
|
||||
hello!","reblog":null,"application":{"name":"Mastodon.py test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":17,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}'}
|
||||
body: {string: '{"id":"102945481191655042","created_at":"2019-10-11T19:49:42.450Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost/users/admin/statuses/102945481191655042","url":"http://localhost/@admin/102945481191655042","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"text":"@mastodonpy_test
|
||||
hello!","reblog":null,"application":{"name":"Mastodon.py test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T12:42:50.096Z","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":2,"following_count":1,"statuses_count":20,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[],"card":null,"poll":null}'}
|
||||
headers:
|
||||
Cache-Control: ['no-cache, no-store']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
|
@ -118,8 +153,8 @@ interactions:
|
|||
X-Download-Options: [noopen]
|
||||
X-Frame-Options: [SAMEORIGIN]
|
||||
X-Permitted-Cross-Domain-Policies: [none]
|
||||
X-Request-Id: [d8419c44-3f0a-4c22-b486-fe69128ad00a]
|
||||
X-Runtime: ['0.137253']
|
||||
X-Request-Id: [881b7e0e-4ee4-485c-9b01-746d55c0d4f7]
|
||||
X-Runtime: ['0.070719']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['1281']
|
||||
status: {code: 200, message: OK}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
import vcr
|
||||
|
||||
@pytest.fixture()
|
||||
def mention(api2):
|
||||
|
@ -14,7 +15,12 @@ def test_notifications(api, mention):
|
|||
@pytest.mark.vcr()
|
||||
def test_notifications_dismiss(api, mention):
|
||||
notifications = api.notifications()
|
||||
api.notifications_dismiss(notifications[0])
|
||||
api.notifications_dismiss(notifications[0]) # TODO possibly verify that this returns a notif dict
|
||||
|
||||
def test_notifications_dismiss_pre_2_9_2(api, mention):
|
||||
with vcr.use_cassette('test_notifications_dismiss.yaml', cassette_library_dir='tests/cassettes_pre_2_9_2', record_mode='none'):
|
||||
notifications = api.notifications()
|
||||
api.notifications_dismiss(notifications[0])
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_notifications_clear(api):
|
||||
|
|
Loading…
Referencia en una nova incidència