From 8e7002db7a02b4b24a549d1e890f89e7e92c0df1 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Fri, 29 Jul 2016 07:35:29 -0400 Subject: [PATCH] Test CompletionFilterModel.count --- tests/unit/completion/test_sortfilter.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/completion/test_sortfilter.py b/tests/unit/completion/test_sortfilter.py index 0d00fcf64..50e88130d 100644 --- a/tests/unit/completion/test_sortfilter.py +++ b/tests/unit/completion/test_sortfilter.py @@ -93,3 +93,24 @@ def test_set_source_model(): assert filter_model.srcmodel is model2 assert filter_model.sourceModel() is model2 assert not filter_model.pattern + +@pytest.mark.parametrize('tree, expected', [ + ([['Aa']], 1), + ([['Aa'], ['Ba']], 2), + ([['Aa', 'Ab', 'Ac'], ['Ba', 'Bb'], ['Ca']], 6), + ([[], ['Ba']], 1), + ([[], [], ['Ca']], 1), + ([[], [], ['Ca', 'Cb']], 2), + ([['Aa'], []], 1), + ([['Aa'], []], 1), + ([['Aa'], [], []], 1), + ([['Aa'], [], ['Ca']], 2), +]) +def test_count(tree, expected): + model = base.BaseCompletionModel() + for catdata in tree: + cat = model.new_category('') + for name in catdata: + model.new_item(cat, name, '') + filter_model = sortfilter.CompletionFilterModel(model) + assert filter_model.count() == expected