Add integration tests for lists

This commit is contained in:
Ivan Habunek 2023-03-30 11:48:54 +02:00
parent 8624ddb175
commit a19670d0c3
No known key found for this signature in database
GPG key ID: CDBD63C43A30BB95
2 changed files with 59 additions and 1 deletions

View file

@ -0,0 +1,58 @@
from toot import api
from tests.integration.conftest import register_account
def test_lists_empty(run):
out = run("lists")
assert out == "You have no lists defined."
def test_list_create_delete(run):
out = run("list_create", "banana")
assert out == '✓ List "banana" created.'
out = run("lists")
assert "banana" in out
out = run("list_create", "mango")
assert out == '✓ List "mango" created.'
out = run("lists")
assert "banana" in out
assert "mango" in out
out = run("list_delete", "banana")
assert out == '✓ List "banana" deleted.'
out = run("lists")
assert "banana" not in out
assert "mango" in out
out = run("list_delete", "mango")
assert out == '✓ List "mango" deleted.'
out = run("lists")
assert out == "You have no lists defined."
def test_list_add_remove(run, app):
acc = register_account(app)
run("list_create", "foo")
out = run("list_add", "foo", acc.username)
assert out == f"You must follow @{acc.username} before adding this account to a list."
run("follow", acc.username)
out = run("list_add", "foo", acc.username)
assert out == f'✓ Added account "{acc.username}"'
out = run("list_accounts", "foo")
assert acc.username in out
out = run("list_remove", "foo", acc.username)
assert out == f'✓ Removed account "{acc.username}"'
out = run("list_accounts", "foo")
assert out == "This list has no accounts."

View file

@ -241,8 +241,8 @@ def print_table(headers: List[str], data: List[List[str]]):
def print_list_accounts(accounts):
print_out("Accounts in list</green>:\n")
if accounts:
print_out("Accounts in list</green>:\n")
print_acct_list(accounts)
else:
print_out("This list has no accounts.")