<commit_before># (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)

import pytest

from datadog_checks.dev.utils import get_metadata_metrics
from datadog_checks.snmp import SnmpCheck

from . import common
from .metrics import (
    ADAPTER_IF_COUNTS,
    CIE_METRICS,
    CPU_METRICS,
    DISK_GAUGES,
    DRS_GAUGES,
    FRU_METRICS,
    IF_COUNTS,
    IF_GAUGES,
    IF_RATES,
    IP_COUNTS,
    IP_IF_COUNTS,
    IPX_COUNTS,
    LTM_GAUGES,
    LTM_NODES_COUNTS,
    LTM_NODES_GAUGES,
    LTM_NODES_RATES,
    LTM_POOL_COUNTS,
    LTM_POOL_GAUGES,
    LTM_POOL_MEMBER_COUNTS,
    LTM_POOL_MEMBER_GAUGES,
    LTM_POOL_MEMBER_RATES,
    LTM_POOL_RATES,
    LTM_VIRTUAL_SERVER_COUNTS,
    LTM_VIRTUAL_SERVER_GAUGES,
    LTM_VIRTUAL_SERVER_RATES,
    MEMORY_METRICS,
    PEER_GAUGES,
    PEER_RATES,
    PROBE_GAUGES,
    SYSTEM_STATUS_GAUGES,
    TCP_COUNTS,
    TCP_GAUGES,
    UDP_COUNTS,
    VOLTAGE_GAUGES,
)

pytestmark = pytest.mark.usefixtures("dd_environment")


def run_profile_check(recording_name):
    """
    Run a single check with the provided `recording_name` used as
    `community_string` by the docker SNMP endpoint.
    """
    instance = common.generate_instance_config([])

    instance['community_string'] = recording_name
    instance['enforce_mib_constraints'] = False
    check = SnmpCheck('snmp', {}, [instance])
    check.check(instance)


def test_cisco_voice(aggregator):
    run_profile_check('cisco_icm')<commit_msg>Add profile syntax test (#6613)<commit_after># (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)
import pytest

from datadog_checks.base import ConfigurationError
from datadog_checks.dev.utils import get_metadata_metrics
from datadog_checks.snmp import SnmpCheck

from . import common
from .metrics import (
    ADAPTER_IF_COUNTS,
    CIE_METRICS,
    CPU_METRICS,
    DISK_GAUGES,
    DRS_GAUGES,
    FRU_METRICS,
    IF_COUNTS,
    IF_GAUGES,
    IF_RATES,
    IP_COUNTS,
    IP_IF_COUNTS,
    IPX_COUNTS,
    LTM_GAUGES,
    LTM_NODES_COUNTS,
    LTM_NODES_GAUGES,
    LTM_NODES_RATES,
    LTM_POOL_COUNTS,
    LTM_POOL_GAUGES,
    LTM_POOL_MEMBER_COUNTS,
    LTM_POOL_MEMBER_GAUGES,
    LTM_POOL_MEMBER_RATES,
    LTM_POOL_RATES,
    LTM_VIRTUAL_SERVER_COUNTS,
    LTM_VIRTUAL_SERVER_GAUGES,
    LTM_VIRTUAL_SERVER_RATES,
    MEMORY_METRICS,
    PEER_GAUGES,
    PEER_RATES,
    PROBE_GAUGES,
    SYSTEM_STATUS_GAUGES,
    TCP_COUNTS,
    TCP_GAUGES,
    UDP_COUNTS,
    VOLTAGE_GAUGES,
)

pytestmark = pytest.mark.usefixtures("dd_environment")


def test_load_profiles():
    instance = common.generate_instance_config([])
    check = SnmpCheck('snmp', {}, [instance])
    for name, profile in check.profiles.items():
        try:
            check._config.refresh_with_profile(profile)
        except ConfigurationError as e:
            pytest.fail("Profile `{}` is not configured correctly: {}".format(name, e))


def run_profile_check(recording_name):
    """
    Run a single check with the provided `recording_name` used as
    `community_string` by the docker SNMP endpoint.
    """
    instance = common.generate_instance_config([])

    instance['community_string'] = recording_name
    instance['enforce_mib_constraints'] = False
    check = SnmpCheck('snmp', {}, [instance])
    check.check(instance)


def test_cisco_voice(aggregator):
    run_profile_check('cisco_icm')
{'fraction_non_alphanumeric': 0.08002319512902291, 'fraction_numerical': 0.0034792693534357786, 'mean_word_length': 3.838709677419355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2732506', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1316, 'n_words': 228}