Skip to content

Commit b95a285

Browse files
committed
enable runscript tests
1 parent 9456d23 commit b95a285

File tree

6 files changed

+10
-25
lines changed

6 files changed

+10
-25
lines changed

src/ansys/geometry/core/modeler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,11 @@ def run_discovery_script_file(
455455

456456
# Check if API version is specified... if so, validate it
457457
if api_version is not None:
458-
if self.client.backend_type == BackendType.WINDOWS_SERVICE:
458+
if self.client.backend_type in (
459+
BackendType.WINDOWS_SERVICE,
460+
BackendType.CORE_WINDOWS,
461+
BackendType.CORE_LINUX,
462+
):
459463
self.client.log.warning(
460464
"The Ansys Geometry Service only supports "
461465
"scripts that are of its same API version."
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
doc = GetActiveWindow().Document
1+
doc = GetActiveDocument()
22
radius = MM(int(argsDict["radius"]))
33

44
sphere = Sphere.Create(Frame.World, radius)
@@ -8,6 +8,6 @@
88
b = Body.CreateSurfaceBody(sphere, box)
99
db = DesignBody.Create(doc.MainPart, "sphere", b)
1010

11-
numBodies = doc.MainPart.GetAllBodies().Count
11+
numBodies = doc.MainPart.Bodies.Count
1212

1313
result = {"numBodies": numBodies}
0 Bytes
Binary file not shown.

tests/integration/files/disco_scripts/simple_script.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Python Discovery Script
2+
import math
3+
24
doc = Document.Create()
35

46
sphere = Sphere.Create(
0 Bytes
Binary file not shown.

tests/integration/test_runscript.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@
3030
from ansys.geometry.core.math.point import Point2D
3131
from ansys.geometry.core.sketch import Sketch
3232

33-
from .conftest import DSCOSCRIPTS_FILES_DIR, skip_if_core_service
33+
from .conftest import DSCOSCRIPTS_FILES_DIR
3434

3535

3636
# Python (.py)
3737
def test_python_simple_script(modeler: Modeler):
38-
# Skip on CoreService
39-
skip_if_core_service(modeler, test_python_simple_script.__name__, "run_discovery_script_file")
40-
4138
result = modeler.run_discovery_script_file(DSCOSCRIPTS_FILES_DIR / "simple_script.py")
4239
pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE)
4340
pattern_doc = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.Document", re.IGNORECASE)
@@ -49,11 +46,6 @@ def test_python_simple_script(modeler: Modeler):
4946
def test_python_simple_script_ignore_api_version(
5047
modeler: Modeler, caplog: pytest.LogCaptureFixture
5148
):
52-
# Skip on CoreService
53-
skip_if_core_service(
54-
modeler, test_python_simple_script_ignore_api_version.__name__, "run_discovery_script_file"
55-
)
56-
5749
result = modeler.run_discovery_script_file(
5850
DSCOSCRIPTS_FILES_DIR / "simple_script.py",
5951
api_version=ApiVersions.LATEST,
@@ -73,18 +65,11 @@ def test_python_simple_script_ignore_api_version(
7365

7466

7567
def test_python_failing_script(modeler: Modeler):
76-
# Skip on CoreService
77-
skip_if_core_service(modeler, test_python_failing_script.__name__, "run_discovery_script_file")
7868
with pytest.raises(GeometryRuntimeError):
7969
modeler.run_discovery_script_file(DSCOSCRIPTS_FILES_DIR / "failing_script.py")
8070

8171

8272
def test_python_integrated_script(modeler: Modeler):
83-
# Skip on CoreService
84-
skip_if_core_service(
85-
modeler, test_python_integrated_script.__name__, "run_discovery_script_file"
86-
)
87-
8873
# Tests the workflow of creating a design in PyAnsys Geometry, modifying it with a script,
8974
# and continuing to use it in PyAnsys Geometry
9075

@@ -105,9 +90,6 @@ def test_python_integrated_script(modeler: Modeler):
10590

10691
# SpaceClaim (.scscript)
10792
def test_scscript_simple_script(modeler: Modeler):
108-
# Skip on CoreService
109-
skip_if_core_service(modeler, test_scscript_simple_script.__name__, "run_discovery_script_file")
110-
11193
result = modeler.run_discovery_script_file(DSCOSCRIPTS_FILES_DIR / "simple_script.scscript")
11294
assert len(result) == 2
11395
pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE)
@@ -119,9 +101,6 @@ def test_scscript_simple_script(modeler: Modeler):
119101

120102
# Discovery (.dscript)
121103
def test_dscript_simple_script(modeler: Modeler):
122-
# Skip on CoreService
123-
skip_if_core_service(modeler, test_dscript_simple_script.__name__, "run_discovery_script_file")
124-
125104
result = modeler.run_discovery_script_file(DSCOSCRIPTS_FILES_DIR / "simple_script.dscript")
126105
assert len(result) == 2
127106
pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE)

0 commit comments

Comments
 (0)