Skip to content

Commit

Permalink
dry out Cubit test machine indications
Browse files Browse the repository at this point in the history
  • Loading branch information
hovey committed Apr 24, 2024
1 parent d1d347e commit 523e7d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
18 changes: 18 additions & 0 deletions src/atmesh/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""This module stores constants values in a single location for the module."""

from typing import NamedTuple
import platform

import pytest


class Constants(NamedTuple):
Expand All @@ -9,3 +12,18 @@ class Constants(NamedTuple):
yml_schema_version = 1.6
module_name = "atmesh"
module_prompt = module_name + ">"
test_machines = ["atlas", "s1060600", "s1088757", "skybridge"]


def run_on_cubit_machine(func):
"""Only run on a machine that only has as Cubit installation."""

def wrapper_func():

current_machine = platform.uname().node.lower()
test_machines = [x.lower() for x in Constants().test_machines]

if current_machine not in test_machines:
pytest.skip("Only run on a test machine with Cubit installed.")

return wrapper_func
26 changes: 6 additions & 20 deletions tests/test_sculpt_stl_to_inp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
(.venv) ~/autotwin/mesh> arch -x86_64 pytest tests/test_sculpt_stl_to_inp.py --cov=src/atmesh --cov-report term-missing
"""


# import os
from pathlib import Path
import platform
Expand All @@ -19,6 +18,7 @@
import pytest

import atmesh.sculpt_stl_to_inp as translator
import atmesh.constants as cs


@pytest.fixture
Expand Down Expand Up @@ -104,18 +104,14 @@ def test_when_io_fails(tests_files_path):
assert error.typename == "OSError"


@pytest.mark.skipif(
("atlas" not in platform.uname().node.lower())
and ("1060600" not in platform.uname().node)
and ("1088757" not in platform.uname().node),
reason="Run on Atlas and local machines only.",
)
@cs.run_on_cubit_machine
def test_cubit_init():
"""Given a path to the Cubit/Sculpt binary, check that cubit.init and the
current working directory can be set to the path of the test script.
"""
# cubit_path = "/Applications/Cubit-16.06/Cubit.app/Contents/MacOS"
cubit_path = "/Applications/Cubit-16.08/Cubit.app/Contents/MacOS"
# cubit_path = "/Applications/Cubit-16.08/Cubit.app/Contents/MacOS"
cubit_path = "/Applications/Cubit-16.14/Cubit.app/Contents/MacOS"
sys.path.append(cubit_path)

print("Import cubit module initiatied:")
Expand All @@ -139,12 +135,7 @@ def test_cubit_init():
assert success


@pytest.mark.skipif(
("atlas" not in platform.uname().node.lower())
and ("1060600" not in platform.uname().node)
and ("1088757" not in platform.uname().node),
reason="Run on Atlas and local machines only.",
)
@cs.run_on_cubit_machine
def test_two_spheres(tests_files_path):
"""Two concentric spheres with centers located at the origin, with radius
length scale 5 (inner) and radius length scale 10 (outer), in two
Expand All @@ -159,12 +150,7 @@ def test_two_spheres(tests_files_path):
assert completed


# @pytest.mark.skipif(
# ("atlas" not in platform.uname().node.lower())
# and ("1060600" not in platform.uname().node)
# and ("1088757" not in platform.uname().node),
# reason="Run on Atlas and local machines only.",
# )
# @cs.run_on_cubit_machine
@pytest.mark.skip("work in progress")
def test_import_cubit_fails(tests_files_path):
"""Currently with CI/CD, we have no way to test Cubit and Sculpt, so test
Expand Down

0 comments on commit 523e7d5

Please sign in to comment.