Skip to content

Commit e8d0f0d

Browse files
RyanJWardpre-commit-ci[bot]pyansys-ci-bot
authored
test: add fixture for running with tracker (#2120)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 2b95f88 commit e8d0f0d

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

.github/workflows/ci_cd.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,58 @@ jobs:
526526
docker logs ${{ env.GEO_CONT_NAME }}
527527
docker rm ${{ env.GEO_CONT_NAME }}
528528
529+
testing-min-reqs-tracker:
530+
name: Testing with minimum requirements with tracker
531+
needs: [smoke-tests]
532+
runs-on: ubuntu-latest
533+
env:
534+
ANSRV_GEO_IMAGE_MINREQS: 'ghcr.io/ansys/geometry:core-linux-latest'
535+
strategy:
536+
fail-fast: false
537+
matrix:
538+
python-version: ['3.10', '3.13']
539+
steps:
540+
- name: Set up headless display
541+
uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2
542+
543+
- name: Login in Github Container registry
544+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
545+
with:
546+
registry: ghcr.io
547+
username: ${{ github.actor }}
548+
password: ${{ secrets.GITHUB_TOKEN }}
549+
550+
- name: Checkout repository
551+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
552+
553+
- name: Setup Python ${{ matrix.python-version }}
554+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
555+
with:
556+
python-version: ${{ matrix.python-version }}
557+
558+
- name: Install minimum requirements with tracker
559+
run: |
560+
python -m pip install --upgrade pip
561+
pip install -e .[all,tests-minimal]
562+
pip install pytest
563+
564+
- name: Start Geometry service and verify start
565+
run: |
566+
docker pull ${{ env.ANSRV_GEO_IMAGE_MINREQS }}
567+
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_MINREQS }}
568+
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
569+
570+
- name: Run pytest
571+
run: |
572+
pytest -v --use-tracker=yes
573+
574+
- name: Stop the Geometry service
575+
if: always()
576+
run: |
577+
docker stop ${{ env.GEO_CONT_NAME }}
578+
docker logs ${{ env.GEO_CONT_NAME }}
579+
docker rm ${{ env.GEO_CONT_NAME }}
580+
529581
testing-no-graphics:
530582
name: Testing with minimum requirements (no graphics)
531583
needs: [smoke-tests]

doc/changelog.d/2120.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add fixture for running with tracker

tests/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ def pytest_addoption(parser):
4343
),
4444
choices=("yes", "no"),
4545
)
46+
parser.addoption(
47+
"--use-tracker",
48+
action="store",
49+
default="no",
50+
help=("Enable the tracker to update the design. Options: 'yes' or 'no'. By default, 'no'."),
51+
choices=("yes", "no"),
52+
)
4653

4754

4855
@pytest.fixture(scope="session")
@@ -51,6 +58,23 @@ def use_existing_service(request):
5158
return True if value.lower() == "yes" else False
5259

5360

61+
@pytest.fixture(scope="session", autouse=True)
62+
def use_tracker(request):
63+
"""Fixture to enable or disable the tracker."""
64+
value: str = request.config.getoption("--use-tracker", default="no") # Explicitly set default
65+
import ansys.geometry.core as pyansys_geometry
66+
67+
if value.lower() == "yes":
68+
pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN = True
69+
else:
70+
pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN = False
71+
72+
yield # This allows the test to run
73+
74+
# Revert the state after the test session
75+
pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN = False
76+
77+
5478
@pytest.fixture
5579
def fake_record():
5680
def inner_fake_record(

0 commit comments

Comments
 (0)