generated from jCloud/repository-template
42 lines
1.9 KiB
Python
42 lines
1.9 KiB
Python
# 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 ExistingDirectory
|
|
import pytest
|
|
import pathlib
|
|
|
|
@pytest.mark.parametrize('path,expected', [
|
|
('tests/unit/utils/test_directory/', 'tests/unit/utils/test_directory'),
|
|
('tests/unit/utils/test_directory', 'tests/unit/utils/test_directory'),
|
|
('tests/unit/utils/', 'tests/unit/utils'),
|
|
('tests/unit/utils', 'tests/unit/utils'),
|
|
('/', '/'),
|
|
('./', '.'),
|
|
('.', '.'),
|
|
('../', '..'),
|
|
('..', '..'),
|
|
])
|
|
def test_ExistingDirectory(path, expected):
|
|
assert ExistingDirectory(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/\''),
|
|
('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: \'\''),
|
|
('README.md', NotADirectoryError, '[Errno 20] not a directory: \'README.md\''),
|
|
])
|
|
def test_ExistingDirectory_exceptions(path, expected_exception, expected_exception_message):
|
|
with pytest.raises(expected_exception) as exc_info:
|
|
ExistingDirectory(path)
|
|
assert str(exc_info.value) == expected_exception_message |