Add push tests
This commit is contained in:
pare
18c6b3b90f
commit
01e52ccd8f
S'han modificat 8 arxius amb 1407 adicions i 24 eliminacions
|
@ -70,6 +70,7 @@ def api_version(created_ver, last_changed_ver, return_value_ver):
|
|||
if major > self.mastodon_major:
|
||||
raise MastodonVersionError("Version check failed (Need version " + version + ")")
|
||||
elif major == self.mastodon_major and minor > self.mastodon_minor:
|
||||
print(self.mastodon_minor)
|
||||
raise MastodonVersionError("Version check failed (Need version " + version + ")")
|
||||
elif major == self.mastodon_major and minor == self.mastodon_minor and patch > self.mastodon_patch:
|
||||
raise MastodonVersionError("Version check failed (Need version " + version + ")")
|
||||
|
@ -1510,9 +1511,9 @@ class Mastodon:
|
|||
# Writing data: Push subscriptions
|
||||
###
|
||||
@api_version("2.4.0", "2.4.0", __DICT_VERSION_PUSH)
|
||||
def push_subscription_set(self, endpoint, encrypt_params, follow_events=False,
|
||||
favourite_events=False, reblog_events=False,
|
||||
mention_events=False):
|
||||
def push_subscription_set(self, endpoint, encrypt_params, follow_events=None,
|
||||
favourite_events=None, reblog_events=None,
|
||||
mention_events=None):
|
||||
"""
|
||||
Sets up or modifies the push subscription the logged-in user has for this app.
|
||||
|
||||
|
@ -1537,24 +1538,24 @@ class Mastodon:
|
|||
'subscription[keys][auth]': push_auth_b64
|
||||
}
|
||||
|
||||
if follow_events == True:
|
||||
params['data[alerts][follow]'] = True
|
||||
if follow_events != None:
|
||||
params['data[alerts][follow]'] = follow_events
|
||||
|
||||
if favourite_events == True:
|
||||
params['data[alerts][favourite]'] = True
|
||||
if favourite_events != None:
|
||||
params['data[alerts][favourite]'] = favourite_events
|
||||
|
||||
if reblog_events == True:
|
||||
params['data[alerts][reblog]'] = True
|
||||
if reblog_events != None:
|
||||
params['data[alerts][reblog]'] = reblog_events
|
||||
|
||||
if mention_events == True:
|
||||
params['data[alerts][mention]'] = True
|
||||
if mention_events != None:
|
||||
params['data[alerts][mention]'] = mention_events
|
||||
|
||||
return self.__api_request('POST', '/api/v1/push/subscription', params)
|
||||
|
||||
@api_version("2.4.0", "2.4.0", __DICT_VERSION_PUSH)
|
||||
def push_subscription_update(self, endpoint, encrypt_params, follow_events=False,
|
||||
favourite_events=False, reblog_events=False,
|
||||
mention_events=False):
|
||||
def push_subscription_update(self, follow_events=None,
|
||||
favourite_events=None, reblog_events=None,
|
||||
mention_events=None):
|
||||
"""
|
||||
Modifies what kind of events the app wishes to subscribe to.
|
||||
|
||||
|
@ -1562,17 +1563,17 @@ class Mastodon:
|
|||
"""
|
||||
params = {}
|
||||
|
||||
if follow_events == True:
|
||||
params['data[alerts][follow]'] = True
|
||||
if follow_events != None:
|
||||
params['data[alerts][follow]'] = follow_events
|
||||
|
||||
if favourite_events == True:
|
||||
params['data[alerts][favourite]'] = True
|
||||
if favourite_events != None:
|
||||
params['data[alerts][favourite]'] = favourite_events
|
||||
|
||||
if reblog_events == True:
|
||||
params['data[alerts][reblog]'] = True
|
||||
if reblog_events != None:
|
||||
params['data[alerts][reblog]'] = reblog_events
|
||||
|
||||
if mention_events == True:
|
||||
params['data[alerts][mention]'] = True
|
||||
if mention_events != None:
|
||||
params['data[alerts][mention]'] = mention_events
|
||||
|
||||
return self.__api_request('PUT', '/api/v1/push/subscription', params)
|
||||
|
||||
|
@ -1797,6 +1798,19 @@ class Mastodon:
|
|||
raise MastodonAPIError('Encountered invalid date.')
|
||||
return json_object
|
||||
|
||||
@staticmethod
|
||||
def __json_truefalse_parse(json_object):
|
||||
"""
|
||||
Parse 'True' / 'False' strings in certain known fields
|
||||
"""
|
||||
for key in ('follow', 'favourite', 'reblog', 'mention'):
|
||||
if (key in json_object and isinstance(json_object[key], six.text_type)):
|
||||
if json_object[key] == 'True':
|
||||
json_object[key] = True
|
||||
if json_object[key] == 'False':
|
||||
json_object[key] = False
|
||||
return json_object
|
||||
|
||||
@staticmethod
|
||||
def __json_strnum_to_bignum(json_object):
|
||||
"""
|
||||
|
@ -1815,6 +1829,7 @@ class Mastodon:
|
|||
def __json_hooks(json_object):
|
||||
json_object = Mastodon.__json_strnum_to_bignum(json_object)
|
||||
json_object = Mastodon.__json_date_parse(json_object)
|
||||
json_object = Mastodon.__json_truefalse_parse(json_object)
|
||||
json_object = Mastodon.__json_allow_dict_attrs(json_object)
|
||||
return json_object
|
||||
|
||||
|
|
1007
tests/cassettes/test_media_update.yaml
Normal file
1007
tests/cassettes/test_media_update.yaml
Normal file
La diferencia del archivo ha sido suprimido porque es demasiado grande
Cargar Diff
88
tests/cassettes/test_push_delete.yaml
Normal file
88
tests/cassettes/test_push_delete.yaml
Normal file
|
@ -0,0 +1,88 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: subscription%5Bendpoint%5D=https%3A%2F%2Fexample.com&subscription%5Bkeys%5D%5Bp256dh%5D=BKf9D9Gl2PhY6ruoL5t03nMUM%2Fgrz%2FV2t7Ulu9jX8j0CFVp4uI05RdCwg3rc%2BZRauRej7WNr25EVZ6Xu36IjxKI%3D&subscription%5Bkeys%5D%5Bauth%5D=4WFT9tyJwbMJcYaGZ5cqLg%3D%3D
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['246']
|
||||
Content-Type: [application/x-www-form-urlencoded]
|
||||
User-Agent: [python-requests/2.9.1]
|
||||
method: POST
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":2,"endpoint":"https://example.com","alerts":{},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"2332b55e95a78e8117bad874f3a6dfe3"]
|
||||
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: [7d00e007-87df-40a0-948b-149825c01b29]
|
||||
X-Runtime: ['0.040019']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['157']
|
||||
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.9.1]
|
||||
method: DELETE
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"ab10e86dced2746251206331ba63dcdc"]
|
||||
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: [034c37de-98b0-443d-af63-d6c9e7245302]
|
||||
X-Runtime: ['0.044571']
|
||||
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.9.1]
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"error":"Record not found"}'}
|
||||
headers:
|
||||
Cache-Control: [no-cache]
|
||||
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: [501bfcc2-0621-440b-bac8-57df49dcab3e]
|
||||
X-Runtime: ['0.019924']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['28']
|
||||
status: {code: 404, message: Not Found}
|
||||
version: 1
|
60
tests/cassettes/test_push_set.yaml
Normal file
60
tests/cassettes/test_push_set.yaml
Normal file
|
@ -0,0 +1,60 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: subscription%5Bkeys%5D%5Bp256dh%5D=BN2C9y4bkh%2F4nE00yBj6MtIhI%2Bs2ZZsV2uDjzmlpNez5Y%2BL72Myw2T1B7wzPr4bnJZTjTuk6QorSXzOKignYviE%3D&subscription%5Bkeys%5D%5Bauth%5D=IRHAwv4FlkgqOeIFAStUFA%3D%3D&subscription%5Bendpoint%5D=https%3A%2F%2Fexample.com
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['246']
|
||||
Content-Type: [application/x-www-form-urlencoded]
|
||||
User-Agent: [python-requests/2.9.1]
|
||||
method: POST
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":9,"endpoint":"https://example.com","alerts":{},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"03197a3e0be5931be8c9e5de50a5decd"]
|
||||
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: [b29b0737-bd98-49b1-b20b-b26ef35b62ac]
|
||||
X-Runtime: ['0.039190']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['157']
|
||||
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.9.1]
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":9,"endpoint":"https://example.com","alerts":{},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"03197a3e0be5931be8c9e5de50a5decd"]
|
||||
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: [75c9bcf7-8ac4-449e-b590-0f728aa475cb]
|
||||
X-Runtime: ['0.020819']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['157']
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
148
tests/cassettes/test_push_update.yaml
Normal file
148
tests/cassettes/test_push_update.yaml
Normal file
|
@ -0,0 +1,148 @@
|
|||
interactions:
|
||||
- request:
|
||||
body: data%5Balerts%5D%5Bfollow%5D=False&data%5Balerts%5D%5Bmention%5D=False&data%5Balerts%5D%5Bfavourite%5D=False&data%5Balerts%5D%5Breblog%5D=False&subscription%5Bkeys%5D%5Bauth%5D=h5Zt2UrWoYKx02aVC5L0%2Fg%3D%3D&subscription%5Bendpoint%5D=https%3A%2F%2Fexample.com&subscription%5Bkeys%5D%5Bp256dh%5D=BJ%2F4Tq2mAxlVXrgepITYrCU%2B%2F0628kF1nX1vzbBUP3s2C%2FiLo9v1%2FMVCgpMLHVuPNG4fRCjgowdx4D9O%2FDSfncY%3D
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['398']
|
||||
Content-Type: [application/x-www-form-urlencoded]
|
||||
User-Agent: [python-requests/2.9.1]
|
||||
method: POST
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":8,"endpoint":"https://example.com","alerts":{"follow":"False","favourite":"False","reblog":"False","mention":"False"},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"b5b71aae730fd5d31b23f14fdd57c42f"]
|
||||
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: [9fada085-29a3-4666-8c07-2021409541bf]
|
||||
X-Runtime: ['0.049096']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['228']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: data%5Balerts%5D%5Bfollow%5D=True&data%5Balerts%5D%5Bmention%5D=True&data%5Balerts%5D%5Bfavourite%5D=True&data%5Balerts%5D%5Breblog%5D=True
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['139']
|
||||
Content-Type: [application/x-www-form-urlencoded]
|
||||
User-Agent: [python-requests/2.9.1]
|
||||
method: PUT
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":8,"endpoint":"https://example.com","alerts":{"follow":"True","favourite":"True","reblog":"True","mention":"True"},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"3fafedf49e495c0eb69b2da4d976d97d"]
|
||||
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: [2f6d8ac9-9650-4ec4-b3fe-79885e3cfc56]
|
||||
X-Runtime: ['0.029778']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['224']
|
||||
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.9.1]
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":8,"endpoint":"https://example.com","alerts":{"follow":"True","favourite":"True","reblog":"True","mention":"True"},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"66ba38489a2226cf55fafd76860b1384"]
|
||||
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: [36c25fd1-46b4-47aa-ada8-c8fe3e5d5a97]
|
||||
X-Runtime: ['0.024214']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['224']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: data%5Balerts%5D%5Bfollow%5D=False&data%5Balerts%5D%5Bmention%5D=False&data%5Balerts%5D%5Bfavourite%5D=False&data%5Balerts%5D%5Breblog%5D=False
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['143']
|
||||
Content-Type: [application/x-www-form-urlencoded]
|
||||
User-Agent: [python-requests/2.9.1]
|
||||
method: PUT
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":8,"endpoint":"https://example.com","alerts":{"follow":"False","favourite":"False","reblog":"False","mention":"False"},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"aaa8530ccca182b42e8f076f1da2f112"]
|
||||
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: [40893dfd-87c5-4886-9938-69e93d0578c6]
|
||||
X-Runtime: ['0.049371']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['228']
|
||||
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.9.1]
|
||||
method: GET
|
||||
uri: http://localhost:3000/api/v1/push/subscription
|
||||
response:
|
||||
body: {string: '{"id":8,"endpoint":"https://example.com","alerts":{"follow":"False","favourite":"False","reblog":"False","mention":"False"},"server_key":"BEFgv48oiSIH0eOGT7FydL1ukygGBCLjUDocQJQABVZuFedxZr3QRjZQQvaVVrtMALGqQj9Skemt34NvshOvhyo="}'}
|
||||
headers:
|
||||
Cache-Control: ['max-age=0, private, must-revalidate']
|
||||
Content-Type: [application/json; charset=utf-8]
|
||||
ETag: [W/"e403993b72df1ff96f98eb99b4e6ff85"]
|
||||
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: [bb02d1ad-37d7-4496-b136-ba085b60a774]
|
||||
X-Runtime: ['0.022633']
|
||||
X-XSS-Protection: [1; mode=block]
|
||||
content-length: ['228']
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.3.0", version_check_mode="created"):
|
||||
def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.4.0", version_check_mode="created"):
|
||||
import mastodon
|
||||
return mastodon.Mastodon(
|
||||
api_base_url='http://localhost:3000',
|
||||
|
|
|
@ -27,6 +27,25 @@ def test_media_post(api, sensitive):
|
|||
finally:
|
||||
api.status_delete(status['id'])
|
||||
|
||||
@pytest.mark.vcr(match_on=['path'])
|
||||
def test_media_update(api):
|
||||
media = api.media_post(
|
||||
'tests/image.jpg',
|
||||
description="John Lennon doing a funny walk",
|
||||
focus=(-0.5, 0.3))
|
||||
|
||||
assert media
|
||||
|
||||
media_up = api.media_update(
|
||||
media,
|
||||
description="John Lennon doing a cool walk",
|
||||
focus=(0.69, 0.69))
|
||||
|
||||
assert media_up
|
||||
assert media_up['description'] == "John Lennon doing a cool walk"
|
||||
assert media_up['meta']['focus']['x'] == 0.69
|
||||
assert media_up['meta']['focus']['y'] == 0.69
|
||||
|
||||
@pytest.mark.vcr(match_on=['path'])
|
||||
def test_media_post_file(api):
|
||||
with open('tests/image.jpg', 'rb') as f:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import pytest
|
||||
import time
|
||||
from mastodon.Mastodon import MastodonNotFoundError
|
||||
|
||||
def test_decrypt(api):
|
||||
priv = {
|
||||
|
@ -20,4 +22,48 @@ def test_decrypt(api):
|
|||
|
||||
assert decrypted
|
||||
assert decrypted.title == 'You were mentioned by fake halcy'
|
||||
|
||||
|
||||
@pytest.mark.vcr(match_on=['path'])
|
||||
def test_push_set(api):
|
||||
priv, pub = api.push_subscription_generate_keys()
|
||||
sub = api.push_subscription_set("example.com", pub)
|
||||
|
||||
assert sub == api.push_subscription()
|
||||
assert sub.endpoint == "https://example.com"
|
||||
|
||||
@pytest.mark.vcr(match_on=['path'])
|
||||
def test_push_update(api):
|
||||
priv, pub = api.push_subscription_generate_keys()
|
||||
sub = api.push_subscription_set("example.com", pub,follow_events=False,
|
||||
favourite_events=False, reblog_events=False,
|
||||
mention_events=False)
|
||||
|
||||
sub2 = api.push_subscription_update(follow_events=True, favourite_events=True,
|
||||
reblog_events=True, mention_events=True)
|
||||
time.sleep(1)
|
||||
assert sub2 == api.push_subscription()
|
||||
|
||||
sub3 = api.push_subscription_update(follow_events=False, favourite_events=False,
|
||||
reblog_events=False, mention_events=False)
|
||||
time.sleep(1)
|
||||
assert sub3 == api.push_subscription()
|
||||
|
||||
assert sub3.alerts.follow == False
|
||||
assert sub3.alerts.favourite == False
|
||||
assert sub3.alerts.reblog == False
|
||||
assert sub3.alerts.mention == False
|
||||
assert sub2.alerts.follow == True
|
||||
assert sub2.alerts.favourite == True
|
||||
assert sub2.alerts.reblog == True
|
||||
assert sub2.alerts.mention == True
|
||||
|
||||
|
||||
@pytest.mark.vcr(match_on=['path'])
|
||||
def test_push_delete(api):
|
||||
priv, pub = api.push_subscription_generate_keys()
|
||||
sub = api.push_subscription_set("example.com", pub)
|
||||
assert sub
|
||||
|
||||
api.push_subscription_delete()
|
||||
with pytest.raises(MastodonNotFoundError):
|
||||
api.push_subscription()
|
Loading…
Referencia en una nova incidència