mirror of
https://github.com/ihabunek/toot.git
synced 2025-02-02 15:07:51 -05:00
Reorganize cli imports
The old way did not allow for having multiple commands of the same name
This commit is contained in:
parent
120545865b
commit
fab23b9069
@ -5,7 +5,7 @@ from toot.entities import Account, Relationship, from_dict
|
||||
|
||||
|
||||
def test_whoami(user: User, run):
|
||||
result = run(cli.whoami)
|
||||
result = run(cli.read.whoami)
|
||||
assert result.exit_code == 0
|
||||
|
||||
# TODO: test other fields once updating account is supported
|
||||
@ -14,7 +14,7 @@ def test_whoami(user: User, run):
|
||||
|
||||
|
||||
def test_whoami_json(user: User, run):
|
||||
result = run(cli.whoami, "--json")
|
||||
result = run(cli.read.whoami, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
account = from_dict(Account, json.loads(result.stdout))
|
||||
@ -30,7 +30,7 @@ def test_whois(app: App, friend: User, run):
|
||||
]
|
||||
|
||||
for username in variants:
|
||||
result = run(cli.whois, username)
|
||||
result = run(cli.read.whois, username)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{friend.username}" in result.stdout
|
||||
|
||||
@ -39,35 +39,35 @@ def test_following(app: App, user: User, friend: User, friend_id, run):
|
||||
# Make sure we're not initally following friend
|
||||
api.unfollow(app, user, friend_id)
|
||||
|
||||
result = run(cli.following, user.username)
|
||||
result = run(cli.accounts.following, user.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == ""
|
||||
|
||||
result = run(cli.follow, friend.username)
|
||||
result = run(cli.accounts.follow, friend.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f"✓ You are now following {friend.username}"
|
||||
|
||||
result = run(cli.following, user.username)
|
||||
result = run(cli.accounts.following, user.username)
|
||||
assert result.exit_code == 0
|
||||
assert friend.username in result.stdout.strip()
|
||||
|
||||
# If no account is given defaults to logged in user
|
||||
result = run(cli.following)
|
||||
result = run(cli.accounts.following)
|
||||
assert result.exit_code == 0
|
||||
assert friend.username in result.stdout.strip()
|
||||
|
||||
result = run(cli.unfollow, friend.username)
|
||||
result = run(cli.accounts.unfollow, friend.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f"✓ You are no longer following {friend.username}"
|
||||
|
||||
result = run(cli.following, user.username)
|
||||
result = run(cli.accounts.following, user.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == ""
|
||||
|
||||
|
||||
def test_following_case_insensitive(user: User, friend: User, run):
|
||||
assert friend.username != friend.username.upper()
|
||||
result = run(cli.follow, friend.username.upper())
|
||||
result = run(cli.accounts.follow, friend.username.upper())
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
@ -75,11 +75,11 @@ def test_following_case_insensitive(user: User, friend: User, run):
|
||||
|
||||
|
||||
def test_following_not_found(run):
|
||||
result = run(cli.follow, "bananaman")
|
||||
result = run(cli.accounts.follow, "bananaman")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Account not found"
|
||||
|
||||
result = run(cli.unfollow, "bananaman")
|
||||
result = run(cli.accounts.unfollow, "bananaman")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Account not found"
|
||||
|
||||
@ -88,37 +88,37 @@ def test_following_json(app: App, user: User, friend: User, user_id, friend_id,
|
||||
# Make sure we're not initally following friend
|
||||
api.unfollow(app, user, friend_id)
|
||||
|
||||
result = run_json(cli.following, user.username, "--json")
|
||||
result = run_json(cli.accounts.following, user.username, "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.followers, friend.username, "--json")
|
||||
result = run_json(cli.accounts.followers, friend.username, "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.follow, friend.username, "--json")
|
||||
result = run_json(cli.accounts.follow, friend.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
assert relationship.following is True
|
||||
|
||||
[result] = run_json(cli.following, user.username, "--json")
|
||||
[result] = run_json(cli.accounts.following, user.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
|
||||
# If no account is given defaults to logged in user
|
||||
[result] = run_json(cli.following, user.username, "--json")
|
||||
[result] = run_json(cli.accounts.following, user.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
|
||||
[result] = run_json(cli.followers, friend.username, "--json")
|
||||
[result] = run_json(cli.accounts.followers, friend.username, "--json")
|
||||
assert result["id"] == user_id
|
||||
|
||||
result = run_json(cli.unfollow, friend.username, "--json")
|
||||
result = run_json(cli.accounts.unfollow, friend.username, "--json")
|
||||
assert result["id"] == friend_id
|
||||
assert result["following"] is False
|
||||
|
||||
result = run_json(cli.following, user.username, "--json")
|
||||
result = run_json(cli.accounts.following, user.username, "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.followers, friend.username, "--json")
|
||||
result = run_json(cli.accounts.followers, friend.username, "--json")
|
||||
assert result == []
|
||||
|
||||
|
||||
@ -126,31 +126,31 @@ def test_mute(app, user, friend, friend_id, run):
|
||||
# Make sure we're not initially muting friend
|
||||
api.unmute(app, user, friend_id)
|
||||
|
||||
result = run(cli.muted)
|
||||
result = run(cli.accounts.muted)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert out == "No accounts muted"
|
||||
|
||||
result = run(cli.mute, friend.username)
|
||||
result = run(cli.accounts.mute, friend.username)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert out == f"✓ You have muted {friend.username}"
|
||||
|
||||
result = run(cli.muted)
|
||||
result = run(cli.accounts.muted)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert friend.username in out
|
||||
|
||||
result = run(cli.unmute, friend.username)
|
||||
result = run(cli.accounts.unmute, friend.username)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert out == f"✓ {friend.username} is no longer muted"
|
||||
|
||||
result = run(cli.muted)
|
||||
result = run(cli.accounts.muted)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
@ -158,7 +158,7 @@ def test_mute(app, user, friend, friend_id, run):
|
||||
|
||||
|
||||
def test_mute_case_insensitive(friend: User, run):
|
||||
result = run(cli.mute, friend.username.upper())
|
||||
result = run(cli.accounts.mute, friend.username.upper())
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
@ -166,11 +166,11 @@ def test_mute_case_insensitive(friend: User, run):
|
||||
|
||||
|
||||
def test_mute_not_found(run):
|
||||
result = run(cli.mute, "doesnotexistperson")
|
||||
result = run(cli.accounts.mute, "doesnotexistperson")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Account not found"
|
||||
|
||||
result = run(cli.unmute, "doesnotexistperson")
|
||||
result = run(cli.accounts.unmute, "doesnotexistperson")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Account not found"
|
||||
|
||||
@ -179,24 +179,24 @@ def test_mute_json(app: App, user: User, friend: User, run_json, friend_id):
|
||||
# Make sure we're not initially muting friend
|
||||
api.unmute(app, user, friend_id)
|
||||
|
||||
result = run_json(cli.muted, "--json")
|
||||
result = run_json(cli.accounts.muted, "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.mute, friend.username, "--json")
|
||||
result = run_json(cli.accounts.mute, friend.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
assert relationship.muting is True
|
||||
|
||||
[result] = run_json(cli.muted, "--json")
|
||||
[result] = run_json(cli.accounts.muted, "--json")
|
||||
account = from_dict(Account, result)
|
||||
assert account.id == friend_id
|
||||
|
||||
result = run_json(cli.unmute, friend.username, "--json")
|
||||
result = run_json(cli.accounts.unmute, friend.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
assert relationship.muting is False
|
||||
|
||||
result = run_json(cli.muted, "--json")
|
||||
result = run_json(cli.accounts.muted, "--json")
|
||||
assert result == []
|
||||
|
||||
|
||||
@ -204,31 +204,31 @@ def test_block(app, user, friend, friend_id, run):
|
||||
# Make sure we're not initially blocking friend
|
||||
api.unblock(app, user, friend_id)
|
||||
|
||||
result = run(cli.blocked)
|
||||
result = run(cli.accounts.blocked)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert out == "No accounts blocked"
|
||||
|
||||
result = run(cli.block, friend.username)
|
||||
result = run(cli.accounts.block, friend.username)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert out == f"✓ You are now blocking {friend.username}"
|
||||
|
||||
result = run(cli.blocked)
|
||||
result = run(cli.accounts.blocked)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert friend.username in out
|
||||
|
||||
result = run(cli.unblock, friend.username)
|
||||
result = run(cli.accounts.unblock, friend.username)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
assert out == f"✓ {friend.username} is no longer blocked"
|
||||
|
||||
result = run(cli.blocked)
|
||||
result = run(cli.accounts.blocked)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
@ -236,7 +236,7 @@ def test_block(app, user, friend, friend_id, run):
|
||||
|
||||
|
||||
def test_block_case_insensitive(friend: User, run):
|
||||
result = run(cli.block, friend.username.upper())
|
||||
result = run(cli.accounts.block, friend.username.upper())
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
@ -244,7 +244,7 @@ def test_block_case_insensitive(friend: User, run):
|
||||
|
||||
|
||||
def test_block_not_found(run):
|
||||
result = run(cli.block, "doesnotexistperson")
|
||||
result = run(cli.accounts.block, "doesnotexistperson")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Account not found"
|
||||
|
||||
@ -253,22 +253,22 @@ def test_block_json(app: App, user: User, friend: User, run_json, friend_id):
|
||||
# Make sure we're not initially blocking friend
|
||||
api.unblock(app, user, friend_id)
|
||||
|
||||
result = run_json(cli.blocked, "--json")
|
||||
result = run_json(cli.accounts.blocked, "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.block, friend.username, "--json")
|
||||
result = run_json(cli.accounts.block, friend.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
assert relationship.blocking is True
|
||||
|
||||
[result] = run_json(cli.blocked, "--json")
|
||||
[result] = run_json(cli.accounts.blocked, "--json")
|
||||
account = from_dict(Account, result)
|
||||
assert account.id == friend_id
|
||||
|
||||
result = run_json(cli.unblock, friend.username, "--json")
|
||||
result = run_json(cli.accounts.unblock, friend.username, "--json")
|
||||
relationship = from_dict(Relationship, result)
|
||||
assert relationship.id == friend_id
|
||||
assert relationship.blocking is False
|
||||
|
||||
result = run_json(cli.blocked, "--json")
|
||||
result = run_json(cli.accounts.blocked, "--json")
|
||||
assert result == []
|
||||
|
@ -46,7 +46,7 @@ SAMPLE_CONFIG = {
|
||||
|
||||
|
||||
def test_env(run: Run):
|
||||
result = run(cli.env)
|
||||
result = run(cli.auth.env)
|
||||
assert result.exit_code == 0
|
||||
assert "toot" in result.stdout
|
||||
assert "Python" in result.stdout
|
||||
@ -55,7 +55,7 @@ def test_env(run: Run):
|
||||
@mock.patch("toot.config.load_config")
|
||||
def test_auth_empty(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = EMPTY_CONFIG
|
||||
result = run(cli.auth)
|
||||
result = run(cli.auth.auth)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You are not logged in to any accounts"
|
||||
|
||||
@ -63,7 +63,7 @@ def test_auth_empty(load_config: MagicMock, run: Run):
|
||||
@mock.patch("toot.config.load_config")
|
||||
def test_auth_full(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
result = run(cli.auth)
|
||||
result = run(cli.auth.auth)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip().startswith("Authenticated accounts:")
|
||||
assert "frank@foo.social" in result.stdout
|
||||
@ -86,7 +86,7 @@ def test_login_cli(
|
||||
load_app.return_value = None
|
||||
|
||||
result = run(
|
||||
cli.login_cli,
|
||||
cli.auth.login_cli,
|
||||
"--instance", "http://localhost:3000",
|
||||
"--email", f"{user.username}@example.com",
|
||||
"--password", "password",
|
||||
@ -123,7 +123,7 @@ def test_login_cli_wrong_password(
|
||||
load_app.return_value = None
|
||||
|
||||
result = run(
|
||||
cli.login_cli,
|
||||
cli.auth.login_cli,
|
||||
"--instance", "http://localhost:3000",
|
||||
"--email", f"{user.username}@example.com",
|
||||
"--password", "wrong password",
|
||||
@ -146,7 +146,7 @@ def test_login_cli_wrong_password(
|
||||
def test_logout(delete_user: MagicMock, load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
|
||||
result = run(cli.logout, "frank@foo.social")
|
||||
result = run(cli.auth.logout, "frank@foo.social")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account frank@foo.social logged out"
|
||||
delete_user.assert_called_once_with(User("foo.social", "frank", "123"))
|
||||
@ -156,7 +156,7 @@ def test_logout(delete_user: MagicMock, load_config: MagicMock, run: Run):
|
||||
def test_logout_not_logged_in(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = EMPTY_CONFIG
|
||||
|
||||
result = run(cli.logout)
|
||||
result = run(cli.auth.logout)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: You're not logged into any accounts"
|
||||
|
||||
@ -165,7 +165,7 @@ def test_logout_not_logged_in(load_config: MagicMock, run: Run):
|
||||
def test_logout_account_not_specified(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
|
||||
result = run(cli.logout)
|
||||
result = run(cli.auth.logout)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.startswith("Error: Specify account to log out")
|
||||
|
||||
@ -174,7 +174,7 @@ def test_logout_account_not_specified(load_config: MagicMock, run: Run):
|
||||
def test_logout_account_does_not_exist(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
|
||||
result = run(cli.logout, "banana")
|
||||
result = run(cli.auth.logout, "banana")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.startswith("Error: Account not found")
|
||||
|
||||
@ -184,7 +184,7 @@ def test_logout_account_does_not_exist(load_config: MagicMock, run: Run):
|
||||
def test_activate(activate_user: MagicMock, load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
|
||||
result = run(cli.activate, "frank@foo.social")
|
||||
result = run(cli.auth.activate, "frank@foo.social")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account frank@foo.social activated"
|
||||
activate_user.assert_called_once_with(User("foo.social", "frank", "123"))
|
||||
@ -194,7 +194,7 @@ def test_activate(activate_user: MagicMock, load_config: MagicMock, run: Run):
|
||||
def test_activate_not_logged_in(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = EMPTY_CONFIG
|
||||
|
||||
result = run(cli.activate)
|
||||
result = run(cli.auth.activate)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: You're not logged into any accounts"
|
||||
|
||||
@ -203,7 +203,7 @@ def test_activate_not_logged_in(load_config: MagicMock, run: Run):
|
||||
def test_activate_account_not_given(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
|
||||
result = run(cli.activate)
|
||||
result = run(cli.auth.activate)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.startswith("Error: Specify account to activate")
|
||||
|
||||
@ -212,6 +212,6 @@ def test_activate_account_not_given(load_config: MagicMock, run: Run):
|
||||
def test_activate_invalid_Account(load_config: MagicMock, run: Run):
|
||||
load_config.return_value = SAMPLE_CONFIG
|
||||
|
||||
result = run(cli.activate, "banana")
|
||||
result = run(cli.auth.activate, "banana")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.startswith("Error: Account not found")
|
||||
|
@ -4,83 +4,83 @@ from tests.integration.conftest import register_account
|
||||
|
||||
|
||||
def test_lists_empty(run):
|
||||
result = run(cli.lists)
|
||||
result = run(cli.lists.lists)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You have no lists defined."
|
||||
|
||||
|
||||
def test_list_create_delete(run):
|
||||
result = run(cli.list_create, "banana")
|
||||
result = run(cli.lists.list_create, "banana")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == '✓ List "banana" created.'
|
||||
|
||||
result = run(cli.lists)
|
||||
result = run(cli.lists.lists)
|
||||
assert result.exit_code == 0
|
||||
assert "banana" in result.stdout
|
||||
|
||||
result = run(cli.list_create, "mango")
|
||||
result = run(cli.lists.list_create, "mango")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == '✓ List "mango" created.'
|
||||
|
||||
result = run(cli.lists)
|
||||
result = run(cli.lists.lists)
|
||||
assert result.exit_code == 0
|
||||
assert "banana" in result.stdout
|
||||
assert "mango" in result.stdout
|
||||
|
||||
result = run(cli.list_delete, "banana")
|
||||
result = run(cli.lists.list_delete, "banana")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == '✓ List "banana" deleted.'
|
||||
|
||||
result = run(cli.lists)
|
||||
result = run(cli.lists.lists)
|
||||
assert result.exit_code == 0
|
||||
assert "banana" not in result.stdout
|
||||
assert "mango" in result.stdout
|
||||
|
||||
result = run(cli.list_delete, "mango")
|
||||
result = run(cli.lists.list_delete, "mango")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == '✓ List "mango" deleted.'
|
||||
|
||||
result = run(cli.lists)
|
||||
result = run(cli.lists.lists)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You have no lists defined."
|
||||
|
||||
result = run(cli.list_delete, "mango")
|
||||
result = run(cli.lists.list_delete, "mango")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: List not found"
|
||||
|
||||
|
||||
def test_list_add_remove(run, app):
|
||||
acc = register_account(app)
|
||||
run(cli.list_create, "foo")
|
||||
run(cli.lists.list_create, "foo")
|
||||
|
||||
result = run(cli.list_add, "foo", acc.username)
|
||||
result = run(cli.lists.list_add, "foo", acc.username)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == f"Error: You must follow @{acc.username} before adding this account to a list."
|
||||
|
||||
run(cli.follow, acc.username)
|
||||
run(cli.accounts.follow, acc.username)
|
||||
|
||||
result = run(cli.list_add, "foo", acc.username)
|
||||
result = run(cli.lists.list_add, "foo", acc.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f'✓ Added account "{acc.username}"'
|
||||
|
||||
result = run(cli.list_accounts, "foo")
|
||||
result = run(cli.lists.list_accounts, "foo")
|
||||
assert result.exit_code == 0
|
||||
assert acc.username in result.stdout
|
||||
|
||||
# Account doesn't exist
|
||||
result = run(cli.list_add, "foo", "does_not_exist")
|
||||
result = run(cli.lists.list_add, "foo", "does_not_exist")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Account not found"
|
||||
|
||||
# List doesn't exist
|
||||
result = run(cli.list_add, "does_not_exist", acc.username)
|
||||
result = run(cli.lists.list_add, "does_not_exist", acc.username)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: List not found"
|
||||
|
||||
result = run(cli.list_remove, "foo", acc.username)
|
||||
result = run(cli.lists.list_remove, "foo", acc.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f'✓ Removed account "{acc.username}"'
|
||||
|
||||
result = run(cli.list_accounts, "foo")
|
||||
result = run(cli.lists.list_accounts, "foo")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "This list has no accounts."
|
||||
|
@ -12,7 +12,7 @@ from unittest import mock
|
||||
|
||||
def test_post(app, user, run):
|
||||
text = "i wish i was a #lumberjack"
|
||||
result = run(cli.post, text)
|
||||
result = run(cli.post.post, text)
|
||||
assert result.exit_code == 0
|
||||
|
||||
status_id = posted_status_id(result.stdout)
|
||||
@ -31,14 +31,14 @@ def test_post(app, user, run):
|
||||
|
||||
|
||||
def test_post_no_text(run):
|
||||
result = run(cli.post)
|
||||
result = run(cli.post.post)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: You must specify either text or media to post."
|
||||
|
||||
|
||||
def test_post_json(run):
|
||||
content = "i wish i was a #lumberjack"
|
||||
result = run(cli.post, content, "--json")
|
||||
result = run(cli.post.post, content, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
status = json.loads(result.stdout)
|
||||
@ -51,7 +51,7 @@ def test_post_json(run):
|
||||
|
||||
def test_post_visibility(app, user, run):
|
||||
for visibility in ["public", "unlisted", "private", "direct"]:
|
||||
result = run(cli.post, "foo", "--visibility", visibility)
|
||||
result = run(cli.post.post, "foo", "--visibility", visibility)
|
||||
assert result.exit_code == 0
|
||||
|
||||
status_id = posted_status_id(result.stdout)
|
||||
@ -63,7 +63,7 @@ def test_post_scheduled_at(app, user, run):
|
||||
text = str(uuid.uuid4())
|
||||
scheduled_at = datetime.now(timezone.utc).replace(microsecond=0) + timedelta(minutes=10)
|
||||
|
||||
result = run(cli.post, text, "--scheduled-at", scheduled_at.isoformat())
|
||||
result = run(cli.post.post, text, "--scheduled-at", scheduled_at.isoformat())
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "Toot scheduled for" in result.stdout
|
||||
@ -74,7 +74,7 @@ def test_post_scheduled_at(app, user, run):
|
||||
|
||||
|
||||
def test_post_scheduled_at_error(run):
|
||||
result = run(cli.post, "foo", "--scheduled-at", "banana")
|
||||
result = run(cli.post.post, "foo", "--scheduled-at", "banana")
|
||||
assert result.exit_code == 1
|
||||
# Stupid error returned by mastodon
|
||||
assert result.stderr.strip() == "Error: Record invalid"
|
||||
@ -96,7 +96,7 @@ def test_post_scheduled_in(app, user, run):
|
||||
|
||||
datetimes = []
|
||||
for scheduled_in, delta in variants:
|
||||
result = run(cli.post, text, "--scheduled-in", scheduled_in)
|
||||
result = run(cli.post.post, text, "--scheduled-in", scheduled_in)
|
||||
assert result.exit_code == 0
|
||||
|
||||
dttm = datetime.utcnow() + delta
|
||||
@ -115,13 +115,13 @@ def test_post_scheduled_in(app, user, run):
|
||||
|
||||
|
||||
def test_post_scheduled_in_invalid_duration(run):
|
||||
result = run(cli.post, "foo", "--scheduled-in", "banana")
|
||||
result = run(cli.post.post, "foo", "--scheduled-in", "banana")
|
||||
assert result.exit_code == 2
|
||||
assert "Invalid duration: banana" in result.stderr
|
||||
|
||||
|
||||
def test_post_scheduled_in_empty_duration(run):
|
||||
result = run(cli.post, "foo", "--scheduled-in", "0m")
|
||||
result = run(cli.post.post, "foo", "--scheduled-in", "0m")
|
||||
assert result.exit_code == 2
|
||||
assert "Empty duration" in result.stderr
|
||||
|
||||
@ -130,7 +130,7 @@ def test_post_poll(app, user, run):
|
||||
text = str(uuid.uuid4())
|
||||
|
||||
result = run(
|
||||
cli.post, text,
|
||||
cli.post.post, text,
|
||||
"--poll-option", "foo",
|
||||
"--poll-option", "bar",
|
||||
"--poll-option", "baz",
|
||||
@ -161,7 +161,7 @@ def test_post_poll_multiple(app, user, run):
|
||||
text = str(uuid.uuid4())
|
||||
|
||||
result = run(
|
||||
cli.post, text,
|
||||
cli.post.post, text,
|
||||
"--poll-option", "foo",
|
||||
"--poll-option", "bar",
|
||||
"--poll-multiple"
|
||||
@ -177,7 +177,7 @@ def test_post_poll_expires_in(app, user, run):
|
||||
text = str(uuid.uuid4())
|
||||
|
||||
result = run(
|
||||
cli.post, text,
|
||||
cli.post.post, text,
|
||||
"--poll-option", "foo",
|
||||
"--poll-option", "bar",
|
||||
"--poll-expires-in", "8h",
|
||||
@ -197,7 +197,7 @@ def test_post_poll_hide_totals(app, user, run):
|
||||
text = str(uuid.uuid4())
|
||||
|
||||
result = run(
|
||||
cli.post, text,
|
||||
cli.post.post, text,
|
||||
"--poll-option", "foo",
|
||||
"--poll-option", "bar",
|
||||
"--poll-hide-totals"
|
||||
@ -216,14 +216,14 @@ def test_post_poll_hide_totals(app, user, run):
|
||||
|
||||
|
||||
def test_post_language(app, user, run):
|
||||
result = run(cli.post, "test", "--language", "hr")
|
||||
result = run(cli.post.post, "test", "--language", "hr")
|
||||
assert result.exit_code == 0
|
||||
|
||||
status_id = posted_status_id(result.stdout)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["language"] == "hr"
|
||||
|
||||
result = run(cli.post, "test", "--language", "zh")
|
||||
result = run(cli.post.post, "test", "--language", "zh")
|
||||
assert result.exit_code == 0
|
||||
|
||||
status_id = posted_status_id(result.stdout)
|
||||
@ -232,7 +232,7 @@ def test_post_language(app, user, run):
|
||||
|
||||
|
||||
def test_post_language_error(run):
|
||||
result = run(cli.post, "test", "--language", "banana")
|
||||
result = run(cli.post.post, "test", "--language", "banana")
|
||||
assert result.exit_code == 2
|
||||
assert "Language should be a two letter abbreviation." in result.stderr
|
||||
|
||||
@ -242,7 +242,7 @@ def test_media_thumbnail(app, user, run):
|
||||
thumbnail_path = path.join(ASSETS_DIR, "test1.png")
|
||||
|
||||
result = run(
|
||||
cli.post,
|
||||
cli.post.post,
|
||||
"--media", video_path,
|
||||
"--thumbnail", thumbnail_path,
|
||||
"--description", "foo",
|
||||
@ -276,7 +276,7 @@ def test_media_attachments(app, user, run):
|
||||
path4 = path.join(ASSETS_DIR, "test4.png")
|
||||
|
||||
result = run(
|
||||
cli.post,
|
||||
cli.post.post,
|
||||
"--media", path1,
|
||||
"--media", path2,
|
||||
"--media", path3,
|
||||
@ -309,7 +309,7 @@ def test_media_attachments(app, user, run):
|
||||
|
||||
def test_too_many_media(run):
|
||||
m = path.join(ASSETS_DIR, "test1.png")
|
||||
result = run(cli.post, "-m", m, "-m", m, "-m", m, "-m", m, "-m", m)
|
||||
result = run(cli.post.post, "-m", m, "-m", m, "-m", m, "-m", m, "-m", m)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Cannot attach more than 4 files."
|
||||
|
||||
@ -323,7 +323,7 @@ def test_media_attachment_without_text(mock_read, mock_ml, app, user, run):
|
||||
|
||||
media_path = path.join(ASSETS_DIR, "test1.png")
|
||||
|
||||
result = run(cli.post, "--media", media_path)
|
||||
result = run(cli.post.post, "--media", media_path)
|
||||
assert result.exit_code == 0
|
||||
|
||||
status_id = posted_status_id(result.stdout)
|
||||
@ -342,7 +342,7 @@ def test_media_attachment_without_text(mock_read, mock_ml, app, user, run):
|
||||
def test_reply_thread(app, user, friend, run):
|
||||
status = api.post_status(app, friend, "This is the status").json()
|
||||
|
||||
result = run(cli.post, "--reply-to", status["id"], "This is the reply")
|
||||
result = run(cli.post.post, "--reply-to", status["id"], "This is the reply")
|
||||
assert result.exit_code == 0
|
||||
|
||||
status_id = posted_status_id(result.stdout)
|
||||
@ -350,7 +350,7 @@ def test_reply_thread(app, user, friend, run):
|
||||
|
||||
assert reply["in_reply_to_id"] == status["id"]
|
||||
|
||||
result = run(cli.thread, status["id"])
|
||||
result = run(cli.read.thread, status["id"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
[s1, s2] = [s.strip() for s in re.split(r"─+", result.stdout) if s.strip()]
|
||||
|
@ -8,7 +8,7 @@ from uuid import uuid4
|
||||
|
||||
|
||||
def test_instance_default(app, run):
|
||||
result = run(cli.instance)
|
||||
result = run(cli.read.instance)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "Mastodon" in result.stdout
|
||||
@ -17,7 +17,7 @@ def test_instance_default(app, run):
|
||||
|
||||
|
||||
def test_instance_with_url(app, run):
|
||||
result = run(cli.instance, TOOT_TEST_BASE_URL)
|
||||
result = run(cli.read.instance, TOOT_TEST_BASE_URL)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "Mastodon" in result.stdout
|
||||
@ -26,7 +26,7 @@ def test_instance_with_url(app, run):
|
||||
|
||||
|
||||
def test_instance_json(app, run):
|
||||
result = run(cli.instance, "--json")
|
||||
result = run(cli.read.instance, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
data = json.loads(result.stdout)
|
||||
@ -36,7 +36,7 @@ def test_instance_json(app, run):
|
||||
|
||||
|
||||
def test_instance_anon(app, run_anon, base_url):
|
||||
result = run_anon(cli.instance, base_url)
|
||||
result = run_anon(cli.read.instance, base_url)
|
||||
assert result.exit_code == 0
|
||||
|
||||
assert "Mastodon" in result.stdout
|
||||
@ -44,19 +44,19 @@ def test_instance_anon(app, run_anon, base_url):
|
||||
assert "running Mastodon" in result.stdout
|
||||
|
||||
# Need to specify the instance name when running anon
|
||||
result = run_anon(cli.instance)
|
||||
result = run_anon(cli.read.instance)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr == "Error: Please specify an instance.\n"
|
||||
|
||||
|
||||
def test_whoami(user, run):
|
||||
result = run(cli.whoami)
|
||||
result = run(cli.read.whoami)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{user.username}" in result.stdout
|
||||
|
||||
|
||||
def test_whoami_json(user, run):
|
||||
result = run(cli.whoami, "--json")
|
||||
result = run(cli.read.whoami, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
data = json.loads(result.stdout)
|
||||
@ -74,13 +74,13 @@ def test_whois(app, friend, run):
|
||||
]
|
||||
|
||||
for username in variants:
|
||||
result = run(cli.whois, username)
|
||||
result = run(cli.read.whois, username)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{friend.username}" in result.stdout
|
||||
|
||||
|
||||
def test_whois_json(app, friend, run):
|
||||
result = run(cli.whois, friend.username, "--json")
|
||||
result = run(cli.read.whois, friend.username, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
data = json.loads(result.stdout)
|
||||
@ -90,13 +90,13 @@ def test_whois_json(app, friend, run):
|
||||
|
||||
|
||||
def test_search_account(friend, run):
|
||||
result = run(cli.search, friend.username)
|
||||
result = run(cli.read.search, friend.username)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f"Accounts:\n* @{friend.username}"
|
||||
|
||||
|
||||
def test_search_account_json(friend, run):
|
||||
result = run(cli.search, friend.username, "--json")
|
||||
result = run(cli.read.search, friend.username, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
data = json.loads(result.stdout)
|
||||
@ -109,7 +109,7 @@ def test_search_hashtag(app, user, run):
|
||||
api.post_status(app, user, "#hashtag_y")
|
||||
api.post_status(app, user, "#hashtag_z")
|
||||
|
||||
result = run(cli.search, "#hashtag")
|
||||
result = run(cli.read.search, "#hashtag")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "Hashtags:\n#hashtag_x, #hashtag_y, #hashtag_z"
|
||||
|
||||
@ -119,7 +119,7 @@ def test_search_hashtag_json(app, user, run):
|
||||
api.post_status(app, user, "#hashtag_y")
|
||||
api.post_status(app, user, "#hashtag_z")
|
||||
|
||||
result = run(cli.search, "#hashtag", "--json")
|
||||
result = run(cli.read.search, "#hashtag", "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
data = json.loads(result.stdout)
|
||||
@ -134,7 +134,7 @@ def test_status(app, user, run):
|
||||
uuid = str(uuid4())
|
||||
status_id = api.post_status(app, user, uuid).json()["id"]
|
||||
|
||||
result = run(cli.status, status_id)
|
||||
result = run(cli.read.status, status_id)
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout.strip()
|
||||
@ -147,7 +147,7 @@ def test_status_json(app, user, run):
|
||||
uuid = str(uuid4())
|
||||
status_id = api.post_status(app, user, uuid).json()["id"]
|
||||
|
||||
result = run(cli.status, status_id, "--json")
|
||||
result = run(cli.read.status, status_id, "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
status = from_dict(Status, json.loads(result.stdout))
|
||||
@ -166,7 +166,7 @@ def test_thread(app, user, run):
|
||||
s3 = api.post_status(app, user, uuid3, in_reply_to_id=s2["id"]).json()
|
||||
|
||||
for status in [s1, s2, s3]:
|
||||
result = run(cli.thread, status["id"])
|
||||
result = run(cli.read.thread, status["id"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
bits = re.split(r"─+", result.stdout.strip())
|
||||
@ -192,7 +192,7 @@ def test_thread_json(app, user, run):
|
||||
s2 = api.post_status(app, user, uuid2, in_reply_to_id=s1["id"]).json()
|
||||
s3 = api.post_status(app, user, uuid3, in_reply_to_id=s2["id"]).json()
|
||||
|
||||
result = run(cli.thread, s2["id"], "--json")
|
||||
result = run(cli.read.thread, s2["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
|
@ -9,7 +9,7 @@ from toot.exceptions import NotFoundError
|
||||
def test_delete(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
|
||||
result = run(cli.delete, status["id"])
|
||||
result = run(cli.statuses.delete, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status deleted"
|
||||
|
||||
@ -20,7 +20,7 @@ def test_delete(app, user, run):
|
||||
def test_delete_json(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
|
||||
result = run(cli.delete, status["id"], "--json")
|
||||
result = run(cli.statuses.delete, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
out = result.stdout
|
||||
@ -35,14 +35,14 @@ def test_favourite(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["favourited"]
|
||||
|
||||
result = run(cli.favourite, status["id"])
|
||||
result = run(cli.statuses.favourite, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status favourited"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["favourited"]
|
||||
|
||||
result = run(cli.unfavourite, status["id"])
|
||||
result = run(cli.statuses.unfavourite, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status unfavourited"
|
||||
|
||||
@ -57,14 +57,14 @@ def test_favourite_json(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["favourited"]
|
||||
|
||||
result = run(cli.favourite, status["id"], "--json")
|
||||
result = run(cli.statuses.favourite, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
assert result["id"] == status["id"]
|
||||
assert result["favourited"] is True
|
||||
|
||||
result = run(cli.unfavourite, status["id"], "--json")
|
||||
result = run(cli.statuses.unfavourite, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
@ -76,22 +76,22 @@ def test_reblog(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["reblogged"]
|
||||
|
||||
result = run(cli.reblogged_by, status["id"])
|
||||
result = run(cli.statuses.reblogged_by, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "This status is not reblogged by anyone"
|
||||
|
||||
result = run(cli.reblog, status["id"])
|
||||
result = run(cli.statuses.reblog, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status reblogged"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["reblogged"]
|
||||
|
||||
result = run(cli.reblogged_by, status["id"])
|
||||
result = run(cli.statuses.reblogged_by, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert user.username in result.stdout
|
||||
|
||||
result = run(cli.unreblog, status["id"])
|
||||
result = run(cli.statuses.unreblog, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status unreblogged"
|
||||
|
||||
@ -103,20 +103,20 @@ def test_reblog_json(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["reblogged"]
|
||||
|
||||
result = run(cli.reblog, status["id"], "--json")
|
||||
result = run(cli.statuses.reblog, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
assert result["reblogged"] is True
|
||||
assert result["reblog"]["id"] == status["id"]
|
||||
|
||||
result = run(cli.reblogged_by, status["id"], "--json")
|
||||
result = run(cli.statuses.reblogged_by, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
[reblog] = json.loads(result.stdout)
|
||||
assert reblog["acct"] == user.username
|
||||
|
||||
result = run(cli.unreblog, status["id"], "--json")
|
||||
result = run(cli.statuses.unreblog, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
@ -128,14 +128,14 @@ def test_pin(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["pinned"]
|
||||
|
||||
result = run(cli.pin, status["id"])
|
||||
result = run(cli.statuses.pin, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status pinned"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["pinned"]
|
||||
|
||||
result = run(cli.unpin, status["id"])
|
||||
result = run(cli.statuses.unpin, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status unpinned"
|
||||
|
||||
@ -147,14 +147,14 @@ def test_pin_json(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["pinned"]
|
||||
|
||||
result = run(cli.pin, status["id"], "--json")
|
||||
result = run(cli.statuses.pin, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
assert result["pinned"] is True
|
||||
assert result["id"] == status["id"]
|
||||
|
||||
result = run(cli.unpin, status["id"], "--json")
|
||||
result = run(cli.statuses.unpin, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
@ -166,14 +166,14 @@ def test_bookmark(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["bookmarked"]
|
||||
|
||||
result = run(cli.bookmark, status["id"])
|
||||
result = run(cli.statuses.bookmark, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status bookmarked"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["bookmarked"]
|
||||
|
||||
result = run(cli.unbookmark, status["id"])
|
||||
result = run(cli.statuses.unbookmark, status["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Status unbookmarked"
|
||||
|
||||
@ -185,14 +185,14 @@ def test_bookmark_json(app, user, run):
|
||||
status = api.post_status(app, user, "foo").json()
|
||||
assert not status["bookmarked"]
|
||||
|
||||
result = run(cli.bookmark, status["id"], "--json")
|
||||
result = run(cli.statuses.bookmark, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
assert result["id"] == status["id"]
|
||||
assert result["bookmarked"] is True
|
||||
|
||||
result = run(cli.unbookmark, status["id"], "--json")
|
||||
result = run(cli.statuses.unbookmark, status["id"], "--json")
|
||||
assert result.exit_code == 0
|
||||
|
||||
result = json.loads(result.stdout)
|
||||
|
@ -6,63 +6,63 @@ from toot.entities import FeaturedTag, Tag, from_dict, from_dict_list
|
||||
|
||||
|
||||
def test_tags(run):
|
||||
result = run(cli.tags, "followed")
|
||||
result = run(cli.tags.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You're not following any hashtags"
|
||||
|
||||
result = run(cli.tags, "follow", "foo")
|
||||
result = run(cli.tags.tags, "follow", "foo")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are now following #foo"
|
||||
|
||||
result = run(cli.tags, "followed")
|
||||
result = run(cli.tags.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert _find_tags(result.stdout) == ["#foo"]
|
||||
|
||||
result = run(cli.tags, "follow", "bar")
|
||||
result = run(cli.tags.tags, "follow", "bar")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are now following #bar"
|
||||
|
||||
result = run(cli.tags, "followed")
|
||||
result = run(cli.tags.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert _find_tags(result.stdout) == ["#bar", "#foo"]
|
||||
|
||||
result = run(cli.tags, "unfollow", "foo")
|
||||
result = run(cli.tags.tags, "unfollow", "foo")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are no longer following #foo"
|
||||
|
||||
result = run(cli.tags, "followed")
|
||||
result = run(cli.tags.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert _find_tags(result.stdout) == ["#bar"]
|
||||
|
||||
result = run(cli.tags, "unfollow", "bar")
|
||||
result = run(cli.tags.tags, "unfollow", "bar")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are no longer following #bar"
|
||||
|
||||
result = run(cli.tags, "followed")
|
||||
result = run(cli.tags.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You're not following any hashtags"
|
||||
|
||||
|
||||
def test_tags_json(run_json):
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
result = run_json(cli.tags.tags, "followed", "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.tags, "follow", "foo", "--json")
|
||||
result = run_json(cli.tags.tags, "follow", "foo", "--json")
|
||||
tag = from_dict(Tag, result)
|
||||
assert tag.name == "foo"
|
||||
assert tag.following is True
|
||||
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
result = run_json(cli.tags.tags, "followed", "--json")
|
||||
[tag] = from_dict_list(Tag, result)
|
||||
assert tag.name == "foo"
|
||||
assert tag.following is True
|
||||
|
||||
result = run_json(cli.tags, "follow", "bar", "--json")
|
||||
result = run_json(cli.tags.tags, "follow", "bar", "--json")
|
||||
tag = from_dict(Tag, result)
|
||||
assert tag.name == "bar"
|
||||
assert tag.following is True
|
||||
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
result = run_json(cli.tags.tags, "followed", "--json")
|
||||
tags = from_dict_list(Tag, result)
|
||||
[bar, foo] = sorted(tags, key=lambda t: t.name)
|
||||
assert foo.name == "foo"
|
||||
@ -70,47 +70,47 @@ def test_tags_json(run_json):
|
||||
assert bar.name == "bar"
|
||||
assert bar.following is True
|
||||
|
||||
result = run_json(cli.tags, "unfollow", "foo", "--json")
|
||||
result = run_json(cli.tags.tags, "unfollow", "foo", "--json")
|
||||
tag = from_dict(Tag, result)
|
||||
assert tag.name == "foo"
|
||||
assert tag.following is False
|
||||
|
||||
result = run_json(cli.tags, "unfollow", "bar", "--json")
|
||||
result = run_json(cli.tags.tags, "unfollow", "bar", "--json")
|
||||
tag = from_dict(Tag, result)
|
||||
assert tag.name == "bar"
|
||||
assert tag.following is False
|
||||
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
result = run_json(cli.tags.tags, "followed", "--json")
|
||||
assert result == []
|
||||
|
||||
|
||||
def test_tags_featured(run, app, user):
|
||||
result = run(cli.tags, "featured")
|
||||
result = run(cli.tags.tags, "featured")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You don't have any featured hashtags"
|
||||
|
||||
result = run(cli.tags, "feature", "foo")
|
||||
result = run(cli.tags.tags, "feature", "foo")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Tag #foo is now featured"
|
||||
|
||||
result = run(cli.tags, "featured")
|
||||
result = run(cli.tags.tags, "featured")
|
||||
assert result.exit_code == 0
|
||||
assert _find_tags(result.stdout) == ["#foo"]
|
||||
|
||||
result = run(cli.tags, "feature", "bar")
|
||||
result = run(cli.tags.tags, "feature", "bar")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Tag #bar is now featured"
|
||||
|
||||
result = run(cli.tags, "featured")
|
||||
result = run(cli.tags.tags, "featured")
|
||||
assert result.exit_code == 0
|
||||
assert _find_tags(result.stdout) == ["#bar", "#foo"]
|
||||
|
||||
# Unfeature by Name
|
||||
result = run(cli.tags, "unfeature", "foo")
|
||||
result = run(cli.tags.tags, "unfeature", "foo")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Tag #foo is no longer featured"
|
||||
|
||||
result = run(cli.tags, "featured")
|
||||
result = run(cli.tags.tags, "featured")
|
||||
assert result.exit_code == 0
|
||||
assert _find_tags(result.stdout) == ["#bar"]
|
||||
|
||||
@ -118,44 +118,44 @@ def test_tags_featured(run, app, user):
|
||||
tag = api.find_featured_tag(app, user, "bar")
|
||||
assert tag is not None
|
||||
|
||||
result = run(cli.tags, "unfeature", tag["id"])
|
||||
result = run(cli.tags.tags, "unfeature", tag["id"])
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Tag #bar is no longer featured"
|
||||
|
||||
result = run(cli.tags, "featured")
|
||||
result = run(cli.tags.tags, "featured")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You don't have any featured hashtags"
|
||||
|
||||
|
||||
def test_tags_featured_json(run_json):
|
||||
result = run_json(cli.tags, "featured", "--json")
|
||||
result = run_json(cli.tags.tags, "featured", "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.tags, "feature", "foo", "--json")
|
||||
result = run_json(cli.tags.tags, "feature", "foo", "--json")
|
||||
tag = from_dict(FeaturedTag, result)
|
||||
assert tag.name == "foo"
|
||||
|
||||
result = run_json(cli.tags, "featured", "--json")
|
||||
result = run_json(cli.tags.tags, "featured", "--json")
|
||||
[tag] = from_dict_list(FeaturedTag, result)
|
||||
assert tag.name == "foo"
|
||||
|
||||
result = run_json(cli.tags, "feature", "bar", "--json")
|
||||
result = run_json(cli.tags.tags, "feature", "bar", "--json")
|
||||
tag = from_dict(FeaturedTag, result)
|
||||
assert tag.name == "bar"
|
||||
|
||||
result = run_json(cli.tags, "featured", "--json")
|
||||
result = run_json(cli.tags.tags, "featured", "--json")
|
||||
tags = from_dict_list(FeaturedTag, result)
|
||||
[bar, foo] = sorted(tags, key=lambda t: t.name)
|
||||
assert foo.name == "foo"
|
||||
assert bar.name == "bar"
|
||||
|
||||
result = run_json(cli.tags, "unfeature", "foo", "--json")
|
||||
result = run_json(cli.tags.tags, "unfeature", "foo", "--json")
|
||||
assert result == {}
|
||||
|
||||
result = run_json(cli.tags, "unfeature", "bar", "--json")
|
||||
result = run_json(cli.tags.tags, "unfeature", "bar", "--json")
|
||||
assert result == {}
|
||||
|
||||
result = run_json(cli.tags, "featured", "--json")
|
||||
result = run_json(cli.tags.tags, "featured", "--json")
|
||||
assert result == []
|
||||
|
||||
|
||||
|
@ -45,68 +45,68 @@ def test_timelines(app, user, other_user, friend_user, friend_list, run):
|
||||
sleep(1)
|
||||
|
||||
# Home timeline
|
||||
result = run(cli.timeline)
|
||||
result = run(cli.timelines.timeline)
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id not in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# Public timeline
|
||||
result = run(cli.timeline, "--public")
|
||||
result = run(cli.timelines.timeline, "--public")
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# Anon public timeline
|
||||
result = run(cli.timeline, "--instance", TOOT_TEST_BASE_URL, "--public")
|
||||
result = run(cli.timelines.timeline, "--instance", TOOT_TEST_BASE_URL, "--public")
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# Tag timeline
|
||||
result = run(cli.timeline, "--tag", "foo")
|
||||
result = run(cli.timelines.timeline, "--tag", "foo")
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id not in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
result = run(cli.timeline, "--tag", "bar")
|
||||
result = run(cli.timelines.timeline, "--tag", "bar")
|
||||
assert result.exit_code == 0
|
||||
assert status1.id not in result.stdout
|
||||
assert status2.id in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# Anon tag timeline
|
||||
result = run(cli.timeline, "--instance", TOOT_TEST_BASE_URL, "--tag", "foo")
|
||||
result = run(cli.timelines.timeline, "--instance", TOOT_TEST_BASE_URL, "--tag", "foo")
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id not in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# List timeline (by list name)
|
||||
result = run(cli.timeline, "--list", friend_list["title"])
|
||||
result = run(cli.timelines.timeline, "--list", friend_list["title"])
|
||||
assert result.exit_code == 0
|
||||
assert status1.id not in result.stdout
|
||||
assert status2.id not in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# List timeline (by list ID)
|
||||
result = run(cli.timeline, "--list", friend_list["id"])
|
||||
result = run(cli.timelines.timeline, "--list", friend_list["id"])
|
||||
assert result.exit_code == 0
|
||||
assert status1.id not in result.stdout
|
||||
assert status2.id not in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
# Account timeline
|
||||
result = run(cli.timeline, "--account", friend_user.username)
|
||||
result = run(cli.timelines.timeline, "--account", friend_user.username)
|
||||
assert result.exit_code == 0
|
||||
assert status1.id not in result.stdout
|
||||
assert status2.id not in result.stdout
|
||||
assert status3.id in result.stdout
|
||||
|
||||
result = run(cli.timeline, "--account", other_user.username)
|
||||
result = run(cli.timelines.timeline, "--account", other_user.username)
|
||||
assert result.exit_code == 0
|
||||
assert status1.id not in result.stdout
|
||||
assert status2.id in result.stdout
|
||||
@ -115,25 +115,25 @@ def test_timelines(app, user, other_user, friend_user, friend_list, run):
|
||||
|
||||
def test_empty_timeline(app, run_as):
|
||||
user = register_account(app)
|
||||
result = run_as(user, cli.timeline)
|
||||
result = run_as(user, cli.timelines.timeline)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "─" * 80
|
||||
|
||||
|
||||
def test_timeline_cant_combine_timelines(run):
|
||||
result = run(cli.timeline, "--tag", "foo", "--account", "bar")
|
||||
result = run(cli.timelines.timeline, "--tag", "foo", "--account", "bar")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Only one of --public, --tag, --account, or --list can be used at one time."
|
||||
|
||||
|
||||
def test_timeline_local_needs_public_or_tag(run):
|
||||
result = run(cli.timeline, "--local")
|
||||
result = run(cli.timelines.timeline, "--local")
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: The --local option is only valid alongside --public or --tag."
|
||||
|
||||
|
||||
def test_timeline_instance_needs_public_or_tag(run):
|
||||
result = run(cli.timeline, "--instance", TOOT_TEST_BASE_URL)
|
||||
result = run(cli.timelines.timeline, "--instance", TOOT_TEST_BASE_URL)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: The --instance option is only valid alongside --public or --tag."
|
||||
|
||||
@ -145,14 +145,14 @@ def test_bookmarks(app, user, run):
|
||||
api.bookmark(app, user, status1.id)
|
||||
api.bookmark(app, user, status2.id)
|
||||
|
||||
result = run(cli.bookmarks)
|
||||
result = run(cli.timelines.bookmarks)
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id in result.stdout
|
||||
assert result.stdout.find(status1.id) > result.stdout.find(status2.id)
|
||||
|
||||
|
||||
result = run(cli.bookmarks, "--reverse")
|
||||
result = run(cli.timelines.bookmarks, "--reverse")
|
||||
assert result.exit_code == 0
|
||||
assert status1.id in result.stdout
|
||||
assert status2.id in result.stdout
|
||||
@ -160,7 +160,7 @@ def test_bookmarks(app, user, run):
|
||||
|
||||
|
||||
def test_notifications(app, user, other_user, run):
|
||||
result = run(cli.notifications)
|
||||
result = run(cli.timelines.notifications)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You have no notifications"
|
||||
|
||||
@ -168,13 +168,13 @@ def test_notifications(app, user, other_user, run):
|
||||
status = _post_status(app, other_user, text)
|
||||
sleep(0.5) # grr
|
||||
|
||||
result = run(cli.notifications)
|
||||
result = run(cli.timelines.notifications)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{other_user.username} mentioned you" in result.stdout
|
||||
assert status.id in result.stdout
|
||||
assert text in result.stdout
|
||||
|
||||
result = run(cli.notifications, "--mentions")
|
||||
result = run(cli.timelines.notifications, "--mentions")
|
||||
assert result.exit_code == 0
|
||||
assert f"@{other_user.username} mentioned you" in result.stdout
|
||||
assert status.id in result.stdout
|
||||
@ -182,12 +182,12 @@ def test_notifications(app, user, other_user, run):
|
||||
|
||||
|
||||
def test_notifications_follow(app, user, friend_user, run_as):
|
||||
result = run_as(friend_user, cli.notifications)
|
||||
result = run_as(friend_user, cli.timelines.notifications)
|
||||
assert result.exit_code == 0
|
||||
assert f"@{user.username} now follows you" in result.stdout
|
||||
|
||||
|
||||
result = run_as(friend_user, cli.notifications, "--mentions")
|
||||
result = run_as(friend_user, cli.timelines.notifications, "--mentions")
|
||||
assert result.exit_code == 0
|
||||
assert "now follows you" not in result.stdout
|
||||
|
||||
|
@ -6,7 +6,7 @@ from toot.utils import get_text
|
||||
|
||||
|
||||
def test_update_account_no_options(run):
|
||||
result = run(cli.update_account)
|
||||
result = run(cli.accounts.update_account)
|
||||
assert result.exit_code == 1
|
||||
assert result.stderr.strip() == "Error: Please specify at least one option to update the account"
|
||||
|
||||
@ -14,7 +14,7 @@ def test_update_account_no_options(run):
|
||||
def test_update_account_display_name(run, app, user):
|
||||
name = str(uuid4())[:10]
|
||||
|
||||
result = run(cli.update_account, "--display-name", name)
|
||||
result = run(cli.accounts.update_account, "--display-name", name)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -24,7 +24,7 @@ def test_update_account_display_name(run, app, user):
|
||||
|
||||
def test_update_account_json(run_json, app, user):
|
||||
name = str(uuid4())[:10]
|
||||
out = run_json(cli.update_account, "--display-name", name, "--json")
|
||||
out = run_json(cli.accounts.update_account, "--display-name", name, "--json")
|
||||
account = from_dict(Account, out)
|
||||
assert account.acct == user.username
|
||||
assert account.display_name == name
|
||||
@ -34,7 +34,7 @@ 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.")
|
||||
|
||||
result = run(cli.update_account, "--note", note)
|
||||
result = run(cli.accounts.update_account, "--note", note)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -43,7 +43,7 @@ def test_update_account_note(run, app, user):
|
||||
|
||||
|
||||
def test_update_account_language(run, app, user):
|
||||
result = run(cli.update_account, "--language", "hr")
|
||||
result = run(cli.accounts.update_account, "--language", "hr")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -52,7 +52,7 @@ def test_update_account_language(run, app, user):
|
||||
|
||||
|
||||
def test_update_account_privacy(run, app, user):
|
||||
result = run(cli.update_account, "--privacy", "private")
|
||||
result = run(cli.accounts.update_account, "--privacy", "private")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -64,7 +64,7 @@ def test_update_account_avatar(run, app, user):
|
||||
account = api.verify_credentials(app, user).json()
|
||||
old_value = account["avatar"]
|
||||
|
||||
result = run(cli.update_account, "--avatar", TRUMPET)
|
||||
result = run(cli.accounts.update_account, "--avatar", TRUMPET)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -76,7 +76,7 @@ def test_update_account_header(run, app, user):
|
||||
account = api.verify_credentials(app, user).json()
|
||||
old_value = account["header"]
|
||||
|
||||
result = run(cli.update_account, "--header", TRUMPET)
|
||||
result = run(cli.accounts.update_account, "--header", TRUMPET)
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -85,14 +85,14 @@ def test_update_account_header(run, app, user):
|
||||
|
||||
|
||||
def test_update_account_locked(run, app, user):
|
||||
result = run(cli.update_account, "--locked")
|
||||
result = run(cli.accounts.update_account, "--locked")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["locked"] is True
|
||||
|
||||
result = run(cli.update_account, "--no-locked")
|
||||
result = run(cli.accounts.update_account, "--no-locked")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -101,7 +101,7 @@ def test_update_account_locked(run, app, user):
|
||||
|
||||
|
||||
def test_update_account_bot(run, app, user):
|
||||
result = run(cli.update_account, "--bot")
|
||||
result = run(cli.accounts.update_account, "--bot")
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
@ -109,7 +109,7 @@ def test_update_account_bot(run, app, user):
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["bot"] is True
|
||||
|
||||
result = run(cli.update_account, "--no-bot")
|
||||
result = run(cli.accounts.update_account, "--no-bot")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -118,14 +118,14 @@ def test_update_account_bot(run, app, user):
|
||||
|
||||
|
||||
def test_update_account_discoverable(run, app, user):
|
||||
result = run(cli.update_account, "--discoverable")
|
||||
result = run(cli.accounts.update_account, "--discoverable")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["discoverable"] is True
|
||||
|
||||
result = run(cli.update_account, "--no-discoverable")
|
||||
result = run(cli.accounts.update_account, "--no-discoverable")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
@ -134,14 +134,14 @@ def test_update_account_discoverable(run, app, user):
|
||||
|
||||
|
||||
def test_update_account_sensitive(run, app, user):
|
||||
result = run(cli.update_account, "--sensitive")
|
||||
result = run(cli.accounts.update_account, "--sensitive")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
account = api.verify_credentials(app, user).json()
|
||||
assert account["source"]["sensitive"] is True
|
||||
|
||||
result = run(cli.update_account, "--no-sensitive")
|
||||
result = run(cli.accounts.update_account, "--no-sensitive")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ Account updated"
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# flake8: noqa
|
||||
from toot.cli.base import cli, Context
|
||||
|
||||
from toot.cli.accounts import *
|
||||
from toot.cli.auth import *
|
||||
from toot.cli.lists import *
|
||||
from toot.cli.post import *
|
||||
from toot.cli.read import *
|
||||
from toot.cli.statuses import *
|
||||
from toot.cli.tags import *
|
||||
from toot.cli.timelines import *
|
||||
from toot.cli.tui import *
|
||||
from toot.cli import accounts
|
||||
from toot.cli import auth
|
||||
from toot.cli import lists
|
||||
from toot.cli import post
|
||||
from toot.cli import read
|
||||
from toot.cli import statuses
|
||||
from toot.cli import tags
|
||||
from toot.cli import timelines
|
||||
from toot.cli import tui
|
||||
|
Loading…
x
Reference in New Issue
Block a user