Skip to content

Commit

Permalink
formatting with black
Browse files Browse the repository at this point in the history
  • Loading branch information
hughrun committed May 19, 2024
1 parent a3de1ec commit 2e4bb69
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from setuptools import setup

setup()
setup()
1 change: 0 additions & 1 deletion src/ephemetoot/ephemetoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def version(vnum):


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.
"""
Expand Down
25 changes: 18 additions & 7 deletions tests/test_ephemetoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
],
},
"media_attachments": [
{
"id": 123456789987654321,
"type": "image",
"url": "https://hugh.run/success/accomplished.jpg"
}
{
"id": 123456789987654321,
"type": "image",
"url": "https://hugh.run/success/accomplished.jpg",
}
],
"mentions": [],
"tags": [],
Expand All @@ -86,6 +86,7 @@
# NOTE: ensure values in the dict object are what you need:
# it can be mutated by any test before your test runs


def dict2obj(d):
# checking whether object d is a
# instance of class list
Expand Down Expand Up @@ -124,9 +125,10 @@ class C:
"toots_to_keep": [103996285277439262, 103976473612749097, 103877521458738491],
"visibility_to_keep": [],
"archive": "archive",
"archive_media": False
"archive_media": False,
}


# mock GitHub API call for the version number
class MockGitHub:
@staticmethod
Expand All @@ -136,7 +138,7 @@ def json():

# mock image call for archive
class MockMedia:
f = open('tests/accomplished.jpg', 'rb')
f = open("tests/accomplished.jpg", "rb")
content = f.read()
f.close()

Expand Down Expand Up @@ -223,6 +225,7 @@ def mock_get(*args, **kwargs):

monkeypatch.setattr(requests, "get", mock_get)


########################
# TESTS #
########################
Expand All @@ -241,6 +244,7 @@ def test_archive_toot(tmpdir):
file_exists = os.path.exists(p + "/104136090490756999.json")
assert file_exists


def test_archive_toot_media(mock_archive_response, tmpdir):
p = tmpdir.mkdir("archive")
config_file["archive"] = str(p) # make archive directory a temp test dir
Expand All @@ -250,6 +254,7 @@ def test_archive_toot_media(mock_archive_response, tmpdir):
config_file["archive_media"] = False
assert image_exists


def test_check_batch(capfd, monkeypatch):
config = config_file
options = Namespace(archive_deleted=False)
Expand All @@ -269,6 +274,7 @@ def test_check_batch(capfd, monkeypatch):
output = capfd.readouterr().out.split("\n")
assert output[0] == "Removed 10 toots for [email protected]."


def test_check_batch_quiet(capfd, monkeypatch):
config = config_file
options = Namespace(archive_deleted=False, quiet=1)
Expand All @@ -284,6 +290,7 @@ def test_check_batch_quiet(capfd, monkeypatch):
output = capfd.readouterr().out.split("\n")
assert output[0] == "Removed 10 toots for [email protected]."


def test_check_batch_quiet_no_toots(capfd, monkeypatch):
config = config_file
options = Namespace(archive_deleted=False, quiet=2)
Expand All @@ -301,6 +308,7 @@ def test_check_batch_quiet_no_toots(capfd, monkeypatch):
output = capfd.readouterr().out
assert output == ""


def test_check_batch_qq(capfd, monkeypatch):
config = config_file
options = Namespace(archive_deleted=False, quiet=2)
Expand All @@ -316,6 +324,7 @@ def test_check_batch_qq(capfd, monkeypatch):
output = capfd.readouterr().out.split("\n")
assert output[0] == "Removed 10 toots for [email protected]."


def test_check_batch_qq_no_deletes(capfd, monkeypatch):
config = config_file
options = Namespace(archive_deleted=False, quiet=2)
Expand All @@ -333,6 +342,7 @@ def test_check_batch_qq_no_deletes(capfd, monkeypatch):
output = capfd.readouterr().out
assert output == ""


def test_check_batch_qqq(capfd, monkeypatch):
config = config_file
options = Namespace(archive_deleted=False, quiet=3)
Expand All @@ -349,6 +359,7 @@ def test_check_batch_qqq(capfd, monkeypatch):
output = capfd.readouterr().out
assert output == ""


def test_console_print(capfd):
ephemetoot.console_print(
"test123", Namespace(test=False, hide_skipped=False, quiet=False), False
Expand Down

0 comments on commit 2e4bb69

Please sign in to comment.