refactor(utils)!: move fit_row_length to utility module

Moved the _fit_row_length function from the Python generator core module
to fit_row_length in the utility module. The public exports definition
of the utility module and all imports were updated.

The test module was also moved to the appropriate new path and the
testing functions were renamed.
This commit is contained in:
jakob.scheid committed 2026-10-21 13:01:28 +02:00
1 parent 39d3b0ace4
commit 36bc14185a
3 files changed
+31 -30

No files matched your search

@@ -1,66 +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.
import pytest
from src.jcloud_docsgen.core.python._core import _fit_row_length
@pytest.mark.parametrize(
'expected_length,row,expected',
[
(0, (), ()),
(1, (), (None,)),
(2, (), (None, None)),
(2, (1,), (1, None)),
(0, (1,), ()),
(1, (1, 2), (1,)),
(1, (1, 2), (1,)),
(0, (1, 2), ()),
(0, (1, 2, 3), ()),
(1, (1, 2, 3), (1,)),
(2, (1, 2, 3), (1, 2)),
(1, (1,), (1,)),
(2, (1, 1), (1, 1)),
(2, (1, 2), (1, 2)),
(3, (1, 2, 3), (1, 2, 3)),
],
)
def test__fit_row_length(expected_length, row, expected):
assert _fit_row_length(expected_length, row) == expected
@pytest.mark.parametrize(
'row',
[
(),
(1,),
(1, 2),
(1, 2, 3),
(1, 2, 3, 456),
],
)
@pytest.mark.parametrize(
'expected_length,expected_exception',
[
(-1, ValueError),
(-2, ValueError),
(-3, ValueError),
(-42, ValueError),
],
)
def test__fit_row_length_exceptions(expected_length, row, expected_exception):
with pytest.raises(expected_exception) as exc_info:
_fit_row_length(expected_length, row)
assert str(exc_info.value) == 'expected must be larger than or equal 0.'