mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-22 04:25:55 -04:00
Change toot tags
to toot tags followed
This commit is contained in:
parent
a0caa88ffe
commit
743dfd715e
@ -3,7 +3,7 @@ from toot.entities import Tag, from_dict, from_dict_list
|
||||
|
||||
|
||||
def test_tags(run, base_url):
|
||||
result = run(cli.tags)
|
||||
result = run(cli.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "You're not following any hashtags."
|
||||
|
||||
@ -11,7 +11,7 @@ def test_tags(run, base_url):
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are now following #foo"
|
||||
|
||||
result = run(cli.tags)
|
||||
result = run(cli.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f"* #foo\t{base_url}/tags/foo"
|
||||
|
||||
@ -19,7 +19,7 @@ def test_tags(run, base_url):
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are now following #bar"
|
||||
|
||||
result = run(cli.tags)
|
||||
result = run(cli.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "\n".join([
|
||||
f"* #bar\t{base_url}/tags/bar",
|
||||
@ -30,7 +30,7 @@ def test_tags(run, base_url):
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are no longer following #foo"
|
||||
|
||||
result = run(cli.tags)
|
||||
result = run(cli.tags, "followed")
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == f"* #bar\t{base_url}/tags/bar"
|
||||
|
||||
@ -38,13 +38,13 @@ def test_tags(run, base_url):
|
||||
assert result.exit_code == 0
|
||||
assert result.stdout.strip() == "✓ You are no longer following #bar"
|
||||
|
||||
result = run(cli.tags)
|
||||
result = run(cli.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, "--json")
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
assert result == []
|
||||
|
||||
result = run_json(cli.tags, "follow", "foo", "--json")
|
||||
@ -52,7 +52,7 @@ def test_tags_json(run_json):
|
||||
assert tag.name == "foo"
|
||||
assert tag.following is True
|
||||
|
||||
result = run_json(cli.tags, "--json")
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
[tag] = from_dict_list(Tag, result)
|
||||
assert tag.name == "foo"
|
||||
assert tag.following is True
|
||||
@ -62,7 +62,7 @@ def test_tags_json(run_json):
|
||||
assert tag.name == "bar"
|
||||
assert tag.following is True
|
||||
|
||||
result = run_json(cli.tags, "--json")
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
tags = from_dict_list(Tag, result)
|
||||
[bar, foo] = sorted(tags, key=lambda t: t.name)
|
||||
assert foo.name == "foo"
|
||||
@ -80,5 +80,5 @@ def test_tags_json(run_json):
|
||||
assert tag.name == "bar"
|
||||
assert tag.following is False
|
||||
|
||||
result = run_json(cli.tags, "--json")
|
||||
result = run_json(cli.tags, "followed", "--json")
|
||||
assert result == []
|
||||
|
@ -6,15 +6,17 @@ from toot.cli.base import cli, pass_context, json_option, Context
|
||||
from toot.output import print_tag_list, print_warning
|
||||
|
||||
|
||||
@cli.group(invoke_without_command=True)
|
||||
@json_option
|
||||
@click.pass_context
|
||||
def tags(ctx: click.Context, json):
|
||||
"""List, follow, and unfollow tags
|
||||
@cli.group()
|
||||
def tags():
|
||||
"""List, follow, and unfollow tags"""
|
||||
|
||||
When invoked without a command, lists followed tags."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
tags = api.followed_tags(ctx.obj.app, ctx.obj.user)
|
||||
|
||||
@tags.command()
|
||||
@json_option
|
||||
@pass_context
|
||||
def followed(ctx: Context, json: bool):
|
||||
"""List followed tags"""
|
||||
tags = api.followed_tags(ctx.app, ctx.user)
|
||||
if json:
|
||||
click.echo(pyjson.dumps(tags))
|
||||
else:
|
||||
@ -55,7 +57,7 @@ def unfollow(ctx: Context, tag: str, json: bool):
|
||||
@pass_context
|
||||
def tags_followed(ctx: Context):
|
||||
"""List hashtags you follow"""
|
||||
print_warning("`toot tags_followed` is deprecated in favour of `toot tags`")
|
||||
print_warning("`toot tags_followed` is deprecated in favour of `toot tags followed`")
|
||||
response = api.followed_tags(ctx.app, ctx.user)
|
||||
print_tag_list(response)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user