Skip to content

Add basic tests for LS-Dyna, VTK and CGNS plugins. #631

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

Merged
merged 5 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 ansys/dpf/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def download_file(self, server_file_path, to_client_file_path):
txt = """
download service only available for server with gRPC communication protocol
"""
raise ValueError(txt)
raise errors.ServerTypeError(txt)
client_path = self._api.data_processing_download_file(
client=self._server().client,
server_file_path=str(server_file_path),
Expand Down
52 changes: 52 additions & 0 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os.path

import pytest

from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0
from ansys.dpf import core as dpf
from ansys.dpf.core import examples


@pytest.fixture()
Expand Down Expand Up @@ -55,3 +59,51 @@ def test_eng(engineering_data_sources, try_load_composites_operators):
field_variable_provider.connect(4, engineering_data_sources)
field_variable_provider.inputs.mesh.connect(m.metadata.mesh_provider)
field_variable_provider.run()


@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
reason='Requires server version higher than 5.0')
def test_lsdynahgp(d3plot, server_type):
ds = dpf.DataSources(server=server_type)
ds.set_result_file_path(d3plot, "d3plot")
streams = dpf.operators.metadata.streams_provider(ds, server=server_type)
u = dpf.operators.result.displacement(server=server_type)
u.inputs.streams_container(streams)
fc = u.outputs.fields_container()
assert len(fc[0]) == 3195
assert dpf.Operator("lsdyna::stream_provider") is not None


@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
reason='Requires server version higher than 5.0')
def test_cgns(server_type):
assert dpf.Operator("cgns::stream_provider", server=server_type) is not None


@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
reason='Requires server version higher than 5.0')
def test_vtk(server_type, tmpdir):
op = dpf.Operator("vtu_export", server=server_type)
try:
rst_file = dpf.upload_file_in_tmp_folder(examples.download_pontoon(return_local_path=True)
, server=server_type)
except dpf.errors.ServerTypeError as e:
print(e)
rst_file = examples.download_pontoon(return_local_path=True)
pass

assert op is not None
model = dpf.Model(rst_file, server=server_type)
u = model.operator("U")
op.inputs.fields1.connect(u)
op.inputs.mesh.connect(model.metadata.mesh_provider)
op.inputs.directory.connect(os.path.dirname(rst_file))
out_path = op.eval()
# assert out_path.result_files is not []
# try:
# out_path = dpf.core.download_file(
# out_path, tmp_path, server=server_type)
# except dpf.errors.ServerTypeError as e:
# print(e)
# pass
# assert os.path.exists(tmp_path)