2023-11-29 07:21:03 +01:00
|
|
|
from toot import cli
|
2023-11-28 11:50:44 +01:00
|
|
|
|
2023-03-30 11:48:54 +02:00
|
|
|
from tests.integration.conftest import register_account
|
|
|
|
|
|
|
|
|
|
|
|
def test_lists_empty(run):
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.list)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == "You have no lists defined."
|
2023-03-30 11:48:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_list_create_delete(run):
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.create, "banana")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == '✓ List "banana" created.'
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.list)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert "banana" in result.stdout
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.create, "mango")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == '✓ List "mango" created.'
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.list)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert "banana" in result.stdout
|
|
|
|
assert "mango" in result.stdout
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.delete, "banana")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == '✓ List "banana" deleted.'
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.list)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert "banana" not in result.stdout
|
|
|
|
assert "mango" in result.stdout
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.delete, "mango")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == '✓ List "mango" deleted.'
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.list)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == "You have no lists defined."
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.delete, "mango")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 1
|
|
|
|
assert result.stderr.strip() == "Error: List not found"
|
2023-03-30 12:31:04 +02:00
|
|
|
|
2023-03-30 11:48:54 +02:00
|
|
|
|
|
|
|
def test_list_add_remove(run, app):
|
|
|
|
acc = register_account(app)
|
2023-12-13 16:14:46 +01:00
|
|
|
run(cli.lists.create, "foo")
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.add, "foo", acc.username)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 1
|
|
|
|
assert result.stderr.strip() == f"Error: You must follow @{acc.username} before adding this account to a list."
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 14:16:30 +01:00
|
|
|
run(cli.accounts.follow, acc.username)
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.add, "foo", acc.username)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == f'✓ Added account "{acc.username}"'
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.accounts, "foo")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert acc.username in result.stdout
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-03-30 12:31:04 +02:00
|
|
|
# Account doesn't exist
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.add, "foo", "does_not_exist")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 1
|
|
|
|
assert result.stderr.strip() == "Error: Account not found"
|
2023-03-30 12:31:04 +02:00
|
|
|
|
|
|
|
# List doesn't exist
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.add, "does_not_exist", acc.username)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 1
|
|
|
|
assert result.stderr.strip() == "Error: List not found"
|
2023-03-30 12:31:04 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.remove, "foo", acc.username)
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == f'✓ Removed account "{acc.username}"'
|
2023-03-30 11:48:54 +02:00
|
|
|
|
2023-12-13 16:14:46 +01:00
|
|
|
result = run(cli.lists.accounts, "foo")
|
2023-11-29 07:21:03 +01:00
|
|
|
assert result.exit_code == 0
|
|
|
|
assert result.stdout.strip() == "This list has no accounts."
|