-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_step_codec.py
More file actions
87 lines (71 loc) · 1.99 KB
/
test_step_codec.py
File metadata and controls
87 lines (71 loc) · 1.99 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import sys
import tests.test_helpers as helpers
def test_step_codec():
"""
Basic test of the STEP codec plugin.
"""
test_file = helpers.get_test_file_location("cube.py")
command = [
sys.executable,
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
test_file,
]
out, err, exitcode = helpers.cli_call(command)
assert "ISO-10303-21;" in out.decode()
def test_step_codec_with_assembly():
"""
Tests that the STEP codec correctly handles a CadQuery Assembly,
exercising the assembly.save() code path instead of exporters.export().
"""
test_file = helpers.get_test_file_location("cube_assy.py")
command = [
sys.executable,
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
test_file,
]
out, err, exitcode = helpers.cli_call(command)
assert exitcode == 0
assert "ISO-10303-21;" in out.decode()
def test_step_codec_to_file(tmp_path):
"""
Tests that the STEP codec writes a valid file when --outfile is specified.
"""
test_file = helpers.get_test_file_location("cube.py")
out_path = tmp_path / "out.step"
command = [
sys.executable,
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
test_file,
"--outfile",
str(out_path),
]
out, err, exitcode = helpers.cli_call(command)
assert exitcode == 0
content = out_path.read_text()
assert content.startswith("ISO-10303-21;")
def test_step_codec_contains_geometry():
"""
Tests that the STEP output contains geometry data, not just the header.
"""
test_file = helpers.get_test_file_location("cube.py")
command = [
sys.executable,
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
test_file,
]
out, err, exitcode = helpers.cli_call(command)
assert exitcode == 0
content = out.decode()
assert "CLOSED_SHELL" in content