wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
60 stars 30 forks source link

DTT2 - Testing Module. Enhance the test assertions #5297

Open mhamra opened 1 week ago

mhamra commented 1 week ago
Target version Related issue Related PR/dev branch
4.9.0 #5229 PR #5264 4495-dtt1-release

Description

The assertions of the Module's tests call the logger.error method instead of returning an error message. This method returns None. The current implementation generates all the AssertionError exception messages as None. For example, this code:

https://github.com/wazuh/wazuh-qa/blob/e71e39aea2caeb0dceab9645fe4f9343152a8a83/deployability/modules/testing/tests/test_agent/test_install.py#L81

We should implement it in this way:

assert HostInformation.dir_exists(wazuh_params['master'], WAZUH_ROOT), f'The {WAZUH_ROOT} is not present in {HostInformation.get_os_name_and_version_from_inventory(wazuh_params["master"])}' 

The other important point is whether the assertion should send the errors to the log file because Pytest sends the AssertionError exception to the final report.

Related PR comment: comment