mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
parent
ef697c3bee
commit
e2d89c2d85
@ -378,9 +378,16 @@ def test_whoami(user, run):
|
||||
assert f"http://{HOSTNAME}/@{user.username}" in out
|
||||
|
||||
|
||||
def test_whois(friend, run):
|
||||
out = run("whois", friend.username)
|
||||
def test_whois(app, friend, run):
|
||||
variants = [
|
||||
friend.username,
|
||||
f"@{friend.username}",
|
||||
f"{friend.username}@{app.instance}",
|
||||
f"@{friend.username}@{app.instance}",
|
||||
]
|
||||
|
||||
for username in variants:
|
||||
out = run("whois", username)
|
||||
assert f"@{friend.username}" in out
|
||||
assert f"http://{HOSTNAME}/@{friend.username}" in out
|
||||
|
||||
|
@ -270,15 +270,20 @@ def _do_upload(app, user, file, description):
|
||||
|
||||
|
||||
def _find_account(app, user, account_name):
|
||||
"""For a given account name, returns the Account object.
|
||||
|
||||
Raises an exception if not found.
|
||||
"""
|
||||
if not account_name:
|
||||
raise ConsoleError("Empty account name given")
|
||||
|
||||
normalized_name = account_name.lstrip("@").lower()
|
||||
|
||||
# Strip @<instance_name> from accounts on the local instance. The `acct`
|
||||
# field in account object contains the qualified name for users of other
|
||||
# instances, but only the username for users of the local instance. This is
|
||||
# required in order to match the account name below.
|
||||
if "@" in normalized_name:
|
||||
[username, instance] = normalized_name.split("@", maxsplit=1)
|
||||
if instance == app.instance:
|
||||
normalized_name = username
|
||||
|
||||
response = api.search(app, user, account_name, type="accounts", resolve=True)
|
||||
for account in response["accounts"]:
|
||||
if account["acct"].lower() == normalized_name:
|
||||
|
Loading…
Reference in New Issue
Block a user