Exemple #1
0
def skip_ok_unless_installed(*packages_or_dependencies, **kwargs):
    """Check that all given RPM packages or dependencies are installed and skip
    the test if not.

    Accepts the following keyword arguments:
    - 'message' is the text to include in the Exception (a generic 'missing
      $package' will be used otherwise)
    - 'by_dependency' is a bool which, if True, will cause dependencies to be
      queried instead of packages
    Raise osgunittest.OkSkipException if packages/dependencies are missing,
    otherwise return None.
    """
    # Handle the keyword arguments. There is some magic here to make it work
    # with the variable number of arguments that we are using for
    # 'packages_or_dependencies'.  Make sure that we accept the argument not
    # being there, but also raise an error on unexpected keyword arguments.
    message = kwargs.pop('message', None)
    by_dependency = kwargs.pop('by_dependency', False)
    if kwargs:
        raise TypeError(
            "skip_ok_unless_installed() got unexpected keyword argument(s) '%s'"
            % ("', '".join(kwargs.keys())))

    if isinstance(packages_or_dependencies[0], (list, tuple)):
        packages_or_dependencies = packages_or_dependencies[0]

    is_installed = dependency_is_installed if by_dependency else rpm_is_installed
    missing = [x for x in packages_or_dependencies if not is_installed(x)]

    if len(missing) > 0:
        raise osgunittest.OkSkipException(message
                                          or 'missing %s' % ' '.join(missing))
Exemple #2
0
def skip_ok_unless_one_installed(*packages):
    """
     Raise osgunittest.SkipOkException if at least one of the packages are installed
     otherwise return None.
    """
    if isinstance(packages[0], (list, tuple)):
        packages = packages[0]
    installed = []
    for package in packages:
        if rpm_is_installed(package):
            installed.append(package)
    if len(installed)==0:
        raise osgunittest.OkSkipException('None of these were intalled, skipping %s ' % ' '.join(packages))
Exemple #3
0
def skip_ok_unless_can_make_proxy():
    """OkSkip if the dependencies for creating VOMS proxies are not installed."""
    if not can_make_proxy():
        raise osgunittest.OkSkipException(
            'Required packages for creating VOMS proxies not installed')
Exemple #4
0
def skip_ok_unless_server_is_installed():
    """OkSkip if the dependencies for setting up and using VOMS are not installed."""
    if not server_is_installed():
        raise osgunittest.OkSkipException(
            'VOMS server requirements not installed')