Skip to content

Commit 0e3568f

Browse files
authored
Issue LIF-Initiative#771: Setup initial transformation auto test (LIF-Initiative#789)
##### Description of Change Adds the following flows into an auto test, and leverages new helper methods to promote easier building of future scenarios. - create transformation group - create transformation - translate (via the Translator) Needed a slight adjustment to the mdr_client code to override calling MDR from the component. ##### Related Issues LIF-Initiative#771 ##### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] commit message follows commit guidelines (see commitlint.config.mjs) - [x] tests are included (unit and/or integration tests) - [x] all tests are successful - [ ] documentation is changed or added (in /docs directory) - [ ] code passes linting checks (`uv run ruff check`) - [ ] code passes formatting checks (`uv run ruff format`) - [ ] code passes type checking (`uv run ty check`) - [x] pre-commit hooks have been run successfully - [ ] database schema changes: migration files created and CHANGELOG.md updated - [ ] API changes: base (Python code) documentation in `docs/` and project README updated - [ ] configuration changes: relevant folder README updated - [ ] breaking changes: added to MIGRATION.md with upgrade instructions and CHANGELOG.md entry ##### Type of Change <!-- Check all that apply --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [x] Infrastructure/deployment change - [ ] Performance improvement - [x] Code refactoring ##### Testing <!-- Describe the testing you've done --> - [x] Manual testing performed - [x] Automated tests added/updated - [ ] Integration testing completed ##### Project Area(s) Affected <!-- Check all project areas affected by this change --> - [ ] bases/ - [x] components/ - [ ] orchestrators/ - [ ] frontends/ - [ ] deployments/ - [ ] CloudFormation/SAM templates - [ ] Database schema - [ ] API endpoints - [ ] Documentation - [x] Testing ##### Additional Notes <!-- Any additional information that reviewers should know -->
1 parent 5cdac95 commit 0e3568f

11 files changed

+1570
-17
lines changed

components/lif/mdr_client/core.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import json
2-
import httpx
32
import os
43
from importlib.resources import files
4+
from typing import AsyncGenerator
55

6+
import httpx
67
from lif.exceptions.core import LIFException, ResourceNotFoundException
78
from lif.logging import get_logger
89

@@ -17,6 +18,16 @@ def _get_mdr_api_auth_token() -> str:
1718
return os.getenv("LIF_MDR_API_AUTH_TOKEN", "no_auth_token_set")
1819

1920

21+
async def _get_mdr_client() -> AsyncGenerator[httpx.AsyncClient]:
22+
"""
23+
Generator that yields an httpx AsyncClient.
24+
25+
Allows a test harness to override this method to connect to an in-memory MDR instance.
26+
"""
27+
async with httpx.AsyncClient() as client:
28+
yield client
29+
30+
2031
def _get_openapi_json_filename() -> str:
2132
return os.getenv("OPENAPI_JSON_FILENAME", "openapi_constrained_with_interactions.json")
2233

