Skip to content

Commit 6bca018

Browse files
committed
Merge branch 'feature/integration-tests' of https://github.com/Autodesk/moldflow-api into feature/integration-tests
2 parents b4ed118 + 84d4eac commit 6bca018

12 files changed

Lines changed: 432 additions & 159 deletions

File tree

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ markers =
1313
mesh_summary: Tests the MeshSummary class
1414
predicate_manager: Tests the PredicateManager class
1515
prop: Tests the Property class (unit tests)
16+
property_editor: Tests the PropertyEditor class
1617
string_array: Tests the StringArray class
1718
synergy: Tests the Synergy class
1819
vector_array: Tests the VectorArray class

run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
run.py build [-P | --publish] [-i | --install]
1010
run.py build-docs [-t <target> | --target=<target>] [-s | --skip-build]
1111
run.py format [--check]
12-
run.py generate-baseline-data [<markers>...]
12+
run.py generate-expected-data [<markers>...]
1313
run.py install [-s | --skip-build]
1414
run.py install-package-requirements
1515
run.py lint [-s | --skip-build]
@@ -24,7 +24,7 @@
2424
build Build and optionally publish the moldflow-api package.
2525
build-docs Build the documentation.
2626
format Format all Python files in the repository using black.
27-
generate-baseline-data Generate baseline data for integration tests.
27+
generate-expected-data Generate expected data for integration tests.
2828
install Install the moldflow-api package.
2929
install-package-requirements Install package dependencies.
3030
lint Lint all Python files in the repository.
@@ -581,7 +581,7 @@ def clean_up():
581581
os.remove(COVERAGE_XML_FILE_NAME)
582582

583583

584-
def generate_data(markers: list[str]):
584+
def generate_expected_data(markers: list[str]):
585585
"""Generate data for integration tests"""
586586
logging.info('Generating data for integration tests')
587587
generate_data_module = 'tests.api.integration_tests.data_generation.generate_data'
@@ -630,9 +630,9 @@ def main():
630630

631631
lint(skip_build=skip_build)
632632

633-
elif args.get('generate-baseline-data'):
633+
elif args.get('generate-expected-data'):
634634
markers = args.get('<markers>') or []
635-
generate_data(markers=markers)
635+
generate_expected_data(markers=markers)
636636

637637
elif args.get('test'):
638638
tests = args.get('<tests>') or []

