From bca07eebba029870057bae66d03f2c2c001b3d25 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sat, 31 Mar 2018 15:57:08 -0400 Subject: [PATCH] Unit-test configmodel arg filtering. Test that values the user has already input are omitted from the suggestions. This brings configmodel coverage back to 100%. --- tests/unit/completion/test_models.py | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index efc30dd1c..5db390194 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -716,6 +716,44 @@ def test_setting_value_completion_invalid(info): assert configmodel.value(optname='foobarbaz', info=info) is None +@pytest.mark.parametrize('args, expected', [ + ([], { + "Current/Default": [ + ('true', 'Current value', None), + ('true', 'Default value', None), + ], + "Completions": [ + ('false', '', None), + ('true', '', None), + ], + }), + (['false'], { + "Current/Default": [ + ('true', 'Current value', None), + ('true', 'Default value', None), + ], + "Completions": [ + ('true', '', None), + ], + }), + (['true'], { + "Completions": [ + ('false', '', None), + ], + }), + (['false', 'true'], {}), +]) +def test_setting_value_cycle(qtmodeltester, config_stub, configdata_stub, + info, args, expected): + opt = 'content.javascript.enabled' + + model = configmodel.value(opt, *args, info=info) + model.set_pattern('') + qtmodeltester.data_display_may_return_none = True + qtmodeltester.check(model) + _check_completions(model, expected) + + def test_bind_completion(qtmodeltester, cmdutils_stub, config_stub, key_config_stub, configdata_stub, info): """Test the results of keybinding command completion.