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
def _projects_file(path): if not utils.file_exists(path): raise argparse.ArgumentTypeError( 'File "{0}" does not exists'.format(path)) return path
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")])
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')])