@@ -109,18 +109,40 @@ def test_base_translator_final_validation_failure():
109109# New test for Translator.run with employment preferences mapping
110110@pytest .mark .asyncio
111111async def test_translator_run_with_employment_preferences (monkeypatch ):
112- # Input data from the prompt
112+ # Input data matching the r1_demo_data structure in example_data_source_rest_api/core.py
113113 input_data = {
114114 "person" : {
115115 "id" : "100001" ,
116- "employment" : {"preferences" : {"preferred_org_types" : ["Public Sector" , "Private Sector" ]}},
116+ "employment" : {
117+ "preferences" : {
118+ "id" : "employment-preferences-100001-001" ,
119+ "preferred_org_types" : ["Public Sector" , "Private Sector" ],
120+ "preferred_org_names" : ["Government Agencies" , "Technology Companies" ],
121+ }
122+ },
117123 }
118124 }
119125
120- # Expected result from the prompt
121- expected = {"Person" : [{"EmploymentPreferences" : [{"organizationTypes" : ["Public Sector" , "Private Sector" ]}]}]}
126+ # Expected LIF output matching new-lif-schema.json EmploymentPreferences requirements
127+ expected = {
128+ "Person" : [
129+ {
130+ "EmploymentPreferences" : [
131+ {
132+ "identifier" : "employment-preferences-100001-001" ,
133+ "organizationTypes" : ["Public Sector" , "Private Sector" ],
134+ "organizationNames" : ["Government Agencies" , "Technology Companies" ],
135+ }
136+ ]
137+ }
138+ ]
139+ }
122140
123- # Transformation payload mimicking the MDR response in transformations_for_26_to_17.json
141+ # Transformation payload mimicking the MDR response
142+ # Maps source fields to LIF EmploymentPreferences fields:
143+ # person.employment.preferences.id -> EmploymentPreferences.identifier
144+ # person.employment.preferences.preferred_org_types -> EmploymentPreferences.organizationTypes
145+ # person.employment.preferences.preferred_org_names -> EmploymentPreferences.organizationNames
124146 transformation_payload = {
125147 "total" : 2 ,
126148 "page" : 1 ,
@@ -138,7 +160,7 @@ async def test_translator_run_with_employment_preferences(monkeypatch):
138160 "TransformationGroupDescription" : None ,
139161 "TransformationGroupNotes" : None ,
140162 "TransformationId" : 1375 ,
141- "TransformationExpression" : '{ "Person": [{ "EmploymentPreferences": [{ "organizationTypes": person.employment.preferences.preferred_org_types }] }] }' ,
163+ "TransformationExpression" : '{ "Person": [{ "EmploymentPreferences": [{ "identifier": person.employment.preferences.id, " organizationTypes": person.employment.preferences.preferred_org_types, "organizationNames": person.employment.preferences.preferred_org_names }] }] }' ,
142164 "TransformationExpressionLanguage" : "JSONata" ,
143165 "TransformationNotes" : None ,
144166 "TransformationAlignment" : None ,
@@ -148,6 +170,19 @@ async def test_translator_run_with_employment_preferences(monkeypatch):
148170 "TransformationContributor" : None ,
149171 "TransformationContributorOrganization" : None ,
150172 "TransformationSourceAttributes" : [
173+ {
174+ "AttributeId" : 1896 ,
175+ "EntityId" : 377 ,
176+ "AttributeName" : "id" ,
177+ "AttributeType" : "Source" ,
178+ "Notes" : None ,
179+ "CreationDate" : None ,
180+ "ActivationDate" : None ,
181+ "DeprecationDate" : None ,
182+ "Contributor" : None ,
183+ "ContributorOrganization" : None ,
184+ "EntityIdPath" : "person.employment.preferences" ,
185+ },
151186 {
152187 "AttributeId" : 1895 ,
153188 "EntityId" : 377 ,
@@ -160,7 +195,20 @@ async def test_translator_run_with_employment_preferences(monkeypatch):
160195 "Contributor" : None ,
161196 "ContributorOrganization" : None ,
162197 "EntityIdPath" : "person.employment.preferences" ,
163- }
198+ },
199+ {
200+ "AttributeId" : 1897 ,
201+ "EntityId" : 377 ,
202+ "AttributeName" : "preferred_org_names" ,
203+ "AttributeType" : "Source" ,
204+ "Notes" : None ,
205+ "CreationDate" : None ,
206+ "ActivationDate" : None ,
207+ "DeprecationDate" : None ,
208+ "Contributor" : None ,
209+ "ContributorOrganization" : None ,
210+ "EntityIdPath" : "person.employment.preferences" ,
211+ },
164212 ],
165213 "TransformationTargetAttribute" : {
166214 "AttributeId" : 1876 ,
0 commit comments