parent
025d8dde09
commit
72f88831ad
5 changed files with 46 additions and 0 deletions
|
@ -107,6 +107,17 @@ def test_post_invalid_media(capsys):
|
|||
assert "can't open 'does_not_exist.jpg'" in err
|
||||
|
||||
|
||||
@mock.patch('toot.http.delete')
|
||||
def test_delete(mock_delete, capsys):
|
||||
console.run_command(app, user, 'delete', ['12321'])
|
||||
|
||||
mock_delete.assert_called_once_with(app, user, '/api/v1/statuses/12321')
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
assert 'Status deleted' in out
|
||||
assert not err
|
||||
|
||||
|
||||
@mock.patch('toot.http.get')
|
||||
def test_timeline(mock_get, monkeypatch, capsys):
|
||||
mock_get.return_value = MockResponse([{
|
||||
|
|
|
@ -106,6 +106,14 @@ def post_status(
|
|||
}, headers=headers).json()
|
||||
|
||||
|
||||
def delete_status(app, user, status_id):
|
||||
"""
|
||||
Deletes a status with given ID.
|
||||
https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#deleting-a-status
|
||||
"""
|
||||
return http.delete(app, user, '/api/v1/statuses/{}'.format(status_id))
|
||||
|
||||
|
||||
def timeline_home(app, user):
|
||||
return http.get(app, user, '/api/v1/timelines/home').json()
|
||||
|
||||
|
|
|
@ -68,6 +68,12 @@ def post(app, user, args):
|
|||
print_out("Toot posted: <green>{}</green>".format(response.get('url')))
|
||||
|
||||
|
||||
def delete(app, user, args):
|
||||
api.delete_status(app, user, args.status_id)
|
||||
|
||||
print_out("<green>✓ Status deleted</green>")
|
||||
|
||||
|
||||
def auth(app, user, args):
|
||||
config_data = config.load_config()
|
||||
|
||||
|
|
|
@ -217,6 +217,17 @@ POST_COMMANDS = [
|
|||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="delete",
|
||||
description="Delete an existing status",
|
||||
arguments=[
|
||||
(["status_id"], {
|
||||
"help": "ID of the status to delete",
|
||||
"type": int,
|
||||
})
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
||||
ACCOUNTS_COMMANDS = [
|
||||
|
|
10
toot/http.py
10
toot/http.py
|
@ -69,6 +69,16 @@ def post(app, user, url, data=None, files=None, allow_redirects=True, headers={}
|
|||
return process_response(response)
|
||||
|
||||
|
||||
def delete(app, user, url, data=None):
|
||||
url = app.base_url + url
|
||||
headers = {"Authorization": "Bearer " + user.access_token}
|
||||
|
||||
request = Request('DELETE', url, headers=headers, data=data)
|
||||
response = send_request(request)
|
||||
|
||||
return process_response(response)
|
||||
|
||||
|
||||
def anon_post(url, data=None, files=None, allow_redirects=True):
|
||||
request = Request('POST', url, {}, files, data)
|
||||
response = send_request(request, allow_redirects)
|
||||
|
|
Loading…
Reference in a new issue