-
Notifications
You must be signed in to change notification settings - Fork 1
EntList Integration Tests #34
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
Changes from all commits
d8767b6
108871d
5d6365e
f003e14
395a7d9
98c428e
7312aae
5887549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the changes in sdy & mpi?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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,
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| 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"}, | ||
| } |
| 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() == "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this file is shown as modified and not newly created?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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