mirror of
https://github.com/ihabunek/toot.git
synced 2025-06-30 22:18:36 -04:00
parent
ef697c3bee
commit
e2d89c2d85
@ -378,11 +378,18 @@ def test_whoami(user, run):
|
|||||||
assert f"http://{HOSTNAME}/@{user.username}" in out
|
assert f"http://{HOSTNAME}/@{user.username}" in out
|
||||||
|
|
||||||
|
|
||||||
def test_whois(friend, run):
|
def test_whois(app, friend, run):
|
||||||
out = run("whois", friend.username)
|
variants = [
|
||||||
|
friend.username,
|
||||||
|
f"@{friend.username}",
|
||||||
|
f"{friend.username}@{app.instance}",
|
||||||
|
f"@{friend.username}@{app.instance}",
|
||||||
|
]
|
||||||
|
|
||||||
assert f"@{friend.username}" in out
|
for username in variants:
|
||||||
assert f"http://{HOSTNAME}/@{friend.username}" in out
|
out = run("whois", username)
|
||||||
|
assert f"@{friend.username}" in out
|
||||||
|
assert f"http://{HOSTNAME}/@{friend.username}" in out
|
||||||
|
|
||||||
|
|
||||||
def test_search_account(friend, run):
|
def test_search_account(friend, run):
|
||||||
|
@ -270,15 +270,20 @@ def _do_upload(app, user, file, description):
|
|||||||
|
|
||||||
|
|
||||||
def _find_account(app, user, account_name):
|
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:
|
if not account_name:
|
||||||
raise ConsoleError("Empty account name given")
|
raise ConsoleError("Empty account name given")
|
||||||
|
|
||||||
normalized_name = account_name.lstrip("@").lower()
|
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)
|
response = api.search(app, user, account_name, type="accounts", resolve=True)
|
||||||
for account in response["accounts"]:
|
for account in response["accounts"]:
|
||||||
if account["acct"].lower() == normalized_name:
|
if account["acct"].lower() == normalized_name:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user