Skip to content

Commit a02362f

Browse files
Integration Tests (#65)
* VectorArray Integration Tests * Bracket fixes * Add SPDX header * Removed read only tag * Vector Class Integration Tests (#6) * Vector Class Integration Tests * Review Fixes * Fixes * Brackets fix * Adding SPDX header * Type order fix * StringArray Class Integration Tests (#11) * StringArray Class Tests * to_list function fix * add spdx headers * IntegerArray Class Integration Tests (#10) * IntegerArray Class Integration Tests * Docstring fixes * Review comments fixes * Add SPDX Header * DoubleArray Class Integration Tests (#9) * DoubleArray Class Integration Tests * Updating unit test * Add SPDX Header * ImportOptions Class Integration Tests (#17) * ImportOptions class integration tests * Marker additions * Code review fixes * MeshSummary Class Integration Tests (#25) * Adding models and model fixtures * MeshSummary Integration Tests * Test Data Generation and Test fixes * README update * README update * Comment fix * Synergy Class Integration Tests (#30) * Adding models and model fixtures * MeshSummary Integration Tests * Test Data Generation and Test fixes * README update * README update * Comment fix * Add non-model based data generation * Synergy Integration Tests * Adding pygetwindow to requirements * Windows size updates and Fixture updates * Copilot review fixes * Zipping study_files * Zip File name changes * Metadata for Test data * Unzip files in test data generation * README updates * Review fixes * Removed ModelType enum * Review fixes * Lint fixes * Project clean up * Revert "Project clean up" This reverts commit 1f16653. * Remove edition assert * CADManager Class Integration Tests (#31) * CADManager Integration Tests * CADManager none tests * Review comment fix * Add Parent-Child Markers, JSON File Name Marker, and Synergy Required Field to Test Data Generation (#32) * Child Markers, Json File Name marker, Synergy in data generation * Review fixes * Review fixes * Property Class Integration Tests (#33) * Property Integration Tests and Child Markers introduction * New Infrastructural changes for the Integration Tests branch (#35) * New Infra * Updating readme, removing childmarkers * Review fix * Timezone added to metadata, docopt command clarification * EntList Integration Tests (#34) * EntList Integration Tests * Update tests/api/integration_tests/test_integration_ent_list.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * SelectFromSavedList function test * Refactoring for new infra * SavedList tests * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * PredicateManager Integration Tests (#38) * PredicateManager Integration Tests * Add marker to unit test * Removing metadata file from integration tests (#55) * Remove metadata from integration tests * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * PropertyEditor Integration Tests (#56) * PropertyEditor Integration Tests * Review fixes * MDLKernel test update --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dae910f commit a02362f

92 files changed

Lines changed: 10004 additions & 151 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,12 @@ Thumbs.db
180180

181181
# Internal Autodesk directories
182182
.adsk/
183+
184+
# Tracking only sdy files in some integration test project folders
185+
# Ignore everything in project_meshed_studies and project_cad_study folders except mpi and sdy files
186+
**/project_meshed_studies/*
187+
**/project_cad_manager_studies/*
188+
!**/project_meshed_studies/*.mpi
189+
!**/project_meshed_studies/*.sdy
190+
!**/project_cad_manager_studies/*.mpi
191+
!**/project_cad_manager_studies/*.sdy

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ repos:
2222
exclude_types: [markdown]
2323
exclude: \.(svg|jpe?g|png|webp|gif|bmp)$
2424
- id: pretty-format-json
25-
args: [--autofix]
25+
args: [--autofix, --no-sort-keys]
2626
exclude_types: [markdown]
2727
exclude: \.(svg|jpe?g|png|webp|gif|bmp)$

pytest.ini

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,22 @@ markers =
33
unit: Unit tests that run quickly and test small pieces of functionality
44
integration: Integration tests that check multiple components together
55
core: Core functionality tests
6+
file_set(set_name): Mark test to run on a specific FileSet
7+
json_file_name(file_name): Mark test to use a specific JSON file for expected data
8+
cad_manager: Tests the CADManager class
9+
double_array: Tests the DoubleArray class
10+
ent_list: Tests the EntList class
11+
import_options: Tests the ImportOptions class
12+
integer_array: Tests the IntegerArray class
13+
mesh_summary: Tests the MeshSummary class
14+
predicate_manager: Tests the PredicateManager class
15+
prop: Tests the Property class (unit tests)
16+
property_editor: Tests the PropertyEditor class
17+
string_array: Tests the StringArray class
18+
synergy: Tests the Synergy class
19+
vector_array: Tests the VectorArray class
20+
vector: Tests the Vector class
21+
22+
; Property class integration tests are divided in two separate suites.
23+
material_property: Tests the pre-existing materials for Property class
24+
custom_property: Tests a new custom property for Property class

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pathspec==0.12.1
77
polib==1.2.0
88
pre-commit==4.2.0
99
pydata-sphinx-theme==0.16.1
10+
pygetwindow==0.0.9
1011
pylint==3.3.4
1112
pytest==8.3.4
1213
sphinx==8.1.3

run.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
run.py build [-P | --publish] [-i | --install]
1010
run.py build-docs [-t <target> | --target=<target>] [-s | --skip-build] [-l | --local]
1111
run.py format [--check]
12+
run.py generate-expected-data [<markers>...]
1213
run.py install [-s | --skip-build]
1314
run.py install-package-requirements
1415
run.py lint [-s | --skip-build]
@@ -23,6 +24,7 @@
2324
build Build and optionally publish the moldflow-api package.
2425
build-docs Build the documentation.
2526
format Format all Python files in the repository using black.
27+
generate-expected-data Generate expected data for integration tests.
2628
install Install the moldflow-api package.
2729
install-package-requirements Install package dependencies.
2830
lint Lint all Python files in the repository.
@@ -52,6 +54,7 @@
5254
--repo-url=<url> Custom PyPI repository URL.
5355
--github-api-url=<url> Custom GitHub API URL.
5456
-l, --local Build documentation locally (single version).
57+
<markers> Markers to filter data generation by: mesh_summary, etc.
5558
"""
5659

5760
import os
@@ -678,6 +681,13 @@ def clean_up():
678681
os.remove(COVERAGE_XML_FILE_NAME)
679682

680683

684+
def generate_expected_data(markers: list[str]):
685+
"""Generate data for integration tests"""
686+
logging.info('Generating data for integration tests')
687+
generate_data_module = 'tests.api.integration_tests.data_generation.generate_data'
688+
run_command([sys.executable, '-m', generate_data_module] + markers, ROOT_DIR)
689+
690+
681691
def set_version():
682692
"""Set current version and write version file to package directory"""
683693

@@ -720,6 +730,10 @@ def main():
720730

721731
lint(skip_build=skip_build)
722732

733+
elif args.get('generate-expected-data'):
734+
markers = args.get('<markers>') or []
735+
generate_expected_data(markers=markers)
736+
723737
elif args.get('test'):
724738
tests = args.get('<tests>') or []
725739
marker = args.get('--marker') or args.get('-m')

src/moldflow/double_array.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,47 @@ def val(self, index: int) -> float:
3535
Get the value at the specified index.
3636
3737
Args:
38-
index (int): The index of the value to get.
38+
index (int): index between 0 and double_array.size-1 (inclusive).
3939
4040
Returns:
41-
float: The value at the specified index.
41+
The value at the specified index.
4242
"""
4343
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="val")
4444
check_type(index, int)
4545
return self.double_array.Val(index)
4646

47-
def add_double(self, value: float) -> None:
47+
def add_double(self, value: float | int) -> None:
4848
"""
49-
Add a double value to the array.
49+
Adds a double value to the end of the array.
5050
5151
Args:
52-
value (float): The value to add.
52+
value (float | int): The value to add.
5353
"""
5454
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="add_double")
5555
check_type(value, (int, float))
5656
self.double_array.AddDouble(value)
5757

58-
def to_list(self) -> list[float]:
58+
def to_list(self) -> list[float | int]:
5959
"""
6060
Convert the double array to a list of floats.
6161
6262
Returns:
63-
list[float]: The list of floats.
63+
The list of values.
6464
"""
6565
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="to_list")
6666

6767
vb_array = self.double_array.ToVBSArray()
6868
return list(vb_array)
6969

70-
def from_list(self, values: list[float]) -> int:
70+
def from_list(self, values: list[float | int] | tuple[float | int]) -> int:
7171
"""
7272
Convert a list of floats to a double array.
7373
7474
Args:
75-
values (list[float]): The list of floats to convert.
75+
values (list[float | int] | tuple[float | int]): The list of floats to convert.
7676
7777
Returns:
78-
int: The number of elements added to the array.
78+
The number of elements added.
7979
"""
8080
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="from_list")
8181

@@ -91,7 +91,7 @@ def size(self) -> int:
9191
Get the size of the array.
9292
9393
Returns:
94-
int: The size of the array.
94+
The size of the array.
9595
"""
9696
process_log(__name__, LogMessage.PROPERTY_GET, locals(), name="size")
9797
return self.double_array.Size

src/moldflow/helper.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,6 @@ def check_min_max(min_value: float, max_value: float):
299299
)
300300

301301

302-
def _mf_array_to_list(array_instance):
303-
"""
304-
Generic helper function to convert any array instance to a list.
305-
306-
Args:
307-
array_instance: The array instance that has val(index) method and size property.
308-
309-
Returns:
310-
list: A list containing all values from the array.
311-
"""
312-
return [array_instance.val(i) for i in range(array_instance.size)]
313-
314-
315302
def variant_null_idispatch():
316303
"""Return a VARIANT representing a null IDispatch pointer (VT_DISPATCH, None)."""
317304
return VARIANT(pythoncom.VT_DISPATCH, None)

src/moldflow/integer_array.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ def val(self, index: int) -> int:
3535
Get the value at the specified index.
3636
3737
Args:
38-
index (int): The index of the value to get.
38+
index (int): index between 0 and integer_array.size-1 (inclusive)
3939
4040
Returns:
41-
int: The value at the specified index.
41+
The value at the specified index.
4242
"""
4343
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="val")
4444
check_type(index, int)
4545
return self.integer_array.Val(index)
4646

4747
def add_integer(self, value: int) -> None:
4848
"""
49-
Add a integer value to the array.
49+
Adds an integer value to the end of the array.
5050
5151
Args:
5252
value (int): The value to add.
@@ -60,22 +60,22 @@ def to_list(self) -> list[int]:
6060
Convert the integer array to a list of integers.
6161
6262
Returns:
63-
list[int]: The list of integers.
63+
The list of integers.
6464
"""
6565
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="to_list")
6666

6767
vb_array = self.integer_array.ToVBSArray()
6868
return list(vb_array)
6969

70-
def from_list(self, values: list[int]) -> int:
70+
def from_list(self, values: list[int] | tuple[int, ...]) -> int:
7171
"""
7272
Convert a list of integers to an integer array.
7373
7474
Args:
75-
values (list[int]): The list of integers to convert.
75+
values (list[int] | tuple[int, ...]): The list of integers to convert.
7676
7777
Returns:
78-
int: The number of elements added to the array.
78+
The number of elements added.
7979
"""
8080
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="from_list")
8181

@@ -91,7 +91,7 @@ def size(self) -> int:
9191
Get the size of the array.
9292
9393
Returns:
94-
int: The size of the array.
94+
The size of the array.
9595
"""
9696
process_log(__name__, LogMessage.PROPERTY_GET, locals(), name="size")
9797
return self.integer_array.Size

src/moldflow/string_array.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
from .logger import process_log
10-
from .helper import check_type, _mf_array_to_list
10+
from .helper import check_type
1111
from .com_proxy import safe_com, flag_com_method
1212
from .common import LogMessage
1313

@@ -34,18 +34,18 @@ def val(self, index: int) -> str:
3434
Get the value at the specified index.
3535
3636
Args:
37-
index (int): The index of the value to get.
37+
index (int): index between 0 and string_array.size-1 (inclusive).
3838
3939
Returns:
40-
str: The value at the specified index.
40+
The value at the specified index.
4141
"""
4242
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="val")
4343
check_type(index, int)
4444
return self.string_array.Val(index)
4545

4646
def add_string(self, value: str) -> None:
4747
"""
48-
Add a string value to the array.
48+
Adds a string value to the end of the array.
4949
5050
Args:
5151
value (str): The value to add.
@@ -58,20 +58,20 @@ def to_list(self) -> list[str]:
5858
"""
5959
Convert the string array to a list of strings.
6060
Returns:
61-
list[str]: The list of strings.
61+
The list of values.
6262
"""
6363
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="to_list")
64-
return _mf_array_to_list(self)
64+
return [self.val(i) for i in range(self.size)]
6565

66-
def from_list(self, values: list[str]) -> int:
66+
def from_list(self, values: list[str] | tuple[str, ...]) -> int:
6767
"""
6868
Convert a list of strings to a string array.
6969
7070
Args:
71-
values (list[str]): The list of strings to convert.
71+
values (list[str] | tuple[str, ...]): The list of strings to convert.
7272
7373
Returns:
74-
int: The number of elements added to the array.
74+
The number of elements added.
7575
"""
7676
process_log(__name__, LogMessage.FUNCTION_CALL, locals(), name="from_list")
7777
check_type(values, (list, tuple))
@@ -87,7 +87,7 @@ def size(self) -> int:
8787
Get the size of the array.
8888
8989
Returns:
90-
int: The size of the array.
90+
The size of the array.
9191
"""
9292
process_log(__name__, LogMessage.PROPERTY_GET, locals(), name="size")
9393
return self.string_array.Size

0 commit comments

Comments
 (0)