def test_get_rules_file_failed(mock_config, item, file_, error_code): """Test downloading a specified rule filter.""" with patch('wazuh.rule.get_rules_files', return_value=AffectedItemsWazuhResult( all_msg='test', affected_items=item)): result = rule.get_rule_file(filename=file_) assert not result.affected_items assert result.render()['data']['failed_items'][0]['error']['code'] == error_code
def test_get_rules_file(mock_config, file_, raw): """Test downloading a specified rule filter.""" d_files = rule.get_rule_file(filename=file_, raw=raw) if raw: assert isinstance(d_files, str) else: assert isinstance(d_files, AffectedItemsWazuhResult) assert d_files.affected_items assert not d_files.failed_items
def test_get_rules_file_invalid_xml(get_rules_mock): """Test downloading a rule with invalid XML.""" result = rule.get_rule_file(filename='test_invalid_rules.xml') assert not result.affected_items assert result.render()['data']['failed_items'][0]['error']['code'] == 1413