Repository navigation
Expand file tree
/
Copy pathgdecoder_test.py
More file actions
59 lines (45 loc) · 1.93 KB
/
Copy pathgdecoder_test.py
File metadata and controls
59 lines (45 loc) · 1.93 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# test gdecoder.py with some example files
from gdecoder import gdecoder
from gdecoder import parse_args
import pathlib
import pytest
pytestmark = pytest.mark.integration
def create_args_emulation_with_defaults(input_file):
class ArgsEmulation:
pass
ArgsEmulation.input = str(input_file)
# settings for maximum output -> crashes becomes most likely in the test
ArgsEmulation.stopOnUndecoded = True
ArgsEmulation.hideComments = False
ArgsEmulation.hideGCode = False
ArgsEmulation.hideDecoded = False
ArgsEmulation.hideSummary = False
# using verbose is very slow when using "real world" gcode files -> don't show by default
ArgsEmulation.showVerbose = False
return ArgsEmulation
# test all .gcode files in the examples_synthetic folder
def pytest_generate_tests(metafunc):
if "synthetic_input_file" in metafunc.fixturenames:
metafunc.parametrize("synthetic_input_file", pathlib.Path().glob("./examples_synthetic/*.gcode"))
def test_gcode_in_examples_synthetic_folder(synthetic_input_file):
args_emulation = create_args_emulation_with_defaults(synthetic_input_file)
args_emulation.showVerbose = True
gdecoder(args_emulation)
def test_parser_all_optional_parameters_unused():
parser = parse_args(['-i', 'abc'])
assert(parser.input == "abc")
assert(parser.hideSummary is False)
assert(parser.hideComments is False)
assert(parser.hideGCode is False)
assert(parser.hideDecoded is False)
assert(parser.showVerbose is False)
assert(parser.stopOnUndecoded is False)
def test_parser_all_optional_parameters_used():
parser = parse_args(['-i', 'abc', "-s", "-c", "-g", "-d", "-v", "-u"])
assert(parser.input == "abc")
assert(parser.hideSummary is True)
assert(parser.hideComments is True)
assert(parser.hideGCode is True)
assert(parser.hideDecoded is True)
assert(parser.showVerbose is True)
assert(parser.stopOnUndecoded is True)