1+ import os
12import tests .test_helpers as helpers
23
34def test_stl_codec ():
@@ -9,4 +10,25 @@ def test_stl_codec():
910 command = ["python" , "cq-cli.py" , "--codec" , "stl" , "--infile" , test_file ]
1011 out , err , exitcode = helpers .cli_call (command )
1112
12- assert out .decode ().split ('\n ' )[0 ].replace ('\r ' , '' ) == "solid "
13+ assert out .decode ().split ('\n ' )[0 ].replace ('\r ' , '' ) == "solid "
14+
15+ def test_stl_codec_quality ():
16+ """
17+ Test of the STL codec plugin's ability to adjust the quality of the resulting STL.
18+ """
19+ test_file = helpers .get_test_file_location ("sphere.py" )
20+
21+ command = ["python" , "cq-cli.py" , "--codec" , "stl" , "--infile" , test_file , "--outfile" , "/tmp/high.stl" ]
22+ out , err , exitcode = helpers .cli_call (command )
23+
24+ # Keep track of the number of lines for each STL as an approximate measure of quality
25+ high_detail = os .path .getsize ("/tmp/high.stl" )
26+
27+ # Attempt to adjust the quality of the resulting STL
28+ command2 = ["python" , "cq-cli.py" , "--codec" , "stl" , "--infile" , test_file , "--outfile" , "/tmp/low.stl" , "--outputopts" , "linearDeflection:0.3;angularDeflection:0.3" ]
29+ out2 , err2 , exitcode2 = helpers .cli_call (command2 )
30+
31+ # Keep track of the number of lines in the STL as an approximate measure of quality
32+ low_detail = os .path .getsize ("/tmp/low.stl" )
33+
34+ assert low_detail < high_detail
0 commit comments