Exemple #1
0
def test_validate_correct():
    """
    validate_overwrite.py: Test various correct objects
    """
    a = OverObj('.', 'anchorhub-out', False)
    assert v.validate(a)

    b = OverObj('.', '.', True)
    assert v.validate(b)

    c = OverObj('.', 'anchorhub-out', True)
    assert v.validate(c)
def _validate(opts):
    """
    Perform validation operations on opts, a namespace created from
    command-line arguments. Returns True if all validation tests are successful.

    Runs validation() methods in validate_input.py, validate_extensions.py,
    validate_overwrite.py, and validate_wrapper.py

    Required attributes on opts:
    * input: String giving the path to input files
    * output: String giving the path to output destination
    * wrapper: String specifying the wrapper format
    * extensions: List of strings specifying the file extensions to look for
    * overwrite: Boolean specifying whether the original input files should
                 be overridden

    :param opts: namespace containing necessary parameters
    :raises ValidationException: if one or more of the tests are unsuccessful
    :raises ValueError: if opts is not a namespace with the correct parameters
    :return: True, if all tests are successful
    """
    if all([
            vi.validate(opts),
            ve.validate(opts),
            vw.validate(opts),
            vo.validate(opts)
    ]):
        return True
    else:
        raise ValidationException("Arguments did not pass validation. Check "
                                  "your inputs.")
def _validate(opts):
    """
    Perform validation operations on opts, a namespace created from
    command-line arguments. Returns True if all validation tests are successful.

    Runs validation() methods in validate_input.py, validate_extensions.py,
    validate_overwrite.py, and validate_wrapper.py

    Required attributes on opts:
    * input: String giving the path to input files
    * output: String giving the path to output destination
    * wrapper: String specifying the wrapper format
    * extensions: List of strings specifying the file extensions to look for
    * overwrite: Boolean specifying whether the original input files should
                 be overridden

    :param opts: namespace containing necessary parameters
    :raises ValidationException: if one or more of the tests are unsuccessful
    :raises ValueError: if opts is not a namespace with the correct parameters
    :return: True, if all tests are successful
    """
    if all([vi.validate(opts),
            ve.validate(opts),
            vw.validate(opts),
            vo.validate(opts)]):
        return True
    else:
        raise ValidationException("Arguments did not pass validation. Check "
                                  "your inputs.")
Exemple #4
0
def test_validate_same_input_output_relative_abs_dirs():
    """
    validate_overwrite.py: input/output are same, mixing relative/absolute paths
    """
    cwd = os.getcwd()
    a = OverObj('.', cwd, False)
    assert v.validate(a)
Exemple #5
0
def test_validate_same_input_output_relative_dirs():
    """
    validate_overwrite.py: input/output are same, using only relative paths
    """
    cwd = os.getcwd()
    # Find last path separator in cwd; dir is everything after that
    dir = cwd[cwd.rfind(get_path_separator()):]
    a = OverObj('.', '..' + dir, False)
    assert v.validate(a)
Exemple #6
0
def test_validate_no_overwrite():
    """
    validate_overwrite.py: no overwrite flag provided
    """
    a = OverObj(input='.', output='.')
    assert v.validate(a)
Exemple #7
0
def test_validate_no_output():
    """
    validate_overwrite.py: no output provided
    """
    a = OverObj(input='.', overwrite=False)
    assert v.validate(a)
Exemple #8
0
def test_validate_same_input_output():
    """
    validate_overwrite.py: input/output are the same, overwrite set to False
    """
    a = OverObj('.', '.', False)
    assert v.validate(a)