Skip to content

Commit

Permalink
Expand tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Jan 2, 2023
1 parent a83c352 commit 15d377e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test:
coverage:
coverage erase
coverage run
coverage html
coverage report

clean :
Expand Down
65 changes: 65 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,71 @@ def test_follow_not_found(run):
assert str(ex_info.value) == "Account not found"


def test_mute(app, user, friend, run):
out = run("mute", friend.username)
assert out == f"✓ You have muted {friend.username}"

[muted_account] = api.get_muted_accounts(app, user)
assert muted_account["acct"] == friend.username

out = run("unmute", friend.username)
assert out == f"✓ {friend.username} is no longer muted"

assert api.get_muted_accounts(app, user) == []


def test_block(app, user, friend, run):
out = run("block", friend.username)
assert out == f"✓ You are now blocking {friend.username}"

[blockd_account] = api.get_blocked_accounts(app, user)
assert blockd_account["acct"] == friend.username

out = run("unblock", friend.username)
assert out == f"✓ {friend.username} is no longer blocked"

assert api.get_blocked_accounts(app, user) == []


def test_following_followers(user, friend, run):
out = run("following", user.username)
assert out == ""

run("follow", friend.username)

out = run("following", user.username)
assert out == f"* @{friend.username}"

out = run("followers", friend.username)
assert out == f"* @{user.username}"


def test_tags(run):
out = run("tags_followed")
assert out == "You're not following any hashtags."

out = run("tags_follow", "foo")
assert out == "✓ You are now following #foo"

out = run("tags_followed")
assert out == "* #foo\thttp://localhost:3000/tags/foo"

out = run("tags_follow", "bar")
assert out == "✓ You are now following #bar"

out = run("tags_followed")
assert out == "\n".join([
"* #bar\thttp://localhost:3000/tags/bar",
"* #foo\thttp://localhost:3000/tags/foo",
])

out = run("tags_unfollow", "foo")
assert out == "✓ You are no longer following #foo"

out = run("tags_followed")
assert out == "* #bar\thttp://localhost:3000/tags/bar"


# ------------------------------------------------------------------------------
# Utils
# ------------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions toot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def create_app(domain, scheme='https'):
return http.anon_post(url, json=json).json()


def get_muted_accounts(app, user):
return http.get(app, user, "/api/v1/mutes").json()


def get_blocked_accounts(app, user):
return http.get(app, user, "/api/v1/blocks").json()


def register_account(app, username, email, password, locale="en", agreement=True):
"""
Register an account
Expand Down
2 changes: 1 addition & 1 deletion toot/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def print_acct_list(accounts):
def print_tag_list(tags):
if tags:
for tag in tags:
print_out(f"* <green>#{tag['name']}\t</green> {tag['url']}")
print_out(f"* <green>#{tag['name']}\t</green>{tag['url']}")
else:
print_out("You're not following any hashtags.")

Expand Down

0 comments on commit 15d377e

Please sign in to comment.