Ejemplo n.º 1
0
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, toot, deleted_count: 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 [email protected]."
Ejemplo n.º 2
0
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, toot, deleted_count: 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 == ""
Ejemplo n.º 3
0
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, toot, deleted_count: 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 == ""
Ejemplo n.º 4
0
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, toot, deleted_count: 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 == ""
Ejemplo n.º 5
0
def test_check_batch(capfd, monkeypatch):
    config = config_file
    options = Namespace(archive_deleted=False)
    mastodon = Mocktodon()
    user_id = "test_user_id"
    # limit to 2 so check_batch calls itself for the last 8 toots
    timeline = mastodon.account_statuses(user_id=user_id, limit=2, max_id=0)
    # monkeypatch process_toot to add 1 to deleted_count and return
    # this simulates what would happen if the toot was being deleted
    monkeypatch.setattr(
        "ephemetoot.ephemetoot.process_toot",
        lambda config, options, mastodon, toot, deleted_count: deleted_count + 1,
    )
    # run check_batch
    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 [email protected]."