65 lines
1.2 KiB
Python
65 lines
1.2 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
|
|
; filament_colour = #DDDDDD
|
|
; prusaslicer_config = end
|
|
|
|
"""
|
|
)
|
|
== GcodeAnalysis(
|
|
max_x=100,
|
|
max_y=100,
|
|
max_z=100,
|
|
max_bed=100,
|
|
max_end=195,
|
|
filament="PETG",
|
|
color="#DDDDDD",
|
|
nozzle=1.0,
|
|
)
|
|
)
|