-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Feature/#521 refactor code for databricks integration #2284
Changes from 7 commits
309fceb
a8c8396
7996e5f
f986964
3611990
41a7a60
03fe9a6
be1d263
0e445b9
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 |
---|---|---|
|
@@ -513,12 +513,12 @@ def test_check_callable_properties(self, caplog): | |
Config.check() | ||
assert len(Config._collector.errors) == 2 | ||
expected_error_message_1 = ( | ||
"`write_query_builder` of DataNodeConfig `new` must be populated with a Callable function." | ||
"`write_query_builder` of DataNodeConfig `new` must be populated with a Callable." | ||
" Current value of property `write_query_builder` is 1." | ||
) | ||
assert expected_error_message_1 in caplog.text | ||
expected_error_message_2 = ( | ||
"`append_query_builder` of DataNodeConfig `new` must be populated with a Callable function." | ||
"`append_query_builder` of DataNodeConfig `new` must be populated with a Callable." | ||
" Current value of property `append_query_builder` is 2." | ||
) | ||
assert expected_error_message_2 in caplog.text | ||
|
@@ -530,7 +530,7 @@ def test_check_callable_properties(self, caplog): | |
Config.check() | ||
assert len(Config._collector.errors) == 1 | ||
expected_error_messages = [ | ||
"`write_fct` of DataNodeConfig `new` must be populated with a Callable function. Current value" | ||
"`write_fct` of DataNodeConfig `new` must be populated with a Callable. Current value" | ||
" of property `write_fct` is 12.", | ||
] | ||
assert all(message in caplog.text for message in expected_error_messages) | ||
|
@@ -542,7 +542,7 @@ def test_check_callable_properties(self, caplog): | |
Config.check() | ||
assert len(Config._collector.errors) == 1 | ||
expected_error_messages = [ | ||
"`read_fct` of DataNodeConfig `new` must be populated with a Callable function. Current value" | ||
"`read_fct` of DataNodeConfig `new` must be populated with a Callable. Current value" | ||
" of property `read_fct` is 5.", | ||
] | ||
assert all(message in caplog.text for message in expected_error_messages) | ||
|
@@ -554,9 +554,9 @@ def test_check_callable_properties(self, caplog): | |
Config.check() | ||
assert len(Config._collector.errors) == 2 | ||
expected_error_messages = [ | ||
"`write_fct` of DataNodeConfig `new` must be populated with a Callable function. Current value" | ||
"`write_fct` of DataNodeConfig `new` must be populated with a Callable. Current value" | ||
" of property `write_fct` is 9.", | ||
"`read_fct` of DataNodeConfig `new` must be populated with a Callable function. Current value" | ||
"`read_fct` of DataNodeConfig `new` must be populated with a Callable. Current value" | ||
" of property `read_fct` is 5.", | ||
] | ||
assert all(message in caplog.text for message in expected_error_messages) | ||
|
@@ -581,6 +581,22 @@ def test_check_callable_properties(self, caplog): | |
Config.check() | ||
assert len(Config._collector.errors) == 0 | ||
|
||
config._sections[DataNodeConfig.name]["new"].storage_type = "generic" | ||
config._sections[DataNodeConfig.name]["new"].properties = {"write_fct": lambda x: x, "read_fct": lambda y: y} | ||
with pytest.raises(SystemExit): | ||
Config._collector = IssueCollector() | ||
Config.check() | ||
assert len(Config._collector.errors) == 2 | ||
expected_error_messages = [ | ||
"`write_fct` of DataNodeConfig `new` must be populated with a Callable and not a lambda." | ||
" Current value of property `write_fct` is <function TestDataNodeConfigChecker." | ||
"test_check_callable_properties.<locals>.<lambda>", | ||
"`read_fct` of DataNodeConfig `new` must be populated with a Callable and not a lambda." | ||
" Current value of property `read_fct` is <function TestDataNodeConfigChecker." | ||
"test_check_callable_properties.<locals>.<lambda>", | ||
] | ||
assert all(message in caplog.text for message in expected_error_messages) | ||
|
||
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. BTW, this deserves:
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. The PR I have created for this topic also contains changes required to the doc. https://github.com/orgs/Avaiga/projects/6/views/2?pane=issue&itemId=89479596 |
||
def test_check_read_write_fct_args(self, caplog): | ||
config = Config._applied_config | ||
Config._compile_configs() | ||
|
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.
We should also add all the properties to check. not only the callable.
The dictionary should be moved close to the definition of the properties, in the DataNodeCOnfig class.
The format seems strange to me. I would have used a
Dict[str, Dict[str, Any]]
instead ofDict[str, List[Tuple[Any, List[str]]]]
What do you think? Is there a reason to group the properties by type?
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.
Ah sure, well don't have much reason haha. Since the original code focused mainly on Callable, I just went along with that :D I have created a ticket to resolve this if you're okay with that since the changes are bigger than what we're having atm. https://github.com/orgs/Avaiga/projects/6/views/2?pane=issue&itemId=89479596
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.
Great. Thx!