diff --git a/tests/test_grpc.py b/tests/test_grpc.py index 808de4afab..6d0aaf6fc2 100644 --- a/tests/test_grpc.py +++ b/tests/test_grpc.py @@ -25,6 +25,7 @@ import re import shutil import sys +from unittest.mock import patch import grpc import pytest @@ -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)