@@ -6343,3 +6343,62 @@ def test_field_mapping_errors_report_is_json_serializable(mocked_file_mapper):
63436343 assert "FieldMappingErrors" in payload
63446344 assert isinstance (payload ["FieldMappingErrors" ], dict )
63456345 assert payload ["FieldMappingErrors" ]["Required properties missing in poLines item\t orderFormat,source" ] == 1
6346+
6347+
6348+ def test_nested_object_fields_under_array_item_are_local_to_item (
6349+ mocked_folio_client , mocked_file_mapper
6350+ ):
6351+ schema = {
6352+ "$schema" : "http://json-schema.org/draft-04/schema#" ,
6353+ "type" : "object" ,
6354+ "properties" : {
6355+ "id" : {"type" : "string" },
6356+ "lines" : {
6357+ "type" : "array" ,
6358+ "items" : {
6359+ "type" : "object" ,
6360+ "properties" : {
6361+ "title" : {"type" : "string" },
6362+ "source" : {"type" : "string" },
6363+ "cost" : {
6364+ "type" : "object" ,
6365+ "properties" : {
6366+ "currency" : {"type" : "string" },
6367+ "listUnitPrice" : {"type" : "number" },
6368+ },
6369+ },
6370+ },
6371+ "required" : ["title" , "source" ],
6372+ },
6373+ },
6374+ },
6375+ "required" : [],
6376+ }
6377+ record = {
6378+ "id" : "rec-1" ,
6379+ "line_title" : "Example title" ,
6380+ "line_source" : "API" ,
6381+ }
6382+ the_map = {
6383+ "data" : [
6384+ {"folio_field" : "legacyIdentifier" , "legacy_field" : "id" , "value" : "" , "description" : "" },
6385+ {"folio_field" : "lines[0].title" , "legacy_field" : "line_title" , "value" : "" , "description" : "" },
6386+ {"folio_field" : "lines[0].source" , "legacy_field" : "line_source" , "value" : "" , "description" : "" },
6387+ {"folio_field" : "lines[0].cost.currency" , "legacy_field" : "" , "value" : "USD" , "description" : "" },
6388+ {"folio_field" : "lines[0].cost.listUnitPrice" , "legacy_field" : "" , "value" : 10.5 , "description" : "" },
6389+ ]
6390+ }
6391+ mapper = MappingFileMapperBase (
6392+ mocked_folio_client ,
6393+ schema ,
6394+ the_map ,
6395+ None ,
6396+ FOLIONamespaces .orders ,
6397+ mocked_classes .get_mocked_library_config (),
6398+ mocked_file_mapper .task_configuration ,
6399+ )
6400+
6401+ folio_rec , _ = mapper .do_map (record , record ["id" ], FOLIONamespaces .orders )
6402+
6403+ assert folio_rec ["lines" ][0 ]["cost" ]["currency" ] == "USD"
6404+ assert folio_rec ["lines" ][0 ]["cost" ]["listUnitPrice" ] == 10.5
0 commit comments