| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | """Mock objects for postprocessor testing. |
| | |
| | This module provides mock objects that simulate FreeCAD CAM job structure |
| | without requiring disk I/O or loading actual FreeCAD documents. |
| | """ |
| |
|
| | import Path |
| |
|
| |
|
| | class MockTool: |
| | def __init__(self): |
| | self.ShapeName = "endmill" |
| |
|
| |
|
| | class MockToolController: |
| | """Mock ToolController for operations.""" |
| |
|
| | def __init__( |
| | self, |
| | tool_number=1, |
| | label="TC: Default Tool", |
| | spindle_speed=1000, |
| | spindle_dir="Forward", |
| | ): |
| | self.Tool = MockTool() |
| | self.ToolNumber = tool_number |
| | self.Label = label |
| | self.SpindleSpeed = spindle_speed |
| | self.SpindleDir = spindle_dir |
| | self.Name = f"TC{tool_number}" |
| |
|
| | |
| | self.Path = Path.Path() |
| | self.Path.addCommands( |
| | [Path.Command(f"M6 T{tool_number}"), Path.Command(f"M3 S{spindle_speed}")] |
| | ) |
| |
|
| | def InList(self): |
| | return [] |
| |
|
| |
|
| | class MockOperation: |
| | """Mock Operation object for testing postprocessors.""" |
| |
|
| | def __init__(self, name="Operation", label=None, tool_controller=None, active=True): |
| | self.Name = name |
| | self.Label = label or name |
| | self.Active = active |
| | self.ToolController = tool_controller |
| |
|
| | |
| | self.Path = Path.Path() |
| |
|
| | def InList(self): |
| | """Mock InList - operations belong to a job.""" |
| | return [] |
| |
|
| |
|
| | class MockStock: |
| | """Mock Stock object with BoundBox.""" |
| |
|
| | def __init__(self, xmin=0.0, xmax=100.0, ymin=0.0, ymax=100.0, zmin=0.0, zmax=10.0): |
| | self.Shape = type( |
| | "obj", |
| | (object,), |
| | { |
| | "BoundBox": type( |
| | "obj", |
| | (object,), |
| | { |
| | "XMin": xmin, |
| | "XMax": xmax, |
| | "YMin": ymin, |
| | "YMax": ymax, |
| | "ZMin": zmin, |
| | "ZMax": zmax, |
| | }, |
| | )() |
| | }, |
| | )() |
| |
|
| |
|
| | class MockSetupSheet: |
| | """Mock SetupSheet object.""" |
| |
|
| | def __init__(self, clearance_height=5.0, safe_height=3.0): |
| | self.ClearanceHeightOffset = type("obj", (object,), {"Value": clearance_height})() |
| | self.SafeHeightOffset = type("obj", (object,), {"Value": safe_height})() |
| |
|
| |
|
| | class MockJob: |
| | """Mock Job object for testing postprocessors.""" |
| |
|
| | def __init__(self): |
| | |
| | self.Stock = MockStock() |
| |
|
| | |
| | self.SetupSheet = MockSetupSheet() |
| |
|
| | |
| | self.Operations = type("obj", (object,), {"Group": []})() |
| |
|
| | |
| | self.Tools = type("obj", (object,), {"Group": []})() |
| |
|
| | |
| | self.Model = type("obj", (object,), {"Group": []})() |
| |
|
| | |
| | self.Label = "MockJob" |
| | self.PostProcessor = "" |
| | self.PostProcessorArgs = "" |
| | self.PostProcessorOutputFile = "" |
| | self.Fixtures = ["G54"] |
| | self.OrderOutputBy = "Tool" |
| | self.SplitOutput = False |
| |
|
| | def InList(self): |
| | """Mock InList for fixture setup.""" |
| | return [] |
| |
|
| |
|
| | def create_default_job_with_operation(): |
| | """Create a mock job with a default tool controller and operation. |
| | |
| | This is a convenience function for common test scenarios. |
| | Returns: (job, operation, tool_controller) |
| | """ |
| | job = MockJob() |
| |
|
| | |
| | tc = MockToolController(tool_number=1, label="TC: Default Tool", spindle_speed=1000) |
| | job.Tools.Group = [tc] |
| |
|
| | |
| | op = MockOperation(name="Profile", label="Profile", tool_controller=tc) |
| | job.Operations.Group = [op] |
| |
|
| | return job, op, tc |
| |
|