Beispiel #1
0
def validate_file_by_schema(schema, file_path):
    if not utils.file_exists(file_path):
        raise error.FileDoesNotExist(file_path)

    data = utils.parse_yaml(file_path)
    if data is not None:
        validate_schema(data, schema, file_path)
    else:
        raise error.FileIsEmpty(file_path)
    return data
Beispiel #2
0
def validate_file_by_schema(schema, file_path):
    if not utils.file_exists(file_path):
        raise error.FileDoesNotExist(file_path)

    data = utils.parse_yaml(file_path)
    if data is not None:
        validate_schema(data, schema, file_path)
    else:
        raise error.FileIsEmpty(file_path)
    return data
Beispiel #3
0
 def _projects_file(path):
     if not utils.file_exists(path):
         raise argparse.ArgumentTypeError(
             'File "{0}" does not exists'.format(path))
     return path
Beispiel #4
0
 def _projects_file(path):
     if not utils.file_exists(path):
         raise argparse.ArgumentTypeError(
             'File "{0}" does not exists'.format(path))
     return path
Beispiel #5
0
 def test_file_exists(self, lexists_mock):
     self.assertTrue(utils.file_exists("file1"))
     self.assertFalse(utils.file_exists("file2"))
     self.assertEqual(
         lexists_mock.call_args_list,
         [mock.call("file1"), mock.call("file2")])
Beispiel #6
0
 def test_file_exists(self, lexists_mock):
     self.assertTrue(utils.file_exists('file1'))
     self.assertFalse(utils.file_exists('file2'))
     self.assertEqual(lexists_mock.call_args_list,
                      [mock.call('file1'), mock.call('file2')])