@@ -106,6 +106,34 @@ def test_generate_preview(client):
106106 verify_image (response .data , 'tests/simple.png' )
107107
108108
109+ def test_generate_preview_high_res (client ):
110+ data = EXAMPLE_FORMDATA .copy ()
111+ data ['high_res' ] = 1
112+ data ['text' ] = json .dumps ([
113+ {
114+ 'family' : 'DejaVu Sans' ,
115+ 'style' : 'Book' ,
116+ 'text' : 'Left' ,
117+ 'size' : '60' ,
118+ 'align' : 'left'
119+ },
120+ {
121+ 'family' : 'Droid Sans Mono' ,
122+ 'style' : 'Regular' ,
123+ 'text' : '-- LONG MONO TEXT --' ,
124+ 'size' : '50' ,
125+ 'align' : 'center'
126+ }
127+ ])
128+
129+ response = client .post ('/labeldesigner/api/preview' , data = data )
130+ assert response .status_code == 200
131+ assert response .content_type in ['image/png' ]
132+
133+ # Check image
134+ verify_image (response .data , 'tests/simple_high_res.png' )
135+
136+
109137def test_generate_preview_inverted (client ):
110138 data = EXAMPLE_FORMDATA .copy ()
111139 data ['text' ] = json .dumps ([
@@ -260,8 +288,13 @@ def test_generate_qr(client):
260288 verify_image (response .data , 'tests/qr.png' )
261289
262290
263- def image_test (client , image_path : str = "tests/_demo_image.jpg" , rotated : bool = False , fit : bool = False , text : bool = False , image_mode : str = "grayscale" ):
291+ def image_test (client , image_path : str | None = None , rotated : bool = False , fit : bool = False , text : bool = False , image_mode : str = "grayscale" , high_res : bool = False ):
264292 data = EXAMPLE_FORMDATA .copy ()
293+ if image_path is None :
294+ if high_res :
295+ image_path = "tests/_demo_image_highres.jpg"
296+ else :
297+ image_path = "tests/_demo_image.jpg"
265298 my_file = FileStorage (
266299 stream = open (image_path , "rb" ),
267300 filename = os .path .basename (image_path ),
@@ -270,6 +303,7 @@ def image_test(client, image_path: str = "tests/_demo_image.jpg", rotated: bool
270303 data ['print_type' ] = 'image'
271304 data ['image' ] = my_file
272305 data ['image_mode' ] = image_mode
306+ data ['high_res' ] = 1 if high_res else 0
273307
274308 if image_mode == "black" :
275309 data ['image_bw_threshold' ] = '128'
@@ -287,7 +321,7 @@ def image_test(client, image_path: str = "tests/_demo_image.jpg", rotated: bool
287321 }
288322 ])
289323
290- expected_img_path = "tests/image" + ("_rotated" if rotated else "" ) + ("_fit" if fit else "" ) + ("_text" if text else "" ) + "_" + image_mode + ".png"
324+ expected_img_path = "tests/image" + ("_rotated" if rotated else "" ) + ("_fit" if fit else "" ) + ("_text" if text else "" ) + ( "_highres" if high_res else "" ) + "_" + image_mode + ".png"
291325
292326 response = client .post ('/labeldesigner/api/preview' , data = data )
293327 assert response .status_code == 200
@@ -341,6 +375,14 @@ def test_image_black_fit(client):
341375 image_test (client , image_mode = "black" , fit = True )
342376
343377
378+ def test_image_highres (client ):
379+ image_test (client , high_res = True )
380+
381+
382+ def test_image_highres_fit (client ):
383+ image_test (client , high_res = True , fit = True )
384+
385+
344386def test_generate_template (client ):
345387 data = EXAMPLE_FORMDATA .copy ()
346388 # Mock current datetime.now
0 commit comments