Skip to content
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
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ markers =
json_file_name(file_name): Mark test to use a specific JSON file for expected data
cad_manager: Tests the CADManager class
double_array: Tests the DoubleArray class
ent_list: Tests the EntList class
import_options: Tests the ImportOptions class
integer_array: Tests the IntegerArray class
mesh_summary: Tests the MeshSummary class
Expand Down
6 changes: 6 additions & 0 deletions tests/api/integration_tests/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@
"time": "06:58:32 UTC",
"build_number": "49.1.198",
"version": "2026"
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider this as an exception case, Going ahead, we should not see any changes in this file, Please improve infra

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will improve in the future

"ent_list": {
"date": "2025-12-02",
"time": "15:34:24 UTC",
"build_number": "49.1.198",
"version": "2026"
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ END PROJECT
ORGANIZE 0
BEGIN PROPERTIES
END PROPERTIES
Last Write Time: Thu Nov 6 18:28:23 2025
Last Write Time: Tue Dec 2 21:18:16 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the changes in sdy & mpi?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the PR description, this change updates all study files in the meshed_studies project (3d_model, dd_model, and midplane_model) by adding a new saved list to the study.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just for this PR or going to happen for every subsequent PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the study doesn't have something that we require for the tests, it might, but we don't expect to see this too often.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I would always expect a new study, Either you create study with full features or just keep on adding new,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is that creating new study files for each requirement will add a lot of extra files to the repo unnecessarily. We should only add new ones when clearly needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, why we can't anticipate all the required things in sdy (we already know the API list) and create a full-fledged study upfront?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would require a separate, deeper review of every API, and in many cases the requirements aren’t immediately obvious. Instead of dedicating extra time solely for that, we’re updating the study files alongside the test development. Since all of this work is happening on a feature branch, by the time it’s merged into main we’ll end up with the finalized versions of the sdy and mpi files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least initial spike will reduce the number of changes in sdy file. My only worry is impact. When there is a change in sdy, all existing test cases are impacted and may fail and reviewer is not going to replay them on their machine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don’t anticipate frequent updates to the study files, so it may be worth having this discussion again only if it starts occurring more often.


Binary file not shown.
12 changes: 12 additions & 0 deletions tests/api/integration_tests/test_suite_ent_list/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2025 Autodesk, Inc.
# SPDX-License-Identifier: Apache-2.0

"""
Constants for entity list tests.
"""

TEST_ENTITY_LIST_ITEMS = {
"dd_model": {"entity_type": "T", "items": [56, 57], "saved_list_name": "MyTest"},
"midplane_model": {"entity_type": "T", "items": [56, 57], "saved_list_name": "MyTest"},
"3d_model": {"entity_type": "TE", "items": [3798, 3799], "saved_list_name": "MyTest"},
}
35 changes: 35 additions & 0 deletions tests/api/integration_tests/test_suite_ent_list/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"3d_model": {
"item_string": "TE3798 TE3799",
"item_predicate": "TE3798:3799",
"saved_list_name": "MyTest",
"converted_string": "TE3798 TE3799 ",
"size": 2,
"entity": {
"0": "TE3798 ",
"1": "TE3799 "
}
},
"dd_model": {
"item_string": "T56 T57",
"item_predicate": "T56:57",
"saved_list_name": "MyTest",
"converted_string": "T56 T57 ",
"size": 2,
"entity": {
"0": "T56 ",
"1": "T57 "
}
},
"midplane_model": {
"item_string": "T56 T57",
"item_predicate": "T56:57",
"saved_list_name": "MyTest",
"converted_string": "T56 T57 ",
"size": 2,
"entity": {
"0": "T56 ",
"1": "T57 "
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-FileCopyrightText: 2025 Autodesk, Inc.
# SPDX-License-Identifier: Apache-2.0

"""
Generate data for a new property.
Returns a dict with relevant properties.
"""

from moldflow import Synergy
from tests.api.integration_tests.data_generation.generate_data_helper import generate_json
from tests.api.integration_tests.constants import FileSet
from tests.api.integration_tests.test_suite_ent_list.constants import TEST_ENTITY_LIST_ITEMS


@generate_json(file_set=FileSet.MESHED)
def generate_ent_list_data(synergy: Synergy, study_file: str):
"""
Generates expected test data for EntList integration tests based on the entity type and items
specified in the study file. Returns a dictionary with properties such as item strings,
predicates, saved list name, converted string, size, and entity mapping for use in tests.
"""
entity_type = TEST_ENTITY_LIST_ITEMS[study_file]["entity_type"]
items = TEST_ENTITY_LIST_ITEMS[study_file]["items"]
saved_list_name = TEST_ENTITY_LIST_ITEMS[study_file]["saved_list_name"]

item_string = " ".join([f"{entity_type}{item}" for item in items])
item_predicate = f"{entity_type}{items[0]}:{items[1]}"
converted_string = f"{item_string} "
size = len(items)
entity = {i: f"{entity_type}{item} " for i, item in enumerate(items)}

return {
"item_string": item_string,
"item_predicate": item_predicate,
"saved_list_name": saved_list_name,
"converted_string": converted_string,
"size": size,
"entity": entity,
}


if __name__ == "__main__":
generate_ent_list_data()
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# SPDX-FileCopyrightText: 2025 Autodesk, Inc.
# SPDX-License-Identifier: Apache-2.0

"""
Integration tests for EntList Wrapper Class of moldflow-api module.

These tests focus on testing the actual functionality and behavior
of the EntList class with real Moldflow Synergy COM objects.
"""

import pytest
from moldflow import EntList, Synergy
from tests.api.integration_tests.constants import FileSet


TEST_ENTITY_LIST_PARAMETERS = [
("select_from_string", "item_string"),
("select_from_predicate", "item_predicate"),
("select_from_saved_list", "saved_list_name"),
]


@pytest.mark.integration
@pytest.mark.ent_list
@pytest.mark.file_set(FileSet.MESHED)
class TestIntegrationEntList:
"""
Integration test suite for the EntList class.
"""

@pytest.fixture
def ent_list(self, synergy: Synergy, study_with_project):
"""
Fixture to create a real EntList instance for integration testing.
"""
study_doc = synergy.study_doc
return study_doc.create_entity_list()

def _select_entities(
self,
synergy: Synergy,
ent_list: EntList,
study_file,
select_function,
parameter,
values_to_select,
):
"""
Select entities from the entity list.
"""
if select_function == "select_from_string":
getattr(ent_list, select_function)(values_to_select[parameter])
elif select_function == "select_from_predicate":
pm = synergy.predicate_manager
predicate = pm.create_label_predicate(values_to_select[parameter])
getattr(ent_list, select_function)(predicate)
elif select_function == "select_from_saved_list":
getattr(ent_list, select_function)(values_to_select[parameter])
else:
raise ValueError(f"Invalid select function: {select_function}")

def test_entity_list(self, ent_list: EntList):
"""
Test the entity list method of EntList.
"""
assert ent_list.size == 0
assert ent_list.convert_to_string() == ""

@pytest.mark.parametrize(
"select_function, parameter",
TEST_ENTITY_LIST_PARAMETERS,
ids=["select_from_string", "select_from_predicate", "select_from_saved_list"],
)
def test_entity_list_size(
self,
synergy: Synergy,
ent_list: EntList,
study_file,
select_function,
parameter,
expected_values,
):
"""
Test the size property of EntList.
"""
assert ent_list.size == 0
self._select_entities(
synergy, ent_list, study_file, select_function, parameter, expected_values
)
assert ent_list.size == expected_values["size"]

@pytest.mark.parametrize(
"select_function, parameter",
TEST_ENTITY_LIST_PARAMETERS,
ids=["select_from_string", "select_from_predicate", "select_from_saved_list"],
)
def test_entity_list_convert_to_string(
self,
synergy: Synergy,
ent_list: EntList,
study_file,
select_function,
parameter,
expected_values,
):
"""
Test the convert_to_string method of EntList.
"""
self._select_entities(
synergy, ent_list, study_file, select_function, parameter, expected_values
)
assert ent_list.convert_to_string() == expected_values["converted_string"]

@pytest.mark.parametrize(
"select_function, parameter",
TEST_ENTITY_LIST_PARAMETERS,
ids=["select_from_string", "select_from_predicate", "select_from_saved_list"],
)
def test_entity_list_entity(
self,
synergy: Synergy,
ent_list: EntList,
study_file,
select_function,
parameter,
expected_values,
):
"""
Test the entity method of EntList.
"""
self._select_entities(
synergy, ent_list, study_file, select_function, parameter, expected_values
)
for i in range(ent_list.size):
assert ent_list.entity(i).convert_to_string() == expected_values["entity"][str(i)]

def test_entity_list_select_from_predicate_none(self, ent_list: EntList):
"""
Test the select_from_predicate method of EntList with None parameter.
"""
ent_list.select_from_predicate(None)
assert ent_list.size == 0
assert ent_list.convert_to_string() == ""
1 change: 1 addition & 0 deletions tests/api/unit_tests/test_unit_ent_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file is shown as modified and not newly created?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We previously had unit tests without class-specific labels. Now that we’re introducing labels, we’re going back and adding them to the existing tests as well.


@pytest.mark.unit
@pytest.mark.ent_list
class TestUnitEntList:
"""
Test suite for the EntList class.
Expand Down