From 403341ff03ab5eb0615708f23215e7b364ec93e1 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 7 Jun 2025 17:24:16 +0800 Subject: [PATCH] test: add test suites of permanent rooms option --- tests/test_arg_opts.py | 20 ++++++++++++++++++++ tests/test_cfg_opts.py | 15 +++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tests/test_arg_opts.py b/tests/test_arg_opts.py index 491e911..c0ec187 100644 --- a/tests/test_arg_opts.py +++ b/tests/test_arg_opts.py @@ -87,6 +87,26 @@ def test_args_single_bool(name: str, arg_tag: str): assert boot.load_from_args() == {name: True} +@pytest.mark.parametrize( + 'name, arg_tag', + [ + ('permanent_rooms', '--permanent-rooms'), + ], +) +def test_args_str_list(name: str, arg_tag: str) -> None: + """ + Test command line arguments of string list option. + """ + sys.argv += [arg_tag] + assert boot.load_from_args() == {name: []} + + sys.argv += [arg_tag, 'VALUE'] + assert boot.load_from_args() == {name: ['VALUE']} + + sys.argv += [arg_tag, 'V1', 'V2', 'V3'] + assert boot.load_from_args() == {name: ['V1', 'V2', 'V3']} + + def test_args_full(): """ Test all command line arguments options. diff --git a/tests/test_cfg_opts.py b/tests/test_cfg_opts.py index b12788e..1d4cd45 100644 --- a/tests/test_cfg_opts.py +++ b/tests/test_cfg_opts.py @@ -98,6 +98,21 @@ def test_config_single_bool(name: str, cfg_tag: str) -> None: verify_config({cfg_tag: False}, {name: False}) +@pytest.mark.parametrize( + 'name, cfg_tag', + [ + ('permanent_rooms', 'permanent-rooms'), + ], +) +def test_config_str_list(name: str, cfg_tag: str) -> None: + """ + Test configuration file of string list option. + """ + verify_config({cfg_tag: []}, {name: []}) + verify_config({cfg_tag: ['VALUE']}, {name: ['VALUE']}) + verify_config({cfg_tag: ['V1', 'V2', 'V3']}, {name: ['V1', 'V2', 'V3']}) + + def test_config_full(): """ Test all configuration file options.