source/projects/tentacles/test/test_gcode.py

56 lines
1 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import re
from gcode import (
analyze_gcode_str,
GcodeAnalysis,
2023-07-09 03:00:25 +00:00
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
2023-07-08 23:35:17 +00:00
; nozzle_diameter = 1.0
; prusaslicer_config = end
"""
)
2023-07-08 23:35:17 +00:00
== GcodeAnalysis(100, 100, 100, 100, 195, "PETG", 1.0)
)