# Copyright 2026 jCloud Services GbR # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from src.jcloud_docsgen.utils import ExistingFile import pytest import pathlib @pytest.mark.parametrize('path,expected', [ ('tests/unit/utils/test_file', 'tests/unit/utils/test_file'), ]) def test_ExistingDirectory(path, expected): assert ExistingFile(path).as_posix() == expected @pytest.mark.parametrize('path,expected_exception,expected_exception_message', [ ('tests/unit/utils/does_not_exist', FileNotFoundError, '[Errno 2] no such file or directory: \'tests/unit/utils/does_not_exist\''), ('', FileNotFoundError, '[Errno 2] no such file or directory: \'\''), ('tests/unit/utils/test_directory', IsADirectoryError, '[Errno 21] is a directory: \'tests/unit/utils/test_directory\''), ('.', IsADirectoryError, '[Errno 21] is a directory: \'.\''), ('./', IsADirectoryError, '[Errno 21] is a directory: \'./\''), ]) def test_ExistingDirectory_exceptions(path, expected_exception, expected_exception_message): with pytest.raises(expected_exception) as exc_info: ExistingFile(path) assert str(exc_info.value) == expected_exception_message