From 2760accc678c8283d91e49c204757e6365fafb42 Mon Sep 17 00:00:00 2001 From: Kristian Wallgren Date: Sun, 23 Apr 2023 11:52:31 +0300 Subject: [PATCH] Add test for hints.uppercase yaml migration --- tests/unit/config/test_configfiles.py | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index bd35ced4f..e888a2733 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -879,6 +879,40 @@ class TestYamlMigrations: 'content.media.video_capture']: assert data[setting]['global'] == val + @pytest.mark.parametrize('chars, uppercase', [ + ('aoeuidnths', True), + ('abcdefghijklmnopqrstuvwxyz', True), + (None, True), + ('aoeuidnths', False), + ('abcdefghijklmnopqrstuvwxyz', False), + (None, False), + ('aoeuidnths', None), + ('abcdefghijklmnopqrstuvwxyz', None), + (None, None), + ]) + def test_hints_uppercase(self, yaml, autoconfig, chars, uppercase): + settings = {} + if chars is not None: + settings['hints.chars'] = {'global': chars} + if uppercase is not None: + settings['hints.uppercase'] = {'global': uppercase} + + autoconfig.write(settings) + + yaml.load() + yaml._save() + + data = autoconfig.read() + if uppercase: + if 'hints.chars' in data: + labels = data['hints.chars']['global'].upper() + assert data['hints.labels']['global'] == labels + else: + labels = configdata.DATA['hints.chars'].default.upper() + assert data['hints.labels']['global'] == labels + else: + assert 'hints.labels' not in data + def test_empty_pattern(self, yaml, autoconfig): valid_pattern = 'https://example.com/*' invalid_pattern = '*://*./*'