1
0
Fork 0

Add --json option to update_account

This commit is contained in:
Ivan Habunek 2023-11-22 08:41:15 +01:00
parent e961bd696d
commit 7929919ffc
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
4 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,6 @@
from tests.integration.conftest import TRUMPET
from toot import api
from toot.entities import Account, from_dict
from toot.utils import get_text
@ -16,6 +17,13 @@ def test_update_account_display_name(run, app, user):
assert account["display_name"] == "elwood"
def test_update_account_json(run_json, app, user):
out = run_json("update_account", "--display-name", "elwood", "--json")
account = from_dict(Account, out)
assert account.acct == user.username
assert account.display_name == "elwood"
def test_update_account_note(run, app, user):
note = ("It's 106 miles to Chicago, we got a full tank of gas, half a pack "
"of cigarettes, it's dark... and we're wearing sunglasses.")

View File

@ -340,7 +340,7 @@ def update_account(app, user, args):
if all(option is None for option in options):
raise ConsoleError("Please specify at least one option to update the account")
api.update_account(
response = api.update_account(
app,
user,
avatar=args.avatar,
@ -355,7 +355,10 @@ def update_account(app, user, args):
sensitive=args.sensitive,
)
print_out("<green>✓ Account updated</green>")
if args.json:
print(response.text)
else:
print_out("<green>✓ Account updated</green>")
def login_cli(app, user, args):

View File

@ -370,6 +370,7 @@ AUTH_COMMANDS = [
"type": language,
"help": "Default language to use for authored statuses (ISO 639-1)."
}),
json_arg,
],
require_auth=True,
),

View File

@ -72,6 +72,7 @@ class Account:
statuses_count: int
followers_count: int
following_count: int
source: Optional[dict]
@staticmethod
def __toot_prepare__(obj: Dict) -> Dict: