|
24 | 24 | from pathlib import Path
|
25 | 25 |
|
26 | 26 | import numpy as np
|
| 27 | +import pytest |
27 | 28 |
|
| 29 | +from ansys.geometry.core.designer.geometry_commands import GeometryCommands |
| 30 | +from ansys.geometry.core.errors import GeometryRuntimeError |
28 | 31 | from ansys.geometry.core.math import (
|
29 | 32 | UNITVECTOR3D_X,
|
30 | 33 | UNITVECTOR3D_Y,
|
|
37 | 40 | from ansys.geometry.core.misc import DEFAULT_UNITS, UNITS, Angle, Distance
|
38 | 41 | from ansys.geometry.core.modeler import Modeler
|
39 | 42 | from ansys.geometry.core.sketch import Sketch
|
| 43 | +from ansys.geometry.core.tools import ( |
| 44 | + MeasurementTools, |
| 45 | + PrepareTools, |
| 46 | + RepairTools, |
| 47 | + UnsupportedCommands, |
| 48 | +) |
40 | 49 |
|
41 | 50 | from .conftest import FILES_DIR
|
42 | 51 |
|
@@ -325,3 +334,40 @@ def test_issue_1813_edge_start_end_non_default_units(modeler: Modeler):
|
325 | 334 | finally:
|
326 | 335 | # Reset the default units to meters
|
327 | 336 | DEFAULT_UNITS.LENGTH = UNITS.meter
|
| 337 | + |
| 338 | + |
| 339 | +def test_issue_2184_prevent_raw_instantiation_of_tools_and_commands(): |
| 340 | + """Test that raw instantiation of tools and commands is prevented. |
| 341 | +
|
| 342 | + For more info see |
| 343 | + https://github.com/ansys/pyansys-geometry/issues/2184 |
| 344 | + """ |
| 345 | + # Test UnsupportedCommands |
| 346 | + with pytest.raises( |
| 347 | + GeometryRuntimeError, match="UnsupportedCommands should not be instantiated directly" |
| 348 | + ): |
| 349 | + UnsupportedCommands(None, None) |
| 350 | + |
| 351 | + # Test RepairTools |
| 352 | + with pytest.raises( |
| 353 | + GeometryRuntimeError, match="RepairTools should not be instantiated directly" |
| 354 | + ): |
| 355 | + RepairTools(None, None) |
| 356 | + |
| 357 | + # Test PrepareTools |
| 358 | + with pytest.raises( |
| 359 | + GeometryRuntimeError, match="PrepareTools should not be instantiated directly" |
| 360 | + ): |
| 361 | + PrepareTools(None) |
| 362 | + |
| 363 | + # Test MeasurementTools |
| 364 | + with pytest.raises( |
| 365 | + GeometryRuntimeError, match="MeasurementTools should not be instantiated directly" |
| 366 | + ): |
| 367 | + MeasurementTools(None) |
| 368 | + |
| 369 | + # Test GeometryCommands |
| 370 | + with pytest.raises( |
| 371 | + GeometryRuntimeError, match="GeometryCommands should not be instantiated directly" |
| 372 | + ): |
| 373 | + GeometryCommands(None) |
0 commit comments