def cfg_setup_fixture(request, web, site: Site):
    hostname = "test-prediction"

    # Enforce use of the pre-created RRD file from the git. The restart of the core
    # is needed to make it renew it's internal RRD file cache
    site.makedirs("var/check_mk/rrd/test-prediction")
    with open(site.path("var/check_mk/rrd/test-prediction/CPU_load.rrd"), "wb") as f:
        f.write(
            Path(
                repo_path(), "tests", "integration", "cmk", "base", "test-files", "CPU_load.rrd"
            ).read_bytes()
        )

    site.write_text_file(
        "var/check_mk/rrd/test-prediction/CPU_load.info",
        Path(
            repo_path(), "tests", "integration", "cmk", "base", "test-files", "CPU_load.info"
        ).read_text(),
    )

    site.restart_core()

    create_linux_test_host(request, site, "test-prediction")

    site.write_text_file(
        "etc/check_mk/conf.d/linux_test_host_%s_cpu_load.mk" % hostname,
        """
globals().setdefault('custom_checks', [])

custom_checks = [
    ( {'service_description': u'CPU load', 'has_perfdata': True}, [], ALL_HOSTS, {} ),
] + custom_checks
""",
    )

    site.activate_changes_and_wait_for_core_reload()

    yield

    # Cleanup
    site.delete_file("etc/check_mk/conf.d/linux_test_host_%s_cpu_load.mk" % hostname)
    site.activate_changes_and_wait_for_core_reload()
    site.delete_dir("var/check_mk/rrd")
def cfg_setup_fixture(request, web, site: Site):  # noqa: F811 # pylint: disable=redefined-outer-name
    hostname = "test-prediction"

    # Enforce use of the pre-created RRD file from the git. The restart of the core
    # is needed to make it renew it's internal RRD file cache
    site.makedirs("var/check_mk/rrd/test-prediction")
    with open(site.path("var/check_mk/rrd/test-prediction/CPU_load.rrd"),
              "wb") as f:
        f.write(
            open(
                "%s/tests/integration/cmk/base/test-files/CPU_load.rrd" %
                repo_path(), "rb").read())

    site.write_text_file(
        "var/check_mk/rrd/test-prediction/CPU_load.info",
        open("%s/tests/integration/cmk/base/test-files/CPU_load.info" %
             repo_path()).read(),
    )

    site.restart_core()

    create_linux_test_host(request, web, site, "test-prediction")

    site.write_text_file(
        "etc/check_mk/conf.d/linux_test_host_%s_cpu_load.mk" % hostname,
        """
globals().setdefault('custom_checks', [])

custom_checks = [
    ( {'service_description': u'CPU load', 'has_perfdata': True}, [], ALL_HOSTS, {} ),
] + custom_checks
""",
    )

    web.activate_changes()

    yield

    # Cleanup
    site.delete_file("etc/check_mk/conf.d/linux_test_host_%s_cpu_load.mk" %
                     hostname)
    site.delete_dir("var/check_mk/rrd")