Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code cov #77

Merged
merged 52 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7996a1e
Testing version installed
fingeraugusto Jul 5, 2024
061ff7d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
5c27e5f
Fix global
fingeraugusto Jul 5, 2024
66acbf4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
b53306b
Fixed import
fingeraugusto Jul 5, 2024
1c20390
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
a346389
Another small fix
fingeraugusto Jul 5, 2024
130aa3a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
a76ff2e
another small fix
fingeraugusto Jul 5, 2024
8660ed9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
7b3548b
Add exporttoolkit test
fingeraugusto Jul 8, 2024
d3325d6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2024
5bc1497
Fix some leftovers
fingeraugusto Jul 8, 2024
5e4b681
Fixed test
fingeraugusto Jul 9, 2024
4a441a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2024
69b6e76
test tinkering
fingeraugusto Jul 9, 2024
7af4bef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2024
9279f72
testing the ci
fingeraugusto Jul 9, 2024
dcc1930
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2024
581c979
fixing test
fingeraugusto Jul 9, 2024
bdd51de
testing
fingeraugusto Jul 9, 2024
034aaea
testing 2
fingeraugusto Jul 9, 2024
b6084a8
improve tests
fingeraugusto Jul 10, 2024
4e9d0f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2024
fed168a
fixed codespell
fingeraugusto Jul 10, 2024
ad4aa1b
Added test for different app versions (#76)
fingeraugusto Jul 11, 2024
64925ea
Testing version installed
fingeraugusto Jul 5, 2024
d2c165e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
81f8443
Fix global
fingeraugusto Jul 5, 2024
e1f1214
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
b5fe43e
Fixed import
fingeraugusto Jul 5, 2024
4813a8f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
13ce019
Another small fix
fingeraugusto Jul 5, 2024
f817671
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
bef0087
another small fix
fingeraugusto Jul 5, 2024
91d6cc8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
b799aeb
Add exporttoolkit test
fingeraugusto Jul 8, 2024
fac6dfc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2024
a5740d6
Fix some leftovers
fingeraugusto Jul 8, 2024
b49853b
Fixed test
fingeraugusto Jul 9, 2024
8af6419
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2024
44612ed
test tinkering
fingeraugusto Jul 9, 2024
8ec260d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2024
9000423
testing the ci
fingeraugusto Jul 9, 2024
ba62ee8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2024
f3a2d3f
fixing test
fingeraugusto Jul 9, 2024
1ec02bd
testing
fingeraugusto Jul 9, 2024
badd468
testing 2
fingeraugusto Jul 9, 2024
24d8372
Improve tests
fingeraugusto Jul 10, 2024
fb9840c
fixed codespell
fingeraugusto Jul 10, 2024
59abbeb
Rebased with main
fingeraugusto Jul 11, 2024
2e2b83c
Merge branch 'improve-code-cov' of https://github.com/ansys/pyrocky i…
fingeraugusto Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ansys/rocky/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _get_numerical_version(rocky_api: Pyro5.api.Proxy) -> int:
assert rocky_api is not None, "API Proxy not initialized"
try:
# From 25.1 onwards we may use this to obtain the current rocky version.
rocky_version = _ROCKY_API.GetVersion().split(".")
rocky_version = rocky_api.GetVersion().split(".")
return int(rocky_version[0] + rocky_version[1]) # major + minor
except:
# The rocky version is older than 25.1, the specific version is not really
Expand Down
62 changes: 56 additions & 6 deletions tests/test_pyrocky.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import pytest

import ansys.rocky.core as pyrocky
from ansys.rocky.core.client import DEFAULT_SERVER_PORT
from ansys.rocky.core.launcher import RockyLaunchError
from ansys.rocky.core.rocky_api_proxies import ApiExportToolkitProxy


@pytest.fixture()
Expand All @@ -34,9 +34,14 @@ def rocky_session():
rocky.close()


def test_minimal_simulation(rocky_session, tmp_path):
rocky = pyrocky.connect_to_rocky()
project = rocky.api.CreateProject()
def create_basic_project_with_results(
rocky_api,
project_filename,
simulation_duration: float = 2,
time_interval: float = 0.25,
):
"""Helper to create a basic scenario. Returns the study proxy."""
project = rocky_api.CreateProject()
assert project, "No project created"

study = project.GetStudy()
Expand All @@ -50,10 +55,39 @@ def test_minimal_simulation(rocky_session, tmp_path):
domain.SetCoordinateLimitsMaxValues((10, 1, 10))

solver = study.GetSolver()
solver.SetSimulationDuration(2) # Simulate for 2 sec.
solver.SetSimulationDuration(simulation_duration)
solver.SetTimeInterval(time_interval, "s")

project.SaveProject(str(tmp_path / "rocky-testing.rocky"))
project.SaveProject(project_filename)
study.StartSimulation()
return study


@pytest.mark.parametrize(
"version, expected_version",
[
("25.1", 251),
("24.2", 240),
],
)
def test_minimal_simulation(version, expected_version, tmp_path, request):
"""Minimal test to be run with all the supported Rocky version to ensure
minimal backwards compatibility.
"""
short_v = version.replace(".", "")
exe_file = f"C:\\Program Files\\ANSYS Inc\\v{short_v}\\Rocky\\bin\\Rocky.exe"
pyrocky.launch_rocky(exe_file)
rocky = pyrocky.connect_to_rocky()
request.addfinalizer(rocky.close)

from ansys.rocky.core.client import _ROCKY_VERSION

global _ROCKY_VERSION
assert _ROCKY_VERSION == expected_version

study = create_basic_project_with_results(
rocky.api, str(tmp_path / "rocky-testing.rocky")
)

seconds = study.GetTimeSet()
assert seconds[-1] > 1.75
Expand Down Expand Up @@ -93,6 +127,22 @@ def test_sequences_interface(rocky_session):
assert {e.GetName() for e in inlets_outlets} == {"Inlet2"}


def test_export_toolkit(rocky_session, tmp_path):
rocky = pyrocky.connect_to_rocky()
study = create_basic_project_with_results(
rocky.api,
str(tmp_path / "rocky-testing-export.rocky"),
simulation_duration=0.1,
time_interval=0.1,
)

export_toolkit = study.GetExportToolkit()
assert isinstance(export_toolkit, ApiExportToolkitProxy)

stl_to_save = str(tmp_path / "particles_as_stl.stl")
export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>")


def test_pyrocky_launch_multiple_servers():
"""
Test that start multiple rocky servers is not allowed.
Expand Down
Loading