mirror of
https://github.com/hughrun/ephemetoot
synced 2025-02-16 19:50:35 +01:00
mock archive toot media response
This commit is contained in:
parent
8a2e3d37b1
commit
0c5667181b
BIN
tests/accomplished.jpg
Normal file
BIN
tests/accomplished.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
@ -134,6 +134,13 @@ class MockGitHub:
|
|||||||
return {"tag_name": "vLATEST_VERSION"}
|
return {"tag_name": "vLATEST_VERSION"}
|
||||||
|
|
||||||
|
|
||||||
|
# mock image call for archive
|
||||||
|
class MockMedia:
|
||||||
|
f = open('tests/accomplished.jpg', 'rb')
|
||||||
|
content = f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
# mock Mastodon
|
# mock Mastodon
|
||||||
class Mocktodon:
|
class Mocktodon:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -209,6 +216,13 @@ def mock_github_response(monkeypatch):
|
|||||||
monkeypatch.setattr(requests, "get", mock_get)
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mock_archive_response(monkeypatch):
|
||||||
|
def mock_get(*args, **kwargs):
|
||||||
|
return MockMedia()
|
||||||
|
|
||||||
|
monkeypatch.setattr(requests, "get", mock_get)
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# TESTS #
|
# TESTS #
|
||||||
########################
|
########################
|
||||||
@ -227,7 +241,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(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
|
||||||
config_file["archive_media"] = True
|
config_file["archive_media"] = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user