refactor: remove or update all instances of ExistingFile and ExistingDirectory in tests

This commit is contained in:
jakob.scheid committed 2026-09-05 14:29:31 +02:00
1 parent 5d8dbd659d
commit d54c0fb208
5 files changed
+35 -141

No files matched your search

@@ -1,42 +0,0 @@
# Copyright 2026 jCloud
# 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
-35
View File
@@ -1,35 +0,0 @@
# Copyright 2026 jCloud
# 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