blob: e8da1e04a33978daa2b470a084c9605d53c35d8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import copy
import os
import sys
from ansible.errors import AnsibleError
import pytest
sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, "lookup_plugins"))
from openshift_master_facts_default_predicates import LookupModule # noqa: E402
class TestOpenShiftMasterFactsBadInput(object):
lookup = LookupModule()
default_facts = {
'openshift': {
'common': {}
}
}
def test_missing_openshift_facts(self):
with pytest.raises(AnsibleError):
facts = {}
self.lookup.run(None, variables=facts)
def test_missing_deployment_type(self):
with pytest.raises(AnsibleError):
facts = copy.deepcopy(self.default_facts)
facts['openshift']['common']['short_version'] = '10.10'
self.lookup.run(None, variables=facts)
def test_missing_short_version_and_missing_openshift_release(self):
with pytest.raises(AnsibleError):
facts = copy.deepcopy(self.default_facts)
facts['openshift']['common']['deployment_type'] = 'origin'
self.lookup.run(None, variables=facts)
def test_unknown_deployment_types(self):
with pytest.raises(AnsibleError):
facts = copy.deepcopy(self.default_facts)
facts['openshift']['common']['short_version'] = '1.1'
facts['openshift']['common']['deployment_type'] = 'bogus'
self.lookup.run(None, variables=facts)
def test_unknown_origin_version(self):
with pytest.raises(AnsibleError):
facts = copy.deepcopy(self.default_facts)
facts['openshift']['common']['short_version'] = '0.1'
facts['openshift']['common']['deployment_type'] = 'origin'
self.lookup.run(None, variables=facts)
def test_unknown_ocp_version(self):
with pytest.raises(AnsibleError):
facts = copy.deepcopy(self.default_facts)
facts['openshift']['common']['short_version'] = '0.1'
facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
self.lookup.run(None, variables=facts)
|