formatting with black

This commit is contained in:
Hugh Rundle 2024-05-19 12:35:19 +10:00
parent a3de1ecc85
commit 2e4bb69610
No known key found for this signature in database
GPG Key ID: A7E35779918253F9
3 changed files with 19 additions and 9 deletions

View File

@ -274,7 +274,6 @@ def version(vnum):
def schedule(options): def schedule(options):
""" """
Creates and loads a plist file for scheduled running with launchd. If --time flag is used, the scheduled time is set accordingly. Note that this is designed for use on MacOS. Creates and loads a plist file for scheduled running with launchd. If --time flag is used, the scheduled time is set accordingly. Note that this is designed for use on MacOS.
""" """

View File

@ -70,7 +70,7 @@ toot_dict = {
{ {
"id": 123456789987654321, "id": 123456789987654321,
"type": "image", "type": "image",
"url": "https://hugh.run/success/accomplished.jpg" "url": "https://hugh.run/success/accomplished.jpg",
} }
], ],
"mentions": [], "mentions": [],
@ -86,6 +86,7 @@ toot_dict = {
# NOTE: ensure values in the dict object are what you need: # NOTE: ensure values in the dict object are what you need:
# it can be mutated by any test before your test runs # it can be mutated by any test before your test runs
def dict2obj(d): def dict2obj(d):
# checking whether object d is a # checking whether object d is a
# instance of class list # instance of class list
@ -124,9 +125,10 @@ config_file = {
"toots_to_keep": [103996285277439262, 103976473612749097, 103877521458738491], "toots_to_keep": [103996285277439262, 103976473612749097, 103877521458738491],
"visibility_to_keep": [], "visibility_to_keep": [],
"archive": "archive", "archive": "archive",
"archive_media": False "archive_media": False,
} }
# mock GitHub API call for the version number # mock GitHub API call for the version number
class MockGitHub: class MockGitHub:
@staticmethod @staticmethod
@ -136,7 +138,7 @@ class MockGitHub:
# mock image call for archive # mock image call for archive
class MockMedia: class MockMedia:
f = open('tests/accomplished.jpg', 'rb') f = open("tests/accomplished.jpg", "rb")
content = f.read() content = f.read()
f.close() f.close()
@ -223,6 +225,7 @@ def mock_archive_response(monkeypatch):
monkeypatch.setattr(requests, "get", mock_get) monkeypatch.setattr(requests, "get", mock_get)
######################## ########################
# TESTS # # TESTS #
######################## ########################
@ -241,6 +244,7 @@ def test_archive_toot(tmpdir):
file_exists = os.path.exists(p + "/104136090490756999.json") file_exists = os.path.exists(p + "/104136090490756999.json")
assert file_exists assert file_exists
def test_archive_toot_media(mock_archive_response, tmpdir): def test_archive_toot_media(mock_archive_response, tmpdir):
p = tmpdir.mkdir("archive") p = tmpdir.mkdir("archive")
config_file["archive"] = str(p) # make archive directory a temp test dir config_file["archive"] = str(p) # make archive directory a temp test dir
@ -250,6 +254,7 @@ def test_archive_toot_media(mock_archive_response, tmpdir):
config_file["archive_media"] = False config_file["archive_media"] = False
assert image_exists assert image_exists
def test_check_batch(capfd, monkeypatch): def test_check_batch(capfd, monkeypatch):
config = config_file config = config_file
options = Namespace(archive_deleted=False) options = Namespace(archive_deleted=False)
@ -269,6 +274,7 @@ 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): def test_check_batch_quiet(capfd, monkeypatch):
config = config_file config = config_file
options = Namespace(archive_deleted=False, quiet=1) options = Namespace(archive_deleted=False, quiet=1)
@ -284,6 +290,7 @@ def test_check_batch_quiet(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_no_toots(capfd, monkeypatch): def test_check_batch_quiet_no_toots(capfd, monkeypatch):
config = config_file config = config_file
options = Namespace(archive_deleted=False, quiet=2) options = Namespace(archive_deleted=False, quiet=2)
@ -301,6 +308,7 @@ def test_check_batch_quiet_no_toots(capfd, monkeypatch):
output = capfd.readouterr().out output = capfd.readouterr().out
assert output == "" assert output == ""
def test_check_batch_qq(capfd, monkeypatch): def test_check_batch_qq(capfd, monkeypatch):
config = config_file config = config_file
options = Namespace(archive_deleted=False, quiet=2) options = Namespace(archive_deleted=False, quiet=2)
@ -316,6 +324,7 @@ def test_check_batch_qq(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_qq_no_deletes(capfd, monkeypatch): def test_check_batch_qq_no_deletes(capfd, monkeypatch):
config = config_file config = config_file
options = Namespace(archive_deleted=False, quiet=2) options = Namespace(archive_deleted=False, quiet=2)
@ -333,6 +342,7 @@ def test_check_batch_qq_no_deletes(capfd, monkeypatch):
output = capfd.readouterr().out output = capfd.readouterr().out
assert output == "" assert output == ""
def test_check_batch_qqq(capfd, monkeypatch): def test_check_batch_qqq(capfd, monkeypatch):
config = config_file config = config_file
options = Namespace(archive_deleted=False, quiet=3) options = Namespace(archive_deleted=False, quiet=3)
@ -349,6 +359,7 @@ def test_check_batch_qqq(capfd, monkeypatch):
output = capfd.readouterr().out output = capfd.readouterr().out
assert output == "" assert output == ""
def test_console_print(capfd): def test_console_print(capfd):
ephemetoot.console_print( ephemetoot.console_print(
"test123", Namespace(test=False, hide_skipped=False, quiet=False), False "test123", Namespace(test=False, hide_skipped=False, quiet=False), False