tests/api/integration_tests/README.md

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ It combines the marker-driven test suite conventions with the project fixtures a
1515
6. [Steps to Add a New Integration Test Suite](#steps-to-add-a-new-integration-test-suite)
1616
7. [Baseline Data Handling](#baseline-data-handling)
1717
8. [Generator Functions](#generator-functions)
18-
9. [Metadata Tracking](#metadata-tracking)
19-
10. [Running Integration Tests](#running-integration-tests)
20-
11. [Example Test Suite](#example-test-suite)
21-
12. [Best Practices](#best-practices)
22-
13. [Appendix: Quick Checklist](#appendix-quick-checklist)
18+
9. [Running Integration Tests](#running-integration-tests)
19+
10. [Example Test Suite](#example-test-suite)
20+
11. [Best Practices](#best-practices)
21+
12. [Appendix: Quick Checklist](#appendix-quick-checklist)
2322

2423
---
2524

@@ -31,7 +30,7 @@ Integration tests in this repo exercise **real interactions** with Moldflow Syne
3130
- test class names
3231
- test suite names
3332
- generator function names
34-
- pytest markers and metadata entries
33+
- pytest markers entries
3534

3635
**Important:** Markers are always **snake_case**. The marker's human-readable form inside class names uses **PascalCase** (see naming conventions).
3736

@@ -115,7 +114,6 @@ Each integration test suite is organized in its own dedicated folder following a
115114
tests/api/integration_tests/
116115
├── conftest.py # Shared fixtures for all integration tests
117116
├── constants.py # Shared constants (FileSet enum, paths, etc.)
118-
├── metadata.json # Tracks baseline generation metadata
119117
├── data_generation/ # Data generation utilities
120118
│ ├── generate_data.py # Main data generation script
121119
│ ├── generate_data_helper.py # Helper functions and decorators
@@ -295,7 +293,7 @@ python run.py generate-test-data <marker1> <marker2> ...
295293
- If you pass one or more markers, only those markers' baseline files are generated/updated.
296294
- If you pass **no markers**, **all** available test data baselines are generated/updated.
297295
- Baseline files are **auto-created** the first time you run the generator; it's advised not to hand-create/self-edit them to avoid inconsistencies.
298-
- The generator will write the baseline JSON and also update `metadata.json` for the updated markers (see Metadata section).
296+
- The generator will write the expected data JSON for the updated markers.
299297

300298
**Note:** The generator functions are expected to produce a `dict`.
301299

@@ -482,42 +480,6 @@ This loads: `test_suite_material_property/data.json`
482480

483481
---
484482

485-
## Metadata Tracking
486-
487-
`metadata.json` (located at `tests/api/integration_tests/metadata.json`) keeps a simple audit of baseline updates.
488-
489-
For each marker entry includes:
490-
491-
| Key | Description |
492-
|------------|------|
493-
| `date` | Date of baseline generation/update [In **YYYY-MM-DD** format] |
494-
| `time` | Time of baseline generation/update [In **HH:MM:SS** format] |
495-
| `build_number` | Build Number of Synergy used to generate/update the baseline (e.g., 49.0.x, 49.1.198, etc) |
496-
| `version` | Synergy Version used for baseline update (e.g., 2026, 2027, etc) |
497-
498-
### Example
499-
500-
```json
501-
{
502-
"mesh_summary": {
503-
"date": "2025-12-02",
504-
"time": "01:46:35",
505-
"build_number": "49.1.198",
506-
"version": "2026"
507-
},
508-
"synergy": {
509-
"date": "2025-12-02",
510-
"time": "01:46:35",
511-
"build_number": "49.1.198",
512-
"version": "2026"
513-
}
514-
}
515-
```
516-
517-
When the baseline generator runs for a marker, only that marker's metadata entry is updated (others remain unchanged).
518-
519-
---
520-
521483
## Running Integration Tests
522484

523485
| Task | Command | Example |
@@ -663,8 +625,7 @@ python run.py generate-test-data mesh_summary
663625
```
664626

665627
After running you should see:
666-
- Data file created: `tests/api/integration_tests/test_suite_mesh_summary/data.json`
667-
- `metadata.json` updated to include `mesh_summary`
628+
- Expected data file created: `tests/api/integration_tests/test_suite_mesh_summary/data.json`
668629

669630
### 6. Resulting folder structure
670631

@@ -712,7 +673,6 @@ test_suite_mesh_summary/
712673
- **Class names**: use PascalCase for the Marker portion (e.g., `TestIntegrationMeshSummary`).
713674
- **Folder structure**: each test suite gets its own `test_suite_<marker>/` folder containing all related files.
714675
- **Generator functions**: return serializable dictionaries only (no complex objects).
715-
- **Metadata**: let the generator update `metadata.json` — do not edit manually.
716676
- **Scope fixtures appropriately**: use class scope for expensive resources like COM instances.
717677
- **Parameterize where possible**: reduce duplication by using `study_file` and `study_with_project`.
718678
- **Document new markers**: add a short explanation in `pytest.ini`.
@@ -761,7 +721,6 @@ test_suite_mesh_summary/
761721

762722
- [ ] Run `python run.py generate-test-data <marker>`
763723
- [ ] Verify `test_suite_<marker>/data.json` was created
764-
- [ ] Verify `metadata.json` was updated
765724

766725
### Step 6: Verify and Test
767726

@@ -777,7 +736,6 @@ test_suite_mesh_summary/
777736
- [ ] `test_suite_<marker>/generate_test_data_<marker>.py`
778737
- [ ] `test_suite_<marker>/data.json`
779738
- [ ] `test_suite_<marker>/constants.py` (if created)
780-
- [ ] `metadata.json`
781739
- [ ] Push changes to repository
782740

783741
---

tests/api/integration_tests/constants.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
STUDIES_FILE_NAME = "studies.json"
1616
STUDIES_FILE = Path(STUDY_FILES_DIR) / STUDIES_FILE_NAME
1717

18-
METADATA_FILE_NAME = "metadata.json"
19-
METADATA_FILE = Path(INTEGRATION_TESTS_DIR) / METADATA_FILE_NAME
20-
2118
TEST_PROJECT_NAME = "test_project"
2219

2320
DEFAULT_WINDOW_SIZE_X = 2560
@@ -28,9 +25,6 @@
2825
SYNERGY_VERSION = "2026"
2926
SYNERGY_WINDOW_TITLE = f"Autodesk Moldflow Insight {SYNERGY_VERSION}"
3027

31-
METADATA_DATE_FORMAT = "%Y-%m-%d"
32-
METADATA_TIME_FORMAT = "%H:%M:%S %Z"
33-
3428
TEMP_FILE_PREFIX = "temp_"
3529
GENERATE_DATA_FUNCTION_PREFIX = "generate_"
3630
GENERATE_DATA_FUNCTION_SUFFIX = "_data"

tests/api/integration_tests/data_generation/generate_data.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import docopt
1212
import sys
13-
from datetime import datetime, timezone
1413
from tests.api.integration_tests.data_generation.generate_data_helper import (
1514
clean_up_temp_files,
1615
get_generate_data_functions,
@@ -24,7 +23,6 @@
2423
def main():
2524
"""Main entry point for this script"""
2625
args = docopt.docopt(__doc__)
27-
DATE_TIME = datetime.now(timezone.utc)
2826

2927
try:
3028
markers = args.get('<markers>') or []
@@ -38,9 +36,9 @@ def main():
3836
return 0
3937

4038
if len(markers) > 0:
41-
fetch_data_on_markers(markers, generate_functions, DATE_TIME)
39+
fetch_data_on_markers(markers, generate_functions)
4240
else:
43-
fetch_data_on_markers(generate_functions.keys(), generate_functions, DATE_TIME)
41+
fetch_data_on_markers(generate_functions.keys(), generate_functions)
4442

4543
except Exception as err:
4644
generate_data_logger.error(f'FAILURE: {err}')

tests/api/integration_tests/data_generation/generate_data_helper.py

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
FileSet,
2121
STUDY_FILES_DIR,
2222
INTEGRATION_TESTS_DIR,
23-
METADATA_FILE,
24-
METADATA_FILE_NAME,
2523
TEMP_FILE_PREFIX,
2624
GENERATE_DATA_FUNCTION_PREFIX,
2725
GENERATE_DATA_FUNCTION_SUFFIX,
2826
DATA_FILE_NAME,
29-
METADATA_DATE_FORMAT,
30-
METADATA_TIME_FORMAT,
3127
PROJECT_PREFIX,
3228
PROJECT_EXTENSION,
3329
TEST_SUITE_PREFIX,
@@ -42,26 +38,6 @@
4238
WINDOWS = platform.system() == 'Windows'
4339

4440

45-
@dataclass
46-
class Metadata:
47-
"""
48-
Metadata class for storing metadata about the test data.
49-
"""
50-
51-
date: datetime
52-
time: datetime
53-
build_number: str
54-
version: str
55-
56-
def to_dict(self):
57-
return {
58-
"date": self.date.strftime(METADATA_DATE_FORMAT),
59-
"time": self.time.strftime(METADATA_TIME_FORMAT),
60-
"build_number": self.build_number,
61-
"version": self.version,
62-
}
63-
64-
6541
def run_command(args, cwd=os.getcwd(), extra_env=None):
6642
"""Runs native executable command, args is an array of strings"""
6743

@@ -203,18 +179,6 @@ def wrapper(*args, **kwargs):
203179
return decorator
204180

205181

206-
def fetch_metadata(date_time: datetime):
207-
"""
208-
Fetch the metadata from the Synergy instance.
209-
"""
210-
synergy = Synergy()
211-
metadata = Metadata(
212-
date=date_time, time=date_time, build_number=synergy.build_number, version=synergy.version
213-
)
214-
synergy.quit(False)
215-
return metadata.to_dict()
216-
217-
218182
def clean_up_temp_files():
219183
"""
220184
Clean up the temporary files.
@@ -242,22 +206,12 @@ def read_json_file(file_path: Path):
242206
return
243207

244208

245-
def commit_data(metadata: dict):
209+
def commit_data():
246210
"""
247211
Commit the data to the data directory.
248212
The data is committed to the data directory in the following way:
249-
- The metadata is committed to the metadata file.
250213
- The temporary files are committed to the data directory.
251-
Args:
252-
metadata (dict): The metadata to commit.
253214
"""
254-
# Update metadata file
255-
metadata_file_data = read_json_file(METADATA_FILE)
256-
for marker, data in metadata.items():
257-
metadata_file_data[marker] = data
258-
generate_data_logger.track_generation(marker, METADATA_FILE_NAME)
259-
_json_dump(METADATA_FILE_NAME, metadata_file_data)
260-
261215
# Commit temporary files to final files
262216
for item in INTEGRATION_TESTS_DIR.iterdir():
263217
if item.is_dir() and item.name.startswith(TEST_SUITE_PREFIX):
@@ -296,23 +250,17 @@ def get_generate_data_functions():
296250
return functions
297251

298252

299-
def fetch_data_on_markers(
300-
markers: list[str], generate_functions: dict[str, callable], date_time: datetime
301-
):
253+
def fetch_data_on_markers(markers: list[str], generate_functions: dict[str, callable]):
302254
"""
303255
Run the markers.
304256
"""
305-
metadata = {}
306-
metadata_data = fetch_metadata(date_time)
307-
308257
for marker in markers:
309258
generate_function_file = generate_functions.get(marker)
310259
if not generate_function_file:
311260
generate_data_logger.error(
312261
f"Generator function for marker '{marker}' not found. Please check if the function exists."
313262
)
314263
continue
315-
metadata[marker] = metadata_data
316264

317265
# Convert file path to module path
318266
# e.g., D:\...\tests\api\integration_tests\test_suite_custom_property\generate_test_data_custom_property.py
@@ -321,7 +269,7 @@ def fetch_data_on_markers(
321269
module_path = str(relative_path.with_suffix('')).replace(os.sep, '.')
322270

323271
run_command([sys.executable, '-m', module_path], ROOT_DIR)
324-
commit_data(metadata)
272+
commit_data()
325273
return 0
326274

327275

tests/api/integration_tests/data_generation/generate_data_logger.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import sys
99
from pathlib import Path
1010
from typing import Dict, Set
11-
from tests.api.integration_tests.constants import METADATA_FILE
1211

1312

1413
class GenerateDataLogger:
1514
"""A clean, professional logger for data generation scripts."""
1615

1716
def __init__(self):
1817
self.generated_files: Dict[str, Set[str]] = {}
19-
self.metadata_file = METADATA_FILE
2018

2119
def track_generation(self, marker: str, data_file_name: str):
2220
"""Track a generated file for a specific marker."""

tests/api/integration_tests/metadata.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)