commit
45fd4a90af
|
@ -69,7 +69,7 @@ If you skip a lot of items (e.g. you skip direct messages) it may clutter your l
|
||||||
|
|
||||||
### Hide everything (--quiet)
|
### Hide everything (--quiet)
|
||||||
|
|
||||||
Use the `--quiet` or `-q` flag to suppress all logging except for the account name being checked and the number of toots deleted. Use the `-qq` flag to further suppress output for accounts with zero deleted toots. The `-qqq` flag will suppress all output. Exception messages will not be suppressed.
|
Use the `--quiet` or `-q` flag to suppress all logging except for the account name being checked and the number of toots deleted. Use the `-qq` flag to further suppress output for accounts with zero deleted toots. The `-qqq` flag will suppress all output. Exception messages will not be suppressed, other than `IndexError` when any account has no toots to check.
|
||||||
|
|
||||||
### Only archive deleted toots (--archive-deleted)
|
### Only archive deleted toots (--archive-deleted)
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,14 @@ def check_batch(config, options, mastodon, user_id, timeline, deleted_count=0):
|
||||||
print("---------------------------------------\n")
|
print("---------------------------------------\n")
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print("No toots found!\n")
|
if not options.quiet or options.quiet <= 1:
|
||||||
|
print(
|
||||||
|
"No toots found for "
|
||||||
|
+ config["username"]
|
||||||
|
+ "@"
|
||||||
|
+ config["base_url"]
|
||||||
|
+ ".\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_toots(config, options, retry_count=0):
|
def check_toots(config, options, retry_count=0):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "ephemetoot"
|
name = "ephemetoot"
|
||||||
version = "3.0.0"
|
version = "3.1.0"
|
||||||
description = "A command line tool to delete your old toots"
|
description = "A command line tool to delete your old toots"
|
||||||
authors = ["Hugh Rundle <ephemetoot@hugh.run>"]
|
authors = ["Hugh Rundle <ephemetoot@hugh.run>"]
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
|
@ -117,7 +117,7 @@ config_file = {
|
||||||
"days_to_keep": 14,
|
"days_to_keep": 14,
|
||||||
"keep_pinned": True,
|
"keep_pinned": True,
|
||||||
"toots_to_keep": [103996285277439262, 103976473612749097, 103877521458738491],
|
"toots_to_keep": [103996285277439262, 103976473612749097, 103877521458738491],
|
||||||
"visibility_to_keep": [None],
|
"visibility_to_keep": [],
|
||||||
"archive": "archive",
|
"archive": "archive",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +241,85 @@ def test_check_batch(capfd, monkeypatch):
|
||||||
output = capfd.readouterr().out.split("\n")
|
output = capfd.readouterr().out.split("\n")
|
||||||
assert output[0] == "Removed 10 toots for alice@test.social."
|
assert output[0] == "Removed 10 toots for alice@test.social."
|
||||||
|
|
||||||
|
def test_check_batch_quiet(capfd, monkeypatch):
|
||||||
|
config = config_file
|
||||||
|
options = Namespace(archive_deleted=False, quiet=1)
|
||||||
|
mastodon = Mocktodon()
|
||||||
|
user_id = "test_user_id"
|
||||||
|
timeline = mastodon.account_statuses(user_id=user_id, limit=2, max_id=0)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"ephemetoot.ephemetoot.process_toot",
|
||||||
|
lambda config, options, mastodon, deleted_count, toot: deleted_count + 1,
|
||||||
|
)
|
||||||
|
ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0)
|
||||||
|
# deleted_count should be 10
|
||||||
|
output = capfd.readouterr().out.split("\n")
|
||||||
|
assert output[0] == "Removed 10 toots for alice@test.social."
|
||||||
|
|
||||||
|
def test_check_batch_quiet_no_toots(capfd, monkeypatch):
|
||||||
|
config = config_file
|
||||||
|
options = Namespace(archive_deleted=False, quiet=2)
|
||||||
|
mastodon = Mocktodon()
|
||||||
|
user_id = "test_user_id"
|
||||||
|
# max_id is the last toot in our batch so this returns no toots
|
||||||
|
timeline = mastodon.account_statuses(user_id=user_id, limit=2, max_id=10)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"ephemetoot.ephemetoot.process_toot",
|
||||||
|
lambda config, options, mastodon, deleted_count, toot: deleted_count + 1,
|
||||||
|
)
|
||||||
|
# run check_batch
|
||||||
|
ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0)
|
||||||
|
# deleted_count should be 0 but with quiet=2 there should be not output
|
||||||
|
output = capfd.readouterr().out
|
||||||
|
assert output == ""
|
||||||
|
|
||||||
|
def test_check_batch_qq(capfd, monkeypatch):
|
||||||
|
config = config_file
|
||||||
|
options = Namespace(archive_deleted=False, quiet=2)
|
||||||
|
mastodon = Mocktodon()
|
||||||
|
user_id = "test_user_id"
|
||||||
|
timeline = mastodon.account_statuses(user_id=user_id, limit=2, max_id=0)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"ephemetoot.ephemetoot.process_toot",
|
||||||
|
lambda config, options, mastodon, deleted_count, toot: deleted_count + 1,
|
||||||
|
)
|
||||||
|
ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0)
|
||||||
|
# deleted_count should be 10 and message printed since there was a delete
|
||||||
|
output = capfd.readouterr().out.split("\n")
|
||||||
|
assert output[0] == "Removed 10 toots for alice@test.social."
|
||||||
|
|
||||||
|
def test_check_batch_qq_no_deletes(capfd, monkeypatch):
|
||||||
|
config = config_file
|
||||||
|
options = Namespace(archive_deleted=False, quiet=2)
|
||||||
|
mastodon = Mocktodon()
|
||||||
|
user_id = "quiet_user_id"
|
||||||
|
timeline = mastodon.account_statuses(user_id=user_id, limit=2, max_id=0)
|
||||||
|
# simulate no deletes occuring
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"ephemetoot.ephemetoot.process_toot",
|
||||||
|
lambda config, options, mastodon, deleted_count, toot: 0,
|
||||||
|
)
|
||||||
|
# run check_batch
|
||||||
|
ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0)
|
||||||
|
# deleted_count should be 0 with no message since quiet=2
|
||||||
|
output = capfd.readouterr().out
|
||||||
|
assert output == ""
|
||||||
|
|
||||||
|
def test_check_batch_qqq(capfd, monkeypatch):
|
||||||
|
config = config_file
|
||||||
|
options = Namespace(archive_deleted=False, quiet=3)
|
||||||
|
mastodon = Mocktodon()
|
||||||
|
user_id = "test_user_id"
|
||||||
|
timeline = mastodon.account_statuses(user_id=user_id, limit=2, max_id=0)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"ephemetoot.ephemetoot.process_toot",
|
||||||
|
lambda config, options, mastodon, deleted_count, toot: deleted_count + 1,
|
||||||
|
)
|
||||||
|
# run check_batch
|
||||||
|
ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0)
|
||||||
|
# deleted_count should be 10 and no message should be printed since quiet=3
|
||||||
|
output = capfd.readouterr().out
|
||||||
|
assert output == ""
|
||||||
|
|
||||||
def test_console_print(capfd):
|
def test_console_print(capfd):
|
||||||
ephemetoot.console_print(
|
ephemetoot.console_print(
|
||||||
|
@ -579,6 +658,6 @@ ephemetoot ==> 🥳 ==> 🧼 ==> 😇
|
||||||
-------------------------------
|
-------------------------------
|
||||||
You are using release: \033[92mvTEST_VERSION\033[0m
|
You are using release: \033[92mvTEST_VERSION\033[0m
|
||||||
The latest release is: \033[92mvLATEST_VERSION\033[0m
|
The latest release is: \033[92mvLATEST_VERSION\033[0m
|
||||||
To upgrade to the most recent version run \033[92mpip3 install --update ephemetoot\033[0m\n"""
|
To upgrade to the most recent version run \033[92mpip install --upgrade ephemetoot\033[0m\n"""
|
||||||
|
|
||||||
assert output == msg
|
assert output == msg
|
||||||
|
|
Loading…
Reference in New Issue