Test all the edge cases of the STEP export function.
(tmpdir)
| 836 | |
| 837 | |
| 838 | def test_meta_step_export_edge_cases(tmpdir): |
| 839 | """ |
| 840 | Test all the edge cases of the STEP export function. |
| 841 | """ |
| 842 | |
| 843 | # Create an assembly where the child is empty |
| 844 | assy = cq.Assembly(name="top-level") |
| 845 | subassy = cq.Assembly(name="second-level") |
| 846 | assy.add(subassy) |
| 847 | |
| 848 | with chdir(tmpdir): |
| 849 | # Write an assembly with no children |
| 850 | success = exportStepMeta(assy, "meta_edge_cases1.step") |
| 851 | assert success |
| 852 | |
| 853 | # Test an object with no color set |
| 854 | cube = cq.Workplane().box(10.0, 10.0, 10.0) |
| 855 | assy.add(cube, name="cube") |
| 856 | success = exportStepMeta(assy, "meta_edge_cases2.step") |
| 857 | assert success |
| 858 | |
| 859 | # Tag a face that does not match the object |
| 860 | with pytest.raises(ValueError): |
| 861 | assy.addSubshape(plane(1, 1), name="cube_top_face") |
| 862 | |
| 863 | # Tag the name but nothing else |
| 864 | assy.addSubshape(cube.faces(">Z").val(), name="cube_top_face") |
| 865 | success = exportStepMeta(assy, "meta_edge_cases3.step") |
| 866 | assert success |
| 867 | |
| 868 | # Reset the assembly |
| 869 | assy.remove("cube") |
| 870 | cube = cq.Workplane().box(9.9, 9.9, 9.9) |
| 871 | assy.add(cube, name="cube") |
| 872 | |
| 873 | # Tag the color but nothing else |
| 874 | assy.addSubshape(cube.faces(">Z").val(), color=cq.Color(1.0, 0.0, 0.0)) |
| 875 | success = exportStepMeta(assy, "meta_edge_cases4.step") |
| 876 | assert success |
| 877 | |
| 878 | # Reset the assembly |
| 879 | assy.remove("cube") |
| 880 | cube = cq.Workplane().box(9.8, 9.8, 9.8) |
| 881 | assy.add(cube, name="cube") |
| 882 | |
| 883 | # Tag the layer but nothing else |
| 884 | assy.addSubshape(cube.faces(">Z").val(), layer="cube_top_face") |
| 885 | success = exportStepMeta(assy, "meta_edge_cases5.step") |
| 886 | assert success |
| 887 | |
| 888 | |
| 889 | @pytest.mark.parametrize("kind", ["step", "xml", "xbf"]) |
nothing calls this directly
no test coverage detected