Skip to content

Commit 28123a1

Browse files
authored
Add basic tests for LS-Dyna, VTK and CGNS plugins. (#631)
1 parent 8751455 commit 28123a1

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

ansys/dpf/core/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ def download_file(self, server_file_path, to_client_file_path):
628628
txt = """
629629
download service only available for server with gRPC communication protocol
630630
"""
631-
raise ValueError(txt)
631+
raise errors.ServerTypeError(txt)
632632
client_path = self._api.data_processing_download_file(
633633
client=self._server().client,
634634
server_file_path=str(server_file_path),

tests/test_plugins.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import os.path
2+
13
import pytest
24

5+
from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0
36
from ansys.dpf import core as dpf
7+
from ansys.dpf.core import examples
48

59

610
@pytest.fixture()
@@ -55,3 +59,51 @@ def test_eng(engineering_data_sources, try_load_composites_operators):
5559
field_variable_provider.connect(4, engineering_data_sources)
5660
field_variable_provider.inputs.mesh.connect(m.metadata.mesh_provider)
5761
field_variable_provider.run()
62+
63+
64+
@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
65+
reason='Requires server version higher than 5.0')
66+
def test_lsdynahgp(d3plot, server_type):
67+
ds = dpf.DataSources(server=server_type)
68+
ds.set_result_file_path(d3plot, "d3plot")
69+
streams = dpf.operators.metadata.streams_provider(ds, server=server_type)
70+
u = dpf.operators.result.displacement(server=server_type)
71+
u.inputs.streams_container(streams)
72+
fc = u.outputs.fields_container()
73+
assert len(fc[0]) == 3195
74+
assert dpf.Operator("lsdyna::stream_provider") is not None
75+
76+
77+
@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
78+
reason='Requires server version higher than 5.0')
79+
def test_cgns(server_type):
80+
assert dpf.Operator("cgns::stream_provider", server=server_type) is not None
81+
82+
83+
@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
84+
reason='Requires server version higher than 5.0')
85+
def test_vtk(server_type, tmpdir):
86+
op = dpf.Operator("vtu_export", server=server_type)
87+
try:
88+
rst_file = dpf.upload_file_in_tmp_folder(examples.download_pontoon(return_local_path=True)
89+
, server=server_type)
90+
except dpf.errors.ServerTypeError as e:
91+
print(e)
92+
rst_file = examples.download_pontoon(return_local_path=True)
93+
pass
94+
95+
assert op is not None
96+
model = dpf.Model(rst_file, server=server_type)
97+
u = model.operator("U")
98+
op.inputs.fields1.connect(u)
99+
op.inputs.mesh.connect(model.metadata.mesh_provider)
100+
op.inputs.directory.connect(os.path.dirname(rst_file))
101+
out_path = op.eval()
102+
# assert out_path.result_files is not []
103+
# try:
104+
# out_path = dpf.core.download_file(
105+
# out_path, tmp_path, server=server_type)
106+
# except dpf.errors.ServerTypeError as e:
107+
# print(e)
108+
# pass
109+
# assert os.path.exists(tmp_path)

0 commit comments

Comments
 (0)