Added undoing favourite and boost
Build and Release / run-terraform (push) Successful in 42s
Details
Build and Release / run-terraform (push) Successful in 42s
Details
This commit is contained in:
parent
d8b0f7c808
commit
8512157c9a
|
@ -19,6 +19,19 @@ class Statuses():
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Server returned {} {}".format(response.status_code, response.content))
|
raise RuntimeError("Server returned {} {}".format(response.status_code, response.content))
|
||||||
|
|
||||||
|
def unfavourite(self, status_id):
|
||||||
|
server = self.config.get_value("server")
|
||||||
|
url = f"https://{server}/api/v1/statuses/{status_id}/unfavourite"
|
||||||
|
|
||||||
|
response = requests.post(url, headers=self.auth.get_auth_headers())
|
||||||
|
|
||||||
|
logger.trace("JSON: {}".format(str(response.content)))
|
||||||
|
if response.status_code == 200:
|
||||||
|
return response.json()
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Server returned {} {}".format(response.status_code, response.content))
|
||||||
|
|
||||||
|
|
||||||
def reblog(self, status_id):
|
def reblog(self, status_id):
|
||||||
server = self.config.get_value("server")
|
server = self.config.get_value("server")
|
||||||
url = f"https://{server}/api/v1/statuses/{status_id}/reblog"
|
url = f"https://{server}/api/v1/statuses/{status_id}/reblog"
|
||||||
|
@ -30,3 +43,15 @@ class Statuses():
|
||||||
return response.json()
|
return response.json()
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Server returned {} {}".format(response.status_code, response.content))
|
raise RuntimeError("Server returned {} {}".format(response.status_code, response.content))
|
||||||
|
|
||||||
|
def unreblog(self, status_id):
|
||||||
|
server = self.config.get_value("server")
|
||||||
|
url = f"https://{server}/api/v1/statuses/{status_id}/unreblog"
|
||||||
|
|
||||||
|
response = requests.post(url, headers=self.auth.get_auth_headers())
|
||||||
|
|
||||||
|
logger.trace("JSON: {}".format(str(response.content)))
|
||||||
|
if response.status_code == 200:
|
||||||
|
return response.json()
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Server returned {} {}".format(response.status_code, response.content))
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
{
|
||||||
|
"id": "103270115826048975",
|
||||||
|
"created_at": "2019-12-08T03:48:33.901Z",
|
||||||
|
"in_reply_to_id": null,
|
||||||
|
"in_reply_to_account_id": null,
|
||||||
|
"sensitive": false,
|
||||||
|
"spoiler_text": "",
|
||||||
|
"visibility": "public",
|
||||||
|
"language": "en",
|
||||||
|
"uri": "https://mastodon.social/users/Gargron/statuses/103270115826048975",
|
||||||
|
"url": "https://mastodon.social/@Gargron/103270115826048975",
|
||||||
|
"replies_count": 5,
|
||||||
|
"reblogs_count": 6,
|
||||||
|
"favourites_count": 11,
|
||||||
|
"favourited": false,
|
||||||
|
"reblogged": false,
|
||||||
|
"muted": false,
|
||||||
|
"bookmarked": false,
|
||||||
|
"content": "<p>"I lost my inheritance with one wrong digit on my sort code"</p><p><a href=\"https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">theguardian.com/money/2019/dec</span><span class=\"invisible\">/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code</span}</p>",
|
||||||
|
"reblog": null,
|
||||||
|
"application": {
|
||||||
|
"name": "Web",
|
||||||
|
"website": null
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"id": "1",
|
||||||
|
"username": "Gargron",
|
||||||
|
"acct": "Gargron",
|
||||||
|
"display_name": "Eugen",
|
||||||
|
"locked": false,
|
||||||
|
"bot": false,
|
||||||
|
"discoverable": true,
|
||||||
|
"group": false,
|
||||||
|
"created_at": "2016-03-16T14:34:26.392Z",
|
||||||
|
"note": "<p>Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.</p>",
|
||||||
|
"url": "https://mastodon.social/@Gargron",
|
||||||
|
"avatar": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg",
|
||||||
|
"avatar_static": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg",
|
||||||
|
"header": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png",
|
||||||
|
"header_static": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png",
|
||||||
|
"followers_count": 322930,
|
||||||
|
"following_count": 459,
|
||||||
|
"statuses_count": 61323,
|
||||||
|
"last_status_at": "2019-12-10T08:14:44.811Z",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "Patreon",
|
||||||
|
"value": "<a href=\"https://www.patreon.com/mastodon\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"\">patreon.com/mastodon</span><span class=\"invisible\"></span}",
|
||||||
|
"verified_at": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Homepage",
|
||||||
|
"value": "<a href=\"https://zeonfederated.com\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">zeonfederated.com</span><span class=\"invisible\"></span}",
|
||||||
|
"verified_at": "2019-07-15T18:29:57.191+00:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"media_attachments": [{
|
||||||
|
"id": "22345792",
|
||||||
|
"type": "image",
|
||||||
|
"url": "https://files.mastodon.social/media_attachments/files/022/345/792/original/57859aede991da25.jpeg",
|
||||||
|
"preview_url": "https://files.mastodon.social/media_attachments/files/022/345/792/small/57859aede991da25.jpeg",
|
||||||
|
"remote_url": null,
|
||||||
|
"text_url": "https://mastodon.social/media/2N4uvkuUtPVrkZGysms",
|
||||||
|
"meta": {
|
||||||
|
"original": {
|
||||||
|
"width": 640,
|
||||||
|
"height": 480,
|
||||||
|
"size": "640x480",
|
||||||
|
"aspect": 1.3333333333333333
|
||||||
|
},
|
||||||
|
"small": {
|
||||||
|
"width": 461,
|
||||||
|
"height": 346,
|
||||||
|
"size": "461x346",
|
||||||
|
"aspect": 1.3323699421965318
|
||||||
|
},
|
||||||
|
"focus": {
|
||||||
|
"x": -0.27,
|
||||||
|
"y": 0.51
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "test media description",
|
||||||
|
"blurhash": "UFBWY:8_0Jxv4mx]t8t64.%M-:IUWGWAt6M}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "22546306",
|
||||||
|
"type": "video",
|
||||||
|
"url": "https://files.mastodon.social/media_attachments/files/022/546/306/original/dab9a597f68b9745.mp4",
|
||||||
|
"preview_url": "https://files.mastodon.social/media_attachments/files/022/546/306/small/dab9a597f68b9745.png",
|
||||||
|
"remote_url": null,
|
||||||
|
"text_url": "https://mastodon.social/media/wWd1HJIBmH1MZGDfg50",
|
||||||
|
"meta": {
|
||||||
|
"length": "0:01:28.65",
|
||||||
|
"duration": 88.65,
|
||||||
|
"fps": 24,
|
||||||
|
"size": "1280x720",
|
||||||
|
"width": 1280,
|
||||||
|
"height": 720,
|
||||||
|
"aspect": 1.7777777777777777,
|
||||||
|
"audio_encode": "aac (LC) (mp4a / 0x6134706D)",
|
||||||
|
"audio_bitrate": "44100 Hz",
|
||||||
|
"audio_channels": "stereo",
|
||||||
|
"original": {
|
||||||
|
"width": 1280,
|
||||||
|
"height": 720,
|
||||||
|
"frame_rate": "6159375/249269",
|
||||||
|
"duration": 88.654,
|
||||||
|
"bitrate": 862056
|
||||||
|
},
|
||||||
|
"small": {
|
||||||
|
"width": 400,
|
||||||
|
"height": 225,
|
||||||
|
"size": "400x225",
|
||||||
|
"aspect": 1.7777777777777777
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": null,
|
||||||
|
"blurhash": "U58E0g8_0M.94T?bIr00?bD%NGoM?bD%oLt7"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mentions": [],
|
||||||
|
"tags": [],
|
||||||
|
"emojis": [],
|
||||||
|
"card": {
|
||||||
|
"url": "https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code",
|
||||||
|
"title": "‘I lost my £193,000 inheritance – with one wrong digit on my sort code’",
|
||||||
|
"description": "When Peter Teich’s money went to another Barclays customer, the bank offered £25 as a token gesture",
|
||||||
|
"type": "link",
|
||||||
|
"author_name": "",
|
||||||
|
"author_url": "",
|
||||||
|
"provider_name": "",
|
||||||
|
"provider_url": "",
|
||||||
|
"html": "",
|
||||||
|
"width": 0,
|
||||||
|
"height": 0,
|
||||||
|
"image": null,
|
||||||
|
"embed_url": ""
|
||||||
|
},
|
||||||
|
"poll": null
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
{
|
||||||
|
"id": "103270115826048975",
|
||||||
|
"created_at": "2019-12-08T03:48:33.901Z",
|
||||||
|
"in_reply_to_id": null,
|
||||||
|
"in_reply_to_account_id": null,
|
||||||
|
"sensitive": false,
|
||||||
|
"spoiler_text": "",
|
||||||
|
"visibility": "public",
|
||||||
|
"language": "en",
|
||||||
|
"uri": "https://mastodon.social/users/Gargron/statuses/103270115826048975",
|
||||||
|
"url": "https://mastodon.social/@Gargron/103270115826048975",
|
||||||
|
"replies_count": 5,
|
||||||
|
"reblogs_count": 6,
|
||||||
|
"favourites_count": 11,
|
||||||
|
"favourited": false,
|
||||||
|
"reblogged": false,
|
||||||
|
"muted": false,
|
||||||
|
"bookmarked": false,
|
||||||
|
"content": "<p>"I lost my inheritance with one wrong digit on my sort code"</p><p><a href=\"https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">theguardian.com/money/2019/dec</span><span class=\"invisible\">/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code</span}</p>",
|
||||||
|
"reblog": null,
|
||||||
|
"application": {
|
||||||
|
"name": "Web",
|
||||||
|
"website": null
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"id": "1",
|
||||||
|
"username": "Gargron",
|
||||||
|
"acct": "Gargron",
|
||||||
|
"display_name": "Eugen",
|
||||||
|
"locked": false,
|
||||||
|
"bot": false,
|
||||||
|
"discoverable": true,
|
||||||
|
"group": false,
|
||||||
|
"created_at": "2016-03-16T14:34:26.392Z",
|
||||||
|
"note": "<p>Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.</p>",
|
||||||
|
"url": "https://mastodon.social/@Gargron",
|
||||||
|
"avatar": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg",
|
||||||
|
"avatar_static": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg",
|
||||||
|
"header": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png",
|
||||||
|
"header_static": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png",
|
||||||
|
"followers_count": 322930,
|
||||||
|
"following_count": 459,
|
||||||
|
"statuses_count": 61323,
|
||||||
|
"last_status_at": "2019-12-10T08:14:44.811Z",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "Patreon",
|
||||||
|
"value": "<a href=\"https://www.patreon.com/mastodon\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"\">patreon.com/mastodon</span><span class=\"invisible\"></span}",
|
||||||
|
"verified_at": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Homepage",
|
||||||
|
"value": "<a href=\"https://zeonfederated.com\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">zeonfederated.com</span><span class=\"invisible\"></span}",
|
||||||
|
"verified_at": "2019-07-15T18:29:57.191+00:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"media_attachments": [{
|
||||||
|
"id": "22345792",
|
||||||
|
"type": "image",
|
||||||
|
"url": "https://files.mastodon.social/media_attachments/files/022/345/792/original/57859aede991da25.jpeg",
|
||||||
|
"preview_url": "https://files.mastodon.social/media_attachments/files/022/345/792/small/57859aede991da25.jpeg",
|
||||||
|
"remote_url": null,
|
||||||
|
"text_url": "https://mastodon.social/media/2N4uvkuUtPVrkZGysms",
|
||||||
|
"meta": {
|
||||||
|
"original": {
|
||||||
|
"width": 640,
|
||||||
|
"height": 480,
|
||||||
|
"size": "640x480",
|
||||||
|
"aspect": 1.3333333333333333
|
||||||
|
},
|
||||||
|
"small": {
|
||||||
|
"width": 461,
|
||||||
|
"height": 346,
|
||||||
|
"size": "461x346",
|
||||||
|
"aspect": 1.3323699421965318
|
||||||
|
},
|
||||||
|
"focus": {
|
||||||
|
"x": -0.27,
|
||||||
|
"y": 0.51
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "test media description",
|
||||||
|
"blurhash": "UFBWY:8_0Jxv4mx]t8t64.%M-:IUWGWAt6M}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "22546306",
|
||||||
|
"type": "video",
|
||||||
|
"url": "https://files.mastodon.social/media_attachments/files/022/546/306/original/dab9a597f68b9745.mp4",
|
||||||
|
"preview_url": "https://files.mastodon.social/media_attachments/files/022/546/306/small/dab9a597f68b9745.png",
|
||||||
|
"remote_url": null,
|
||||||
|
"text_url": "https://mastodon.social/media/wWd1HJIBmH1MZGDfg50",
|
||||||
|
"meta": {
|
||||||
|
"length": "0:01:28.65",
|
||||||
|
"duration": 88.65,
|
||||||
|
"fps": 24,
|
||||||
|
"size": "1280x720",
|
||||||
|
"width": 1280,
|
||||||
|
"height": 720,
|
||||||
|
"aspect": 1.7777777777777777,
|
||||||
|
"audio_encode": "aac (LC) (mp4a / 0x6134706D)",
|
||||||
|
"audio_bitrate": "44100 Hz",
|
||||||
|
"audio_channels": "stereo",
|
||||||
|
"original": {
|
||||||
|
"width": 1280,
|
||||||
|
"height": 720,
|
||||||
|
"frame_rate": "6159375/249269",
|
||||||
|
"duration": 88.654,
|
||||||
|
"bitrate": 862056
|
||||||
|
},
|
||||||
|
"small": {
|
||||||
|
"width": 400,
|
||||||
|
"height": 225,
|
||||||
|
"size": "400x225",
|
||||||
|
"aspect": 1.7777777777777777
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": null,
|
||||||
|
"blurhash": "U58E0g8_0M.94T?bIr00?bD%NGoM?bD%oLt7"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mentions": [],
|
||||||
|
"tags": [],
|
||||||
|
"emojis": [],
|
||||||
|
"card": {
|
||||||
|
"url": "https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code",
|
||||||
|
"title": "‘I lost my £193,000 inheritance – with one wrong digit on my sort code’",
|
||||||
|
"description": "When Peter Teich’s money went to another Barclays customer, the bank offered £25 as a token gesture",
|
||||||
|
"type": "link",
|
||||||
|
"author_name": "",
|
||||||
|
"author_url": "",
|
||||||
|
"provider_name": "",
|
||||||
|
"provider_url": "",
|
||||||
|
"html": "",
|
||||||
|
"width": 0,
|
||||||
|
"height": 0,
|
||||||
|
"image": null,
|
||||||
|
"embed_url": ""
|
||||||
|
},
|
||||||
|
"poll": null
|
||||||
|
}
|
|
@ -24,6 +24,19 @@ def test_favourite(app):
|
||||||
logger.debug(response)
|
logger.debug(response)
|
||||||
logger.error(ve)
|
logger.error(ve)
|
||||||
|
|
||||||
|
@responses.activate
|
||||||
|
def test_favourite(app):
|
||||||
|
responses.post("https://social.example.com/api/v1/statuses/1234/unfavourite", json=json_reader("./tests/resources/unfavourite_response.json"))
|
||||||
|
response = app.statuses.unfavourite("1234")
|
||||||
|
assert response is not None
|
||||||
|
try:
|
||||||
|
status = Status.model_validate(response)
|
||||||
|
assert status.favourited == False
|
||||||
|
except Exception as ve:
|
||||||
|
logger.debug(response)
|
||||||
|
logger.error(ve)
|
||||||
|
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_reblog(app):
|
def test_reblog(app):
|
||||||
responses.post("https://social.example.com/api/v1/statuses/1234/reblog", json=json_reader("./tests/resources/reblog_response.json"))
|
responses.post("https://social.example.com/api/v1/statuses/1234/reblog", json=json_reader("./tests/resources/reblog_response.json"))
|
||||||
|
@ -36,7 +49,19 @@ def test_reblog(app):
|
||||||
logger.debug(response)
|
logger.debug(response)
|
||||||
logger.error(ve)
|
logger.error(ve)
|
||||||
|
|
||||||
|
@responses.activate
|
||||||
|
def test_unreblog(app):
|
||||||
|
responses.post("https://social.example.com/api/v1/statuses/1234/unreblog", json=json_reader("./tests/resources/unreblog_response.json"))
|
||||||
|
response = app.statuses.unreblog("1234")
|
||||||
|
assert response is not None
|
||||||
|
try:
|
||||||
|
status = Status.model_validate(response)
|
||||||
|
assert status.reblogged == False
|
||||||
|
except Exception as ve:
|
||||||
|
logger.debug(response)
|
||||||
|
logger.error(ve)
|
||||||
|
|
||||||
def json_reader(path):
|
def json_reader(path):
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue