Skip to content

Commit

Permalink
tests: adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 committed Jan 8, 2025
1 parent 5610054 commit 9f5d421
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import re
import shutil
import sys
from unittest.mock import patch

import grpc
import pytest
Expand Down Expand Up @@ -682,3 +683,32 @@ def _null_close_process():
mapdl.prep7(mapdl)

mapdl._exited = False # Restoring


@pytest.mark.parametrize("platform", ["linux", "windows", "error"])
def test__get_time_step_stream(mapdl, platform):
with patch("ansys.mapdl.core.mapdl_grpc.MapdlGrpc.platform", platform):
from ansys.mapdl.core import mapdl_grpc

if platform == "linux":
DEFAULT_TIME_STEP_STREAM = mapdl_grpc.DEFAULT_TIME_STEP_STREAM_POSIX
elif platform == "windows":
DEFAULT_TIME_STEP_STREAM = mapdl_grpc.DEFAULT_TIME_STEP_STREAM_NT
else:
with pytest.raises(ValueError, match="The MAPDL platform"):
mapdl._get_time_step_stream()

return # Early exit

assert DEFAULT_TIME_STEP_STREAM == mapdl._get_time_step_stream()

mapdl_grpc.DEFAULT_TIME_STEP_STREAM = 200
assert mapdl_grpc.DEFAULT_TIME_STEP_STREAM == mapdl._get_time_step_stream()
mapdl_grpc.DEFAULT_TIME_STEP_STREAM = None

assert 700 == mapdl._get_time_step_stream(700)

with pytest.raises(
ValueError, match="``time_step`` argument must be greater than 0``"
):
mapdl._get_time_step_stream(-700)

0 comments on commit 9f5d421

Please sign in to comment.