Skip to content

Commit

Permalink
doc: modified more test files
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-ad committed Dec 10, 2024
1 parent 79b8faf commit 8d41688
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
4 changes: 1 addition & 3 deletions tests/test_data_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ def test_write_to_file_remote_data_tree(tmpdir, server_clayer_remote_process):
to_fill.list_double = [1.5, 2.5]
to_fill.list_string = ["hello", "bye"]
data_tree.write_to_txt(str(Path(tmpdir) / "file.txt"))
data_tree = dpf.DataTree.read_from_txt(
str(Path(tmpdir) / "file.txt"), server=server_connected
)
data_tree = dpf.DataTree.read_from_txt(str(Path(tmpdir) / "file.txt"), server=server_connected)
assert data_tree.has("int")
assert data_tree.has("double")
assert data_tree.has("string")
Expand Down
18 changes: 9 additions & 9 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

"""Verify all examples can be accessed or downloaded"""

import os.path
from pathlib import Path

import pytest

Expand Down Expand Up @@ -152,12 +152,12 @@ def test_find_examples(example, server_type_remote_process):


def test_delete_downloaded_files():
path = examples.download_multi_stage_cyclic_result(return_local_path=True)
assert os.path.exists(path)
path = Path(examples.download_multi_stage_cyclic_result(return_local_path=True))
assert path.exists()
examples.delete_downloads(verbose=False)
assert not os.path.exists(path)
path = examples.download_multi_stage_cyclic_result(return_local_path=True)
assert os.path.exists(path)
assert not path.exists()
path = Path(examples.download_multi_stage_cyclic_result(return_local_path=True))
assert path.exists()


def test_get_example_required_minimum_dpf_version(tmp_path):
Expand Down Expand Up @@ -197,12 +197,12 @@ def test_get_example_required_minimum_dpf_version(tmp_path):


def test_download_easy_statistics():
assert os.path.exists(examples.download_easy_statistics(return_local_path=True))
assert Path(examples.download_easy_statistics(return_local_path=True)).exists()


def test_download_average_filter_plugin():
assert os.path.exists(examples.download_average_filter_plugin(return_local_path=True))
assert Path(examples.download_average_filter_plugin(return_local_path=True)).exists()


def test_download_gltf_plugin():
assert os.path.exists(examples.download_gltf_plugin(return_local_path=True))
assert Path(examples.download_gltf_plugin(return_local_path=True)).exists()
13 changes: 8 additions & 5 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# SOFTWARE.

import os
from pathlib import Path

import pytest
import psutil
Expand Down Expand Up @@ -192,10 +193,10 @@ def test_start_local_wrong_ansys_path(self, server_config):
def test_launch_server_full_path(self, server_config):
ansys_path = core.misc.get_ansys_path()
if os.name == "nt":
path = os.path.join(ansys_path, "aisol", "bin", "winx64")
path = Path(ansys_path) / "aisol" / "bin" / "winx64"
else:
if server_config.protocol == core.server_factory.CommunicationProtocols.InProcess:
path = os.path.join(ansys_path, "aisol", "dll", "linx64")
path = Path(ansys_path) / "aisol" / "dll" / "linx64"
elif (
server_config.protocol == core.server_factory.CommunicationProtocols.gRPC
and server_config.legacy is False
Expand All @@ -204,11 +205,13 @@ def test_launch_server_full_path(self, server_config):
# Ans.Dpf.Grpc.sh reside in two different folders
return
else:
path = os.path.join(ansys_path, "aisol", "bin", "linx64")
path = Path(ansys_path) / "aisol" / "bin" / "linx64"

# print("trying to launch on ", path)
# print(os.listdir(path))
server = core.start_local_server(as_global=False, ansys_path=path, config=server_config)
server = core.start_local_server(
as_global=False, ansys_path=str(path), config=server_config
)
assert "server_port" in server.info


Expand All @@ -219,7 +222,7 @@ def test_start_local_failed_executable(remote_config_server_type):

with pytest.raises(FileNotFoundError):
path = Path(get_ansys_path()).parent.absolute()
core.start_local_server(ansys_path=path, config=remote_config_server_type)
core.start_local_server(ansys_path=str(path), config=remote_config_server_type)


@pytest.mark.skipif(not running_docker, reason="Checks docker start server")
Expand Down
9 changes: 5 additions & 4 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import shutil
import types
import weakref
from pathlib import Path

import numpy as np
import pytest
Expand Down Expand Up @@ -446,8 +447,8 @@ def find_mapdl():
try:
path = get_ansys_path()
if dpf.core.SERVER.os == "nt":
exe = os.path.join(path, "ansys", "bin", "winx64", "ANSYS.exe")
return os.path.isfile(exe)
exe = Path(path).joinpath("ansys", "bin", "winx64", "ANSYS.exe")
return exe.is_file()
else:
return False

Expand All @@ -465,8 +466,8 @@ def test_inputs_outputs_datasources_operator(cyclic_ds, server_type):
dsout = op.outputs.data_sources()
assert dsout is not None
assert dsout.result_key == "rst"
path = os.path.join(dsout.result_files[0])
shutil.rmtree(os.path.dirname(path))
path = Path(dsout.result_files[0])
shutil.rmtree(path.parent)


def test_subresults_operator(cyclic_lin_rst, cyclic_ds):
Expand Down

0 comments on commit 8d41688

Please sign in to comment.