-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(low-code): added flatten_lists option to FlattenFields transformation #206
base: main
Are you sure you want to change the base?
Changes from 3 commits
89b0be5
f468844
ec5eb16
87bcbee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,12 @@ | |
|
||
|
||
@pytest.mark.parametrize( | ||
"input_record, expected_output", | ||
"flatten_lists, input_record, expected_output", | ||
[ | ||
({"FirstName": "John", "LastName": "Doe"}, {"FirstName": "John", "LastName": "Doe"}), | ||
({"123Number": 123, "456Another123": 456}, {"123Number": 123, "456Another123": 456}), | ||
(True, {"FirstName": "John", "LastName": "Doe"}, {"FirstName": "John", "LastName": "Doe"}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really attached to this but I'm wondering what is your opinion on this. It is becoming harder and harder when we have a lot of cases to relate to which parameter is what. Do you think it would be overkill to have |
||
(True, {"123Number": 123, "456Another123": 456}, {"123Number": 123, "456Another123": 456}), | ||
( | ||
True, | ||
{ | ||
"NestedRecord": {"FirstName": "John", "LastName": "Doe"}, | ||
"456Another123": 456, | ||
|
@@ -26,10 +27,12 @@ | |
}, | ||
), | ||
( | ||
True, | ||
{"ListExample": [{"A": "a"}, {"A": "b"}]}, | ||
{"ListExample.0.A": "a", "ListExample.1.A": "b"}, | ||
), | ||
( | ||
True, | ||
{ | ||
"MixedCase123": { | ||
"Nested": [{"Key": {"Value": "test1"}}, {"Key": {"Value": "test2"}}] | ||
|
@@ -43,12 +46,44 @@ | |
}, | ||
), | ||
( | ||
True, | ||
{"List": ["Item1", "Item2", "Item3"]}, | ||
{"List.0": "Item1", "List.1": "Item2", "List.2": "Item3"}, | ||
), | ||
( | ||
False, | ||
{"List": ["Item1", "Item2", "Item3"]}, | ||
{"List": ["Item1", "Item2", "Item3"]}, | ||
), | ||
( | ||
False, | ||
{ | ||
"RootField": { | ||
"NestedList": [{"Key": {"Value": "test1"}}, {"Key": {"Value": "test2"}}] | ||
}, | ||
"SimpleKey": "SimpleValue", | ||
}, | ||
{ | ||
"NestedList": [{"Key": {"Value": "test1"}}, {"Key": {"Value": "test2"}}], | ||
"SimpleKey": "SimpleValue", | ||
}, | ||
), | ||
( | ||
False, | ||
{ | ||
"RootField": {"List": [{"Key": {"Value": "test1"}}, {"Key": {"Value": "test2"}}]}, | ||
"List": [1, 3, 6], | ||
"SimpleKey": "SimpleValue", | ||
}, | ||
{ | ||
"RootField.List": [{"Key": {"Value": "test1"}}, {"Key": {"Value": "test2"}}], | ||
"List": [1, 3, 6], | ||
"SimpleKey": "SimpleValue", | ||
}, | ||
), | ||
], | ||
) | ||
def test_flatten_fields(input_record, expected_output): | ||
flattener = FlattenFields() | ||
def test_flatten_fields(flatten_lists, input_record, expected_output): | ||
flattener = FlattenFields(flatten_lists=flatten_lists) | ||
flattener.transform(input_record) | ||
assert input_record == expected_output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this a private fields by prefixing this by
_
?