Exemplo n.º 1
0
def test_create_list_file(mock_delete, mock_chmod):
    """Test that create_list_file function works as expected"""

    with open(os.path.join(common.ossec_path, PATH_FILE)) as f:
        with patch('wazuh.core.cdb_list.common.ossec_path', new='/var/ossec'):
            with patch('builtins.open') as mock_open:
                ossec_cdb_list = f.read()
                result = create_list_file('/test/path', ossec_cdb_list, permissions=0o660)
                assert mock_open.return_value.__enter__().write.call_count == len(ossec_cdb_list.split('\n'))-1

    mock_chmod.assert_called_once_with('/test/path', 0o660)
Exemplo n.º 2
0
def test_create_list_file_ko():
    """Test that create_list_file function works and methods inside are called with expected parameters."""
    with pytest.raises(WazuhError, match=r'\b1806\b'):
        create_list_file(full_path='/test/path', content=' ')