Exemplo n.º 1
0
def test_get_check_plugin_names_requires_type_filter_function_and_ipaddress(monkeypatch, ipaddress):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = SNMPDataSource(hostname, ipaddress)

    with pytest.raises(Exception):
        source.get_check_plugin_names()

    # One filter function is defined in cmk.base.inventory and another one in snmp_scan.
    def dummy_filter_func(host_config, on_error, do_snmp_scan, for_mgmt_board=False):
        return set()

    source.set_check_plugin_name_filter(dummy_filter_func)
    if ipaddress is None:
        with pytest.raises(NotImplementedError):
            source.get_check_plugin_names()
    else:
        assert source.get_check_plugin_names() == set()
Exemplo n.º 2
0
def test_detector_requires_type_filter_function_and_ipaddress(
        monkeypatch, ipaddress):
    hostname = "testhost"
    Scenario().add_host(hostname).apply(monkeypatch)
    source = SNMPDataSource(hostname, ipaddress)

    with pytest.raises(Exception):
        source._get_raw_section_names_to_process()

    def dummy_filter_func(sections, on_error, do_snmp_scan, *, binary_host,
                          backend):
        return set()

    source.set_check_plugin_name_filter(dummy_filter_func, inventory=False)
    if ipaddress is None:
        with pytest.raises(NotImplementedError):
            source._get_raw_section_names_to_process()
    else:
        assert source._get_raw_section_names_to_process() == set()