Debian Codegraph @

test/units/module_utils/common/validation/test_count_terms.py

raw
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2019 Ansible Project
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import annotations
6
7 import pytest
8
9 from ansible.module_utils.common.validation import count_terms
10
11
12 @pytest.fixture
13 def params():
14 return {
15 'name': 'bob',
16 'dest': '/etc/hosts',
17 'state': 'present',
18 'value': 5,
19 }
20
21
22 def test_count_terms(params):
23 check = set(('name', 'dest'))
24 assert count_terms(check, params) == 2
25
26
27 def test_count_terms_str_input(params):
28 check = 'name'
29 assert count_terms(check, params) == 1
30
31
32 def test_count_terms_tuple_input(params):
33 check = ('name', 'dest')
34 assert count_terms(check, params) == 2
35
36
37 def test_count_terms_list_input(params):
38 check = ['name', 'dest']
39 assert count_terms(check, params) == 2