def test_validate_correct_namespace(): """ validate_extensions.py: Test validate() on correct namespaces """ a = ExtSpace(e=['.ds', '.md', 'eeyy']) assert v.validate(a) b = ExtSpace(e=['.md']) assert v.validate(b) c = ExtSpace(e=['t', 't', 't', 't', 't', 't']) assert v.validate(c)
def test_validate_correct(): """ validate_extensions.py: Test validate() on correct lists """ a = ['.ds', '.md', 'eeyy'] assert v.validate(a) b = ['.md'] assert v.validate(b) c = ['t', 't', 't', 't', 't', 't'] 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.")
def test_validate_bad_type_string(): """ validate_extensions.py: Test validate() with a single string :raises ValueError: always, if the test is working """ assert v.validate('.md')
def test_validate_bad_type_no_extensions_attr(): """ validate_extensions.py: Test validate() with object lacking 'extensions' :raises ValueError: always, if the test is working """ assert v.validate(object())
def test_validate_bad_type_number(): """ validate_extensions.py: Test validate() with a single number :raises ValueError: always, if the test is working """ assert v.validate(3)
def test_validate_empty_array_namespace(): """ validate_extensions.py: Test validate() on a namespace with empty array :raises ValidationException: always, if the test is working """ a = ExtSpace(e=['.md', '.rst', '']) assert v.validate(a)
def test_validate_incorrect_empty_list(): """ validate_extensions.py: Test validate() on an empty list :raises ValidationException: always, if the test is working """ a = [] assert v.validate(a)
def test_validate_incorrect_empty_string(): """ validate_extensions.py: Test validate() on lists with empty strings :raises ValidationException: always, if the test is working """ a = ['.md', '.rst', ''] assert v.validate(a)
def test_validate_empty_string_namespace(): """ validate_extensions.py: Test validate() on a namespace with an empty string Try validating a namespace that has an empty string as part of the list under its extensions attribute. :raises ValidationException: always, if the test is working """ a = ExtSpace(e=['.md', '.rst', '']) assert v.validate(a)