Spaces:
Sleeping
Sleeping
File size: 1,023 Bytes
5221a6c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | from __future__ import annotations
import zipfile
from PIL import Image
from tiff_to_gcode import generate_snake_path_gcode
def test_gcode_header_writes_presets_before_initial_aux_commands(tmp_path) -> None:
tiff_path = tmp_path / "slice_0000.tif"
Image.new("L", (1, 1), 0).save(tiff_path)
zip_path = tmp_path / "slices.zip"
with zipfile.ZipFile(zip_path, mode="w") as archive:
archive.write(tiff_path, arcname=tiff_path.name)
gcode_path = generate_snake_path_gcode(
zip_path,
shape_name="header_order",
pressure=25,
valve=7,
port=3,
)
lines = [
line.strip()
for line in gcode_path.read_text().splitlines()
if line.strip()
]
assert lines[0] == "G91"
assert lines[1].startswith("{preset}serialPort3.write(")
assert lines[2].startswith("{preset}serialPort3.write(")
assert lines[3].startswith("{aux_command}WAGO_ValveCommands(")
assert lines[4].startswith("{aux_command}WAGO_ValveCommands(")
|