Skip to content

Commit 46ca18a

Browse files
authored
feat: proper service-based testing (#798)
1 parent 0e4d100 commit 46ca18a

File tree

7 files changed

+17
-31
lines changed

7 files changed

+17
-31
lines changed

.github/workflows/ci_cd.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ jobs:
348348
# ALLOW_PLOTTING: true
349349
# with:
350350
# python-version: ${{ env.MAIN_PYTHON_VERSION }}
351-
# pytest-extra-args: "--service-os=linux"
352351
# checkout: false
353352

354353
- name: Upload integration test logs
@@ -559,7 +558,7 @@ jobs:
559558
ALLOW_PLOTTING: true
560559
with:
561560
python-version: ${{ env.MAIN_PYTHON_VERSION }}
562-
pytest-extra-args: "--service-os=linux --use-existing-service=yes"
561+
pytest-extra-args: "--use-existing-service=yes"
563562
checkout: false
564563
requires-xvfb: true
565564

.github/workflows/docker_test_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
ALLOW_PLOTTING: true
151151
with:
152152
python-version: ${{ env.MAIN_PYTHON_VERSION }}
153-
pytest-extra-args: "--service-os=linux --use-existing-service=yes"
153+
pytest-extra-args: "--use-existing-service=yes"
154154
checkout: false
155155
requires-xvfb: true
156156

.github/workflows/nightly_docker_test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ jobs:
128128
ALLOW_PLOTTING: true
129129
with:
130130
python-version: ${{ env.MAIN_PYTHON_VERSION }}
131-
pytest-extra-args: "--service-os=linux"
132131
requires-xvfb: true
133132

134133
- name: Stop the Geometry service

tests/conftest.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,13 @@ def pytest_addoption(parser):
2222
choices=("yes", "no"),
2323
)
2424

25-
parser.addoption(
26-
"--service-os",
27-
action="store",
28-
default="windows",
29-
help="Geometry service OS running. Options: 'windows' or 'linux'. By default, 'windows'.",
30-
choices=("windows", "linux"),
31-
)
32-
3325

3426
@pytest.fixture(scope="session")
3527
def use_existing_service(request):
3628
value: str = request.config.getoption("--use-existing-service")
3729
return True if value.lower() == "yes" else False
3830

3931

40-
@pytest.fixture(scope="session")
41-
def service_os(request):
42-
return request.config.getoption("--service-os")
43-
44-
4532
@pytest.fixture
4633
def fake_record():
4734
def inner_fake_record(

tests/integration/conftest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@
1515
import pyvista as pv
1616

1717
from ansys.geometry.core import Modeler
18+
from ansys.geometry.core.connection.backend import BackendType
1819
from ansys.geometry.core.connection.defaults import GEOMETRY_SERVICE_DOCKER_IMAGE
1920
from ansys.geometry.core.connection.local_instance import GeometryContainers, LocalDockerInstance
2021

2122
pv.OFF_SCREEN = True
2223

2324

24-
@pytest.fixture(scope="session")
25-
def skip_not_on_linux_service(service_os: str):
26-
if service_os == "linux":
27-
return pytest.skip("Implementation not available on Linux service.") # skip!
28-
29-
3025
@pytest.fixture(scope="session")
3126
def docker_instance(use_existing_service):
3227
# This will only have a value in case that:
@@ -121,3 +116,9 @@ def clean_plot_result_images():
121116
files = os.listdir(results_dir)
122117
for file in files:
123118
os.remove(Path(results_dir, file))
119+
120+
121+
@pytest.fixture(scope="session")
122+
def skip_not_on_linux_service(modeler: Modeler):
123+
if modeler.client.backend_type == BackendType.LINUX_SERVICE:
124+
return pytest.skip("Implementation not available on Linux service.") # skip!

tests/integration/test_design.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def test_bodies_translation(modeler: Modeler):
774774
)
775775

776776

777-
def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory, service_os: str):
777+
def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
778778
"""Test for downloading a design in multiple modes and verifying the correct
779779
download."""
780780

@@ -803,8 +803,8 @@ def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactor
803803

804804
design.save(file_location=file_save)
805805

806-
# Check for other exports
807-
if service_os == "windows":
806+
# Check for other exports - Windows backend...
807+
if modeler.client.backend_type != BackendType.LINUX_SERVICE:
808808
binary_parasolid_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.x_b"
809809
text_parasolid_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.x_t"
810810

@@ -825,11 +825,10 @@ def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactor
825825
# design.download(pmdb_file, DesignFileFormat.PMDB)
826826
# assert pmdb_file.exists()
827827

828-
elif service_os == "linux":
828+
# Linux backend...
829+
else:
829830
binary_parasolid_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.xmt_bin"
830831
text_parasolid_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.xmt_txt"
831-
else:
832-
raise Exception("Unable to determine the service operating system.")
833832

834833
fmd_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.fmd"
835834

tests/integration/test_design_import.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from ansys.geometry.core import Modeler
8+
from ansys.geometry.core.connection.backend import BackendType
89
from ansys.geometry.core.designer import Component, Design
910
from ansys.geometry.core.designer.design import DesignFileFormat
1011
from ansys.geometry.core.math import Plane, Point2D, Point3D, UnitVector3D, Vector3D
@@ -101,7 +102,7 @@ def test_design_import_simple_case(modeler: Modeler):
101102
_checker_method(read_design, design)
102103

103104

104-
def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory, service_os: str):
105+
def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
105106
"""Test creation of a component, saving it to a file, and loading it again to a
106107
second component and make sure they have the same properties."""
107108

@@ -152,7 +153,7 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory, s
152153
_checker_method(design, design2, True)
153154

154155
# Test HOOPS formats (Windows only)
155-
if service_os == "windows":
156+
if modeler.client.backend_type != BackendType.LINUX_SERVICE:
156157
# STEP
157158
file = tmp_path_factory.mktemp("test_design_import") / "two_cars.step"
158159
design.download(file, DesignFileFormat.STEP)

0 commit comments

Comments
 (0)