def testGettingBackendManagerWithCustomConfig(tempDir):
    backendsDir = os.path.join(tempDir, 'backendsss')
    bmDir = os.path.join(tempDir, 'bm')
    dispatchConfig = os.path.join(bmDir, 'dispatch.conf')
    extensionDir = os.path.join(bmDir, 'extension')

    os.mkdir(bmDir)
    os.mkdir(extensionDir)
    os.mkdir(backendsDir)

    with open(dispatchConfig, 'w') as dpconf:
        dpconf.write("""
.* : file
""")

    kwargs = {
        "dispatchConfigFile": dispatchConfig,
        "backendConfigDir": backendsDir,
        "extensionConfigDir": extensionDir,
    }

    with getFileBackend(path=tempDir):
        # We need to make sure there is a file.conf for the backend.
        os.link(os.path.join(tempDir, 'etc', 'opsi', 'backends', 'file.conf'),
                os.path.join(backendsDir, 'file.conf'))

    backend = BackendManager(**kwargs)
    assert backend.backend_info()
def testGettingBackendManagerWithDefaultConfig():
    requiredPaths = (
        u'/etc/opsi/backendManager/dispatch.conf',
        u'/etc/opsi/backends',
        u'/etc/opsi/backendManager/extend.d',
        u'/var/lib/opsi/config/depots',
    )

    for path in requiredPaths:
        if not os.path.exists(path):
            pytest.skip("Missing {0}".format(path))

    backend = BackendManager()
    assert backend.backend_info()