Skip to content

Commit

Permalink
infering from list of lists added test
Browse files Browse the repository at this point in the history
  • Loading branch information
kudj committed Jan 8, 2025
1 parent 656404c commit 48f9c7c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python-sync-actions/src/actions/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def __init__(self):

def parse_row(self, row: dict[str, Any]):
current_path = []

if isinstance(row, list):
row = row[0]

for name, value in row.items():
self.analyzer.analyze_object(current_path, name, value)

Expand Down
67 changes: 67 additions & 0 deletions python-sync-actions/tests/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,70 @@ def test_infer_mapping_userdata_child(self):
expected_output = {'id': 'id',
'status': 'status'}
self.assertEqual(output, expected_output)

def test_types(self):
data = [[
{
'id': 'asdf',
'firstWorkingDay': '2024-07-16',
'workingDays': [
{
'day': 'monday'
},
{
'day': 'tuesday'
},
{
'day': 'wednesday'
},
{
'day': 'thursday'
},
{
'day': 'friday'
}
],
'teams': [
{
'name': 'Dream Team',
}
]
},
{
'id': 'asdf2',
'firstWorkingDay': '2024-07-16',
'workingDays': [
{
'day': 'monday'
},
{
'day': 'tuesday'
},
{
'day': 'wednesday'
},
{
'day': 'thursday'
},
{
'day': 'friday'
}
],
'teams': [
{
'name': 'Dream Team',
}
]
}]]

expected = {'firstWorkingDay': 'firstWorkingDay',
'id': 'id',
'teams': {'forceType': True,
'mapping': {'destination': 'teams'},
'type': 'column'},
'workingDays': {'forceType': True,
'mapping': {'destination': 'workingDays'},
'type': 'column'}}
res = infer_mapping(data, max_level_nest_level=1)

self.assertEqual(res, expected)

0 comments on commit 48f9c7c

Please sign in to comment.