1
+ from unittest .mock import MagicMock
2
+ import unittest
3
+ from jigsawstack .exceptions import JigsawStackError
4
+ import jigsawstack
5
+ import pytest
6
+ import asyncio
7
+ import logging
8
+ import io
9
+
10
+ logging .basicConfig (level = logging .INFO )
11
+ logger = logging .getLogger (__name__ )
12
+
13
+ jigsaw = jigsawstack .JigsawStack ()
14
+ async_jigsaw = jigsawstack .AsyncJigsawStack ()
15
+
16
+
17
+ def test_image_generation_response ():
18
+ async def _test ():
19
+ client = jigsawstack .AsyncJigsawStack ()
20
+ try :
21
+ result = await client .image_generation ({
22
+ "prompt" : "A beautiful mountain landscape at sunset" ,
23
+ "aspect_ratio" : "16:9"
24
+ })
25
+ # Just check if we got some data back
26
+ assert result is not None
27
+ assert len (result ) > 0
28
+ except JigsawStackError as e :
29
+ pytest .fail (f"Unexpected JigsawStackError: { e } " )
30
+
31
+ asyncio .run (_test ())
32
+
33
+
34
+ def test_image_generation_with_advanced_config ():
35
+ async def _test ():
36
+ client = jigsawstack .AsyncJigsawStack ()
37
+ try :
38
+ result = await client .image_generation ({
39
+ "prompt" : "A beautiful mountain landscape at sunset" ,
40
+ "output_format" : "png" ,
41
+ "advance_config" : {
42
+ "negative_prompt" : "blurry, low quality" ,
43
+ "guidance" : 7 ,
44
+ "seed" : 42
45
+ }
46
+ })
47
+ # Just check if we got some data back
48
+ assert result is not None
49
+ assert len (result ) > 0
50
+ except JigsawStackError as e :
51
+ pytest .fail (f"Unexpected JigsawStackError: { e } " )
52
+
53
+ asyncio .run (_test ())
0 commit comments