Пример #1
0
def test_hasattrs_basic():
    """
    hasattrs.py: Basic usage
    """
    a = AttrObj()
    assert hasattrs(a, 'a', 'b', 'c')
    assert hasattrs(a, 'a')
    assert hasattrs(a, 'b', 'd')
    assert not hasattrs(a, 'e')
Пример #2
0
def validate(opts):
    """
     Client facing overwrite validation. Checks to see if the opts arguments
     contains the attributes 'overwrite', 'input', and 'output'.

    :param opts: a namespace containing the attributes 'overwrite', 'input',
        and 'output'
    :raises ValueError: if the value passed in is not a namespace with the
        attributes 'overwrite', 'input', and 'output'
    :raises ValidationException: if opts fails any of the validations
    :return: True if opts passes the validations
    """
    if hasattrs(opts, 'overwrite', 'input', 'output'):
        return _validate(opts)
    else:
        raise ValueError("opts object must have attributes 'overwrite', "
                         "'input', and 'output.")
Пример #3
0
def validate(opts):
    """
     Client facing overwrite validation. Checks to see if the opts arguments
     contains the attributes 'overwrite', 'input', and 'output'.

    :param opts: a namespace containing the attributes 'overwrite', 'input',
        and 'output'
    :raises ValueError: if the value passed in is not a namespace with the
        attributes 'overwrite', 'input', and 'output'
    :raises ValidationException: if opts fails any of the validations
    :return: True if opts passes the validations
    """
    if hasattrs(opts, 'overwrite', 'input', 'output'):
        return _validate(opts)
    else:
        raise ValueError("opts object must have attributes 'overwrite', "
                         "'input', and 'output.")
Пример #4
0
def test_hasattrs_no_names():
    """
    hasattrs.py: Provide no attribute names
    """
    a = AttrObj()
    assert hasattrs(a)