def portal_lib(request):
    use_installed = request.config.getoption("--installed-portal")
    module = import_module("univention.portal",
                           "python/",
                           "univention.portal",
                           use_installed=use_installed)
    return module
def test_setup_logger(portal_lib, request):
    use_installed = request.config.getoption("--installed-portal")
    module = import_module("univention.portal.log",
                           "python/",
                           "univention.portal.log",
                           use_installed=use_installed)
    module.setup_logger()
    unittest_logger = module.get_logger("unittest")
    unittest_logger.info("test_setup_logger works")
Example #3
0
def import_umc_module(module_id,
                      umc_src_path=None,
                      set_umc_module_fixture=True):
    python_module_name = 'univention.management.console.modules.{}'.format(
        module_id)
    if umc_src_path is None:
        umc_src_path = 'umc/python/'
    use_installed = pytest.config.getoption('--installed-umc')
    module = import_module(module_id, umc_src_path, python_module_name,
                           use_installed)
    if set_umc_module_fixture:
        umc_module_class.umc_module = module
    return module
Example #4
0
def import_udm_module(udm_path):
    python_module_name = 'univention.admin.{}'.format(udm_path)
    umc_src_path = 'modules/univention/admin'
    use_installed = pytest.config.getoption('--installed-udm')
    return import_module(udm_path, umc_src_path, python_module_name,
                         use_installed)
def user_module(request):
    use_installed = request.config.getoption("--installed-portal")
    return import_module("univention.portal.user",
                         "python/",
                         "univention.portal.user",
                         use_installed=use_installed)
def import_lib_module(name):
    use_installed = pytest.config.getoption('--installed-lib')
    return import_module(name,
                         'python/',
                         'univention.lib.{}'.format(name),
                         use_installed=use_installed)
Example #7
0
def import_appcenter_modules():
    use_installed = pytest.config.getoption('--installed-appcenter')
    local_python_path = 'python/appcenter/'
    # for pymod in glob(local_python_path + '*.py'):
    # 	name = os.path.basename(pymod)[:-3]
    import_module('listener', None, 'listener', use_installed=True)
    for name in [
            'log', 'ucr', 'utils', 'packages', 'meta', 'ini_parser',
            'settings', 'app', 'app_cache', 'udm', 'actions', 'install_checks'
    ]:
        module = import_module(name,
                               local_python_path,
                               'univention.appcenter.{}'.format(name),
                               use_installed=use_installed)
        if name == 'log':
            module.log_to_stream()
            logger = module.get_base_logger()
            for handler in logger.handlers:
                for filter in handler.filters:
                    if hasattr(filter, 'min_level'):
                        filter.min_level = logging.DEBUG
        if name == 'actions':
            if not use_installed:
                import os.path
                for pymodule in glob('python/appcenter/actions/*.py'):
                    name = os.path.basename(pymodule)[:-3]  # without .py
                    local_python_path = os.path.dirname(pymodule)
                    import_module(
                        name,
                        local_python_path,
                        'univention.appcenter.actions.{}'.format(name),
                        use_installed=use_installed)
                for pymodule in glob(
                        'python/appcenter-docker/actions/service.py'):
                    name = os.path.basename(pymodule)[:-3]  # without .py
                    local_python_path = os.path.dirname(pymodule)
                    import_module(
                        name,
                        local_python_path,
                        'univention.appcenter.actions.{}'.format(name),
                        use_installed=use_installed)
                for pymodule in glob(
                        'python/appcenter-docker/actions/docker_base.py'):
                    name = os.path.basename(pymodule)[:-3]  # without .py
                    local_python_path = os.path.dirname(pymodule)
                    import_module(
                        name,
                        local_python_path,
                        'univention.appcenter.actions.{}'.format(name),
                        use_installed=use_installed)
                for pymodule in glob(
                        'python/appcenter-docker/actions/docker_*.py'):
                    name = os.path.basename(pymodule)[:-3]  # without .py
                    local_python_path = os.path.dirname(pymodule)
                    import_module(
                        name,
                        local_python_path,
                        'univention.appcenter.actions.{}'.format(name),
                        use_installed=use_installed)
                for pymodule in glob('python/appcenter-docker/actions/*.py'):
                    name = os.path.basename(pymodule)[:-3]  # without .py
                    local_python_path = os.path.dirname(pymodule)
                    import_module(
                        name,
                        local_python_path,
                        'univention.appcenter.actions.{}'.format(name),
                        use_installed=use_installed)