# 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.utils import human_readable_list @pytest.mark.parametrize( 'ls,final_separator,quotation_mark,expected', [ ([], '', '', ''), ([], 'and', '', ''), ([], 'and', "'", ''), ([1], '', '', '1'), ([-1], '', '', '-1'), ([0], '', '', '0'), ([0.0], '', '', '0.0'), ([-0.0], '', '', '-0.0'), ([4.2], '', '', '4.2'), ([-4.2], '', '', '-4.2'), (['a'], '', '', 'a'), ([1], 'and', '', '1'), (['a'], 'and', '', 'a'), ([1], 'and', "'", "'1'"), (['a'], 'and', "'", "'a'"), ([1, 2], 'and', '', '1 and 2'), ([1, 2], 'and', "'", "'1' and '2'"), ([1, 'a'], 'and', '', '1 and a'), ([1, 'a'], 'and', "'", "'1' and 'a'"), ([1, 'a'], 'and', '', '1 and a'), ([1, 'a'], 'and', "'", "'1' and 'a'"), ([1, 'a'], 'and', "'", "'1' and 'a'"), ([1, 'a'], '', '', '1 a'), ([1, 'a'], '', "'", "'1' 'a'"), ([1, 'a'], '', '', '1 a'), ([1, 'a'], '', "'", "'1' 'a'"), ([1, 'a'], '', "'", "'1' 'a'"), ([1, 2, 3], 'and', '', '1, 2 and 3'), ([1, 2, 3], '', '', '1, 2 3'), ([1, 2, 3], 'and', "'", "'1', '2' and '3'"), ([1, 2, 3], '', "'", "'1', '2' '3'"), ([1, 2, 3, 42, 'a', 23], 'and', '', '1, 2, 3, 42, a and 23'), ( [1, 2, 3, 42, 'a', 23], 'and', "'", "'1', '2', '3', '42', 'a' and '23'", ), ], ) def test_human_readable_list(ls, final_separator, quotation_mark, expected): assert human_readable_list(ls, final_separator, quotation_mark) == expected