<commit_before>"""
    :codeauthor: :email:`<NAME> <<EMAIL>>`
"""

import pytest

import salt.grains.napalm as napalm_grains
import salt.proxy.napalm as napalm_proxy
import tests.support.napalm as napalm_test_support
from tests.support.mock import MagicMock, patch


@pytest.fixture
def configure_loader_modules():
    patcher = patch.object(
        napalm_grains.salt.utils.napalm, "is_proxy", MagicMock(return_value=True)
    )
    patcher.start()
    test_device_cache = {
        "DRIVER": napalm_test_support.MockNapalmDevice(),
        "DRIVER_NAME": "cisco",
        "OS_VERSION": "1.2.3",
        "HOSTNAME": "test-device.com",
        "USERNAME": "admin",
    }

    test_cache = {"result": True, "out": napalm_test_support.TEST_FACTS}
    module_globals = {
        "__salt__": {
            "config.option": MagicMock(
                return_value={"test": {"driver": "test", "key": "<KEY>"}}
            ),
            "file.file_exists": napalm_test_support.true,
            "file.join": napalm_test_support.join,
            "file.get_managed": napalm_test_support.get_managed_file,
            "random.hash": napalm_test_support.random_hash,
        }
    }
    device_cache_patcher = patch("salt.grains.napalm.DEVICE_CACHE", test_device_cache)
    grains_cache_patcher = patch("salt.grains.napalm.GRAINS_CACHE", test_cache)

    with device_cache_patcher, grains_cache_patcher:
        yield {napalm_grains: module_globals}


def test_os():
    ret = napalm_grains.getos(proxy=napalm_proxy)
    assert ret["os"] == "cisco"


def test_os_version():
    ret = napalm_grains.version(proxy=napalm_proxy)
    assert ret["version"] == "1.2.3"

<commit_msg>fix patcher being left on<commit_after>"""
    :codeauthor: :email:`<NAME> <<EMAIL>>`
"""

import pytest

import salt.grains.napalm as napalm_grains
import salt.proxy.napalm as napalm_proxy
import tests.support.napalm as napalm_test_support
from tests.support.mock import MagicMock, patch


@pytest.fixture
def configure_loader_modules():
    test_device_cache = {
        "DRIVER": napalm_test_support.MockNapalmDevice(),
        "DRIVER_NAME": "cisco",
        "OS_VERSION": "1.2.3",
        "HOSTNAME": "test-device.com",
        "USERNAME": "admin",
    }

    test_cache = {"result": True, "out": napalm_test_support.TEST_FACTS}
    module_globals = {
        "__salt__": {
            "config.option": MagicMock(
                return_value={"test": {"driver": "test", "key": "<KEY>"}}
            ),
            "file.file_exists": napalm_test_support.true,
            "file.join": napalm_test_support.join,
            "file.get_managed": napalm_test_support.get_managed_file,
            "random.hash": napalm_test_support.random_hash,
        }
    }
    device_cache_patcher = patch("salt.grains.napalm.DEVICE_CACHE", test_device_cache)
    grains_cache_patcher = patch("salt.grains.napalm.GRAINS_CACHE", test_cache)
    is_proxy_patcher = patch.object(
        napalm_grains.salt.utils.napalm, "is_proxy", MagicMock(return_value=True)
    )

    with device_cache_patcher, grains_cache_patcher, is_proxy_patcher:
        yield {napalm_grains: module_globals}


def test_os():
    ret = napalm_grains.getos(proxy=napalm_proxy)
    assert ret["os"] == "cisco"


def test_os_version():
    ret = napalm_grains.version(proxy=napalm_proxy)
    assert ret["version"] == "1.2.3"


{'fraction_non_alphanumeric': 0.1293591654247392, 'fraction_numerical': 0.0035767511177347243, 'mean_word_length': 3.3697916666666665, 'pattern_counts': {'":': 32, '<': 11, '<?xml version=': 0, '>': 11, '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': '4810999', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1128, 'n_words': 186}