Skip to content

Commit

Permalink
Add --json option to update_account
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Nov 22, 2023
1 parent e961bd6 commit 7929919
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/integration/test_auth.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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.")
Expand Down
7 changes: 5 additions & 2 deletions toot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions toot/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def editor(value):
"type": language,
"help": "Default language to use for authored statuses (ISO 639-1)."
}),
json_arg,
],
require_auth=True,
),
Expand Down
1 change: 1 addition & 0 deletions toot/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7929919

Please sign in to comment.