fix(upload): target image host API
This commit is contained in:
1 parent
12e9de9ba4
commit
c3358f3f66
7 files changed
+55
-29
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.belki.image_host import ImageHostClient, ImageHostError
|
||||
|
||||
|
||||
class ImageHostClientTests(unittest.TestCase):
|
||||
def test_upload_wraps_presigned_put_failure(self) -> None:
|
||||
client = ImageHostClient(api_url="https://api.example.test")
|
||||
with patch.object(client, "_request_json", return_value={"files": [{"uploadUrl": "https://storage.example.test/upload"}]}):
|
||||
with patch("app.belki.image_host.urlopen", side_effect=OSError("network unavailable")):
|
||||
with self.assertRaisesRegex(ImageHostError, "image host upload failed"):
|
||||
client.upload_bytes(b"image", "screenshot.jpg")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user