<commit_before>"""
Tests for salt.modules.linux_sysctl module

:codeauthor: jmoney <<EMAIL>>
"""

import pytest
import salt.modules.linux_sysctl as linux_sysctl
import salt.modules.systemd_service as systemd
from salt.exceptions import CommandExecutionError
from tests.support.mock import MagicMock, mock_open, patch


@pytest.fixture
def configure_loader_modules():
    return {linux_sysctl: {}, systemd: {}}


def test_get():
    """
    Tests the return of get function
    """
    mock_cmd = MagicMock(return_value=1)
    with patch.dict(linux_sysctl.__salt__, {"cmd.run": mock_cmd}):
        assert linux_sysctl.get("net.ipv4.ip_forward") == 1


def test_get_no_sysctl_binary():
    """
    Tests the failure of get function when no binary exists
    """
    with patch("salt.utils.path.which", MagicMock(return_value=None)):
        with pytest.raises(CommandExecutionError):
            linux_sysctl.get("net.ipv4.ip_forward")<commit_msg>skip sysctl tests on windows since the utility isnt present<commit_after>"""
Tests for salt.modules.linux_sysctl module

:codeauthor: jmoney <<EMAIL>>
"""

import pytest
import salt.modules.linux_sysctl as linux_sysctl
import salt.modules.systemd_service as systemd
from salt.exceptions import CommandExecutionError
from tests.support.mock import MagicMock, mock_open, patch

pytestmark = [
    pytest.mark.skip_on_windows(reason="sysctl not available on Windows"),
]


@pytest.fixture
def configure_loader_modules():
    return {linux_sysctl: {}, systemd: {}}


def test_get():
    """
    Tests the return of get function
    """
    mock_cmd = MagicMock(return_value=1)
    with patch.dict(linux_sysctl.__salt__, {"cmd.run": mock_cmd}):
        assert linux_sysctl.get("net.ipv4.ip_forward") == 1


def test_get_no_sysctl_binary():
    """
    Tests the failure of get function when no binary exists
    """
    with patch("salt.utils.path.which", MagicMock(return_value=None)):
        with pytest.raises(CommandExecutionError):
            linux_sysctl.get("net.ipv4.ip_forward")
{'fraction_non_alphanumeric': 0.10990635781172992, 'fraction_numerical': 0.003942828979793002, 'mean_word_length': 4.37037037037037, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3947192', 'n_tokens_mistral': 645, 'n_tokens_neox': 636, 'n_words': 152}