@@ -71,7 +82,7 @@ async def get_data_model_schema(
7182
mdr_api_url = _get_mdr_api_url()
7283
url: str = f"{mdr_api_url}/datamodels/open_api_schema/{data_model_id}?include_attr_md={str(include_attr_md).lower()}&include_entity_md={str(include_entity_md).lower()}"
7384
try:
74-
async with httpx.AsyncClient() as client:
85+
async for client in _get_mdr_client():
7586
response = await client.get(url, headers=_build_mdr_headers())
7687
response.raise_for_status()
7788
response_json = response.json()
@@ -94,7 +105,7 @@ async def get_data_model_transformation(source_data_model_id: str, target_data_m
94105
mdr_api_url = _get_mdr_api_url()
95106
url: str = f"{mdr_api_url}/transformation_groups/transformations_for_data_models/?source_data_model_id={source_data_model_id}&target_data_model_id={target_data_model_id}&size=1000"
96107
try:
97-
async with httpx.AsyncClient() as client:
108+
async for client in _get_mdr_client():
98109
response = await client.get(url, headers=_build_mdr_headers())
99110
response.raise_for_status()
100111
response_json = response.json()

cspell.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"Dramatiq",
4848
"drivername",
4949
"dtos",
50+
"durationatprofession",
5051
"endraw",
5152
"entitya",
5253
"entityb",
@@ -80,6 +81,7 @@
8081
"langmem",
8182
"lastname",
8283
"levelname",
84+
"levelofskillability",
8385
"LIFAIAgent",
8486
"LIFCORE",
8587
"liffy",
@@ -122,6 +124,8 @@
122124
"scrapy",
123125
"sdist",
124126
"sessionmaker",
127+
"skilllevel",
128+
"skillsgainedfromcourses",
125129
"spyder",
126130
"spyderproject",
127131
"spyproject",
@@ -147,6 +151,7 @@
147151
"venv",
148152
"VITE",
149153
"webassets",
154+
"workpreference",
150155
"xform"
151156
],
152157
"ignorePaths": [
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Machine-Readable Schema for Test DM for source deep",
5+
"version": "1.0",
6+
"description": "OpenAPI Spec"
7+
},
8+
"paths": {},
9+
"components": {
10+
"schemas": {
11+
"Person": {
12+
"type": "object",
13+
"required": [],
14+
"use_recommendations": "",
15+
"SourceModel": null,
16+
"Extension": false,
17+
"Name": "Person",
18+
"DataModelId": 30,
19+
"ExtensionNotes": null,
20+
"Id": 382,
21+
"Notes": null,
22+
"Deleted": false,
23+
"UniqueName": "person",
24+
"CreationDate": null,
25+
"Tags": null,
26+
"Description": null,
27+
"ActivationDate": "2026-01-13T18:17:00+00:00",
28+
"Common": null,
29+
"UseConsiderations": null,
30+
"DeprecationDate": null,
31+
"Required": "No",
32+
"Contributor": "MDRUser",
33+
"Array": "No",
34+
"ContributorOrganization": null,
35+
"properties": {
36+
"Courses": {
37+
"type": "object",
38+
"required": [],
39+
"use_recommendations": "",
40+
"SourceModel": null,
41+
"Extension": false,
42+
"Name": "Courses",
43+
"DataModelId": 30,
44+
"ExtensionNotes": null,
45+
"Id": 383,
46+
"Notes": null,
47+
"Deleted": false,
48+
"UniqueName": "person.courses",
49+
"CreationDate": null,
50+
"Tags": null,
51+
"Description": null,
52+
"ActivationDate": "2026-01-13T18:17:00+00:00",
53+
"Common": null,
54+
"UseConsiderations": null,
55+
"DeprecationDate": null,
56+
"Required": "No",
57+
"Contributor": "MDRUser",
58+
"Array": "No",
59+
"ContributorOrganization": null,
60+
"EntityAssociationId": 186,
61+
"EntityAssociationParentEntityId": 382,
62+
"EntityAssociationRelationship": null,
63+
"EntityAssociationPlacement": "Embedded",
64+
"EntityAssociationNotes": null,
65+
"EntityAssociationCreationDate": "2026-01-13T18:18:00+00:00",
66+
"EntityAssociationActivationDate": "2026-01-13T18:18:00+00:00",
67+
"EntityAssociationDeprecationDate": null,
68+
"EntityAssociationContributor": "MDRUser",
69+
"EntityAssociationContributorOrganization": null,
70+
"EntityAssociationExtension": false,
71+
"EntityAssociationExtensionNotes": null,
72+
"EntityAssociationExtendedByDataModelId": null,
73+
"properties": {
74+
"Grade": {
75+
"Id": 1960,
76+
"Name": "Grade",
77+
"UniqueName": "person.courses.grade",
78+
"Description": null,
79+
"UseConsiderations": null,
80+
"DataModelId": 30,
81+
"DataType": "string",
82+
"ValueSetId": null,
83+
"Required": "No",
84+
"Array": "No",
85+
"SourceModel": null,
86+
"Notes": null,
87+
"CreationDate": null,
88+
"ActivationDate": "2026-01-13T18:18:00+00:00",
89+
"DeprecationDate": null,
90+
"Contributor": "MDRUser",
91+
"ContributorOrganization": null,
92+
"Extension": false,
93+
"ExtensionNotes": null,
94+
"Example": null,
95+
"Common": null,
96+
"EntityAttributeAssociationId": 2230,
97+
"EntityId": 383,
98+
"AssociationNotes": null,
99+
"AssociationCreationDate": "2026-01-13T18:18:00+00:00",
100+
"AssociationActivationDate": "2026-01-13T18:18:00+00:00",
101+
"AssociationDeprecationDate": null,
102+
"AssociationContributor": "MDRUser",
103+
"AssociationContributorOrganization": null,
104+
"AssociationExtendedByDataModelId": null
105+
},
106+
"Style": {
107+
"Id": 1962,
108+
"Name": "Style",
109+
"UniqueName": "person.courses.style",
110+
"Description": null,
111+
"UseConsiderations": null,
112+
"DataModelId": 30,
113+
"DataType": "string",
114+
"ValueSetId": null,
115+
"Required": "No",
116+
"Array": "No",
117+
"SourceModel": null,
118+
"Notes": null,
119+
"CreationDate": null,
120+
"ActivationDate": "2026-01-13T18:21:00+00:00",
121+
"DeprecationDate": null,
122+
"Contributor": "MDRUser",
123+
"ContributorOrganization": null,
124+
"Extension": false,
125+
"ExtensionNotes": null,
126+
"Example": null,
127+
"Common": null,
128+
"EntityAttributeAssociationId": 2232,
129+
"EntityId": 383,
130+
"AssociationNotes": null,
131+
"AssociationCreationDate": "2026-01-13T18:21:00+00:00",
132+
"AssociationActivationDate": "2026-01-13T18:21:00+00:00",
133+
"AssociationDeprecationDate": null,
134+
"AssociationContributor": "MDRUser",
135+
"AssociationContributorOrganization": null,
136+
"AssociationExtendedByDataModelId": null
137+
}
138+
}
139+
}
140+
}
141+
}
142+
}
143+
}
144+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Machine-Readable Schema for Test DM for target deep",
5+
"version": "1.0",
6+
"description": "OpenAPI Spec"
7+
},
8+
"paths": {},
9+
"components": {
10+
"schemas": {
11+
"User": {
12+
"type": "object",
13+
"required": [],
14+
"use_recommendations": "",
15+
"SourceModel": null,
16+
"Extension": false,
17+
"Name": "User",
18+
"DataModelId": 31,
19+
"ExtensionNotes": null,
20+
"Id": 384,
21+
"Notes": null,
22+
"Deleted": false,
23+
"UniqueName": "user",
24+
"CreationDate": null,
25+
"Tags": null,
26+
"Description": null,
27+
"ActivationDate": "2026-01-13T18:18:00+00:00",
28+
"Common": null,
29+
"UseConsiderations": null,
30+
"DeprecationDate": null,
31+
"Required": "No",
32+
"Contributor": "MDRUser",
33+
"Array": "No",
34+
"ContributorOrganization": null,
35+
"properties": {
36+
"Skills": {
37+
"type": "object",
38+
"required": [],
39+
"use_recommendations": "",
40+
"SourceModel": null,
41+
"Extension": false,
42+
"Name": "Skills",
43+
"DataModelId": 31,
44+
"ExtensionNotes": null,
45+
"Id": 385,
46+
"Notes": null,
47+
"Deleted": false,
48+
"UniqueName": "user.skills",
49+
"CreationDate": null,
50+
"Tags": null,
51+
"Description": null,
52+
"ActivationDate": "2026-01-13T18:18:00+00:00",
53+
"Common": null,
54+
"UseConsiderations": null,
55+
"DeprecationDate": null,
56+
"Required": "No",
57+
"Contributor": "MDRUser",
58+
"Array": "No",
59+
"ContributorOrganization": null,
60+
"EntityAssociationId": 187,
61+
"EntityAssociationParentEntityId": 384,
62+
"EntityAssociationRelationship": null,
63+
"EntityAssociationPlacement": "Embedded",
64+
"EntityAssociationNotes": null,
65+
"EntityAssociationCreationDate": "2026-01-13T18:18:00+00:00",
66+
"EntityAssociationActivationDate": "2026-01-13T18:18:00+00:00",
67+
"EntityAssociationDeprecationDate": null,
68+
"EntityAssociationContributor": "MDRUser",
69+
"EntityAssociationContributorOrganization": null,
70+
"EntityAssociationExtension": false,
71+
"EntityAssociationExtensionNotes": null,
72+
"EntityAssociationExtendedByDataModelId": null,
73+
"properties": {
74+
"Genre": {
75+
"Id": 1961,
76+
"Name": "Genre",
77+
"UniqueName": "user.skills.genre",
78+
"Description": null,
79+
"UseConsiderations": null,
80+
"DataModelId": 31,
81+
"DataType": "string",
82+
"ValueSetId": null,
83+
"Required": "No",
84+
"Array": "No",
85+
"SourceModel": null,
86+
"Notes": null,
87+
"CreationDate": null,
88+
"ActivationDate": "2026-01-13T18:19:00+00:00",
89+
"DeprecationDate": null,
90+
"Contributor": "MDRUser",
91+
"ContributorOrganization": null,
92+
"Extension": false,
93+
"ExtensionNotes": null,
94+
"Example": null,
95+
"Common": null,
96+
"EntityAttributeAssociationId": 2231,
97+
"EntityId": 385,
98+
"AssociationNotes": null,
99+
"AssociationCreationDate": "2026-01-13T18:19:00+00:00",
100+
"AssociationActivationDate": "2026-01-13T18:19:00+00:00",
101+
"AssociationDeprecationDate": null,
102+
"AssociationContributor": "MDRUser",
103+
"AssociationContributorOrganization": null,
104+
"AssociationExtendedByDataModelId": null
105+
}
106+
}
107+
}
108+
}
109+
}
110+
}
111+
}
112+
}

0 commit comments

Comments
 (0)