source/projects/tentacles/test/test_gcode.py

55 lines
1 KiB
Python

#!/usr/bin/env python3
import re
from gcode import (
analyze_gcode_str,
GcodeAnalysis,
OPTION_PATTERN,
parse_prusa_config_str,
)
def test_option_pattern():
assert re.match(OPTION_PATTERN, "\n") is None
assert re.findall(OPTION_PATTERN, "; foo = bar\n")
assert re.findall(OPTION_PATTERN, "; foo = bar\n; baz = qux")
def test_parse_config_str():
assert parse_prusa_config_str("") == {}
assert (
parse_prusa_config_str(
"""
; prusaslicer_config = begin
; foo = bar
; prusaslicer_config = end
"""
)
== {"foo": "bar"}
)
def test_analyze_gcode():
assert (
analyze_gcode_str(
"""
gcode garbage
; some comment
more garbage
; prusaslicer_config = begin
; bed_shape = 5x5,95x5,95x95,5x95
; max_print_height = 100
; first_layer_bed_temperature = 100
; first_layer_temperature = 195
; filament_type = PETG
; nozzle_diameter = 1.0
; prusaslicer_config = end
"""
)
== GcodeAnalysis(100, 100, 100, 100, 195, "PETG", 1.0)
)