Exception on malformatted unit tests in YMLs #300
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes two additional fixes:
Raise exception on parse of unittest from yml.
Do this rather than trying to convert it into an integrationtest or manualtest.
For example, the following YML section is NOT if the file test_data.log does not exist:
Because the typing of detection.tests is as follows (since additional tests will be created at runtime):
contentctl/contentctl/objects/abstract_security_content_objects/detection_abstract.py
Line 88 in 5488ca6
if it fails to parse from YML as UnitTest, it will then try to parse as the other types (which may pass - but we do not want this behavior).
https://github.com/splunk/contentctl/blob/main/contentctl/objects/unit_test.py
For example, this will construct a VALID Integration Test (which is not desired behavior):
https://github.com/splunk/contentctl/blob/main/contentctl/objects/integration_test.py
This PR cause a ValueError to be generated if the data read from the YML cannot be used to create a valid UnitTest.