-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add tests for yaml_wrapper #107
Conversation
7723966
to
e97c5fe
Compare
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.
Well done!
I have one comment: could you please add tests for dict/mapping as well? So we can cover the YamlWrapper
functionality once and for all.
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.
Reviewed-by: Volodymyr Babchuk <[email protected]>
Currently moulin crashes when it tries to check if the default value is a list. Add support for storing lists to the _YamlDefaultValue. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]>
as_float func was checking for int type, probably due to copy-paste error. This patch fixes the type check to float. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]>
The error messages for the _YamlDefaultValue class are not consistent with the YamlValue class. Make them more similar where possible. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]>
Writing unit tests uncovered two bugs in the setitem method of the YamlValue class. 1. The method was raising exceptions with valid inputs. 2. Due to caching in yaml module, the new value was not being set. This commit fixes both issues by: 1. Hiding the exception raising code behind an else statement. 2. Replace the whole node, instead of trying to update it. replace_value method was removed, as it was no longer needed. Private _represent_value method was added to unify scalar node creation. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]>
Adding dict support to _YamlDefaultValue class will fully unify it with the YamlValue class. This will allow to safely use default nodes in place of the real ones. Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]>
This patch adds tests for Yaml wrapper. It tests the following methods in YamlValue and _YamlDefaultValue classes: - as_str - as_int - as_float - as_bool - is_list - keys - items - get - __getitem__ - __setitem__ - __len__ - __iter__ Signed-off-by: Mykyta Poturai <[email protected]> Reviewed-by: Volodymyr Babchuk <[email protected]>
Add tests that ensure that YamlValue and YamlDefaultValue provide the same API, and that the API is working. Fix the bugs that came up during testing.