99from suzieq .shared .utils import PollerTransport
1010
1111
12- _INVENTORY = [ {
12+ _INVENTORY = {
1313 'native-ns.192.168.123.123.443' :
1414 {
1515 'address' : '192.168.123.123' ,
1616 'hostname' : None ,
1717 'namespace' : 'native-ns' ,
1818 'port' : 443 ,
19+ 'transport' : 'https'
20+ },
21+ 'native-ns.192.168.123.164.443' :
22+ {
23+ 'address' : '192.168.123.164' ,
24+ 'devtype' : 'eos' ,
25+ 'hostname' : None ,
26+ 'namespace' : 'native-ns' ,
27+ 'port' : 443 ,
28+ 'ignore_known_hosts' : False
29+ },
30+ 'native-ns.192.168.123.111.443' :
31+ {
32+ 'address' : '192.168.123.111' ,
33+ 'hostname' : None ,
34+ 'namespace' : 'native-ns' ,
35+ 'transport' : 'https'
36+ },
37+ 'native-ns.192.168.123.110.22' :
38+ {
39+ 'address' : '192.168.123.110' ,
40+ 'hostname' : None ,
41+ 'namespace' : 'native-ns' ,
42+ 'transport' : 'ssh'
43+ },
44+ 'native-ns.192.168.123.143.443' :
45+ {
46+ 'address' : '192.168.123.143' ,
47+ 'hostname' : None ,
48+ 'namespace' : 'native-ns' ,
49+ 'transport' : 'http' ,
50+ 'port' : 443
51+ },
52+ 'native-ns.192.168.123.171.22' :
53+ {
54+ 'address' : '192.168.123.171' ,
55+ 'hostname' : None ,
56+ 'namespace' : 'native-ns' ,
1957 'transport' : 'http'
58+ }
59+ }
60+
61+ _RESULT_INVENTORY = {
62+ 'native-ns.192.168.123.123.443' :
63+ {
64+ 'address' : '192.168.123.123' ,
65+ 'hostname' : None ,
66+ 'namespace' : 'native-ns' ,
67+ 'port' : 443 ,
68+ 'transport' : 'https'
2069 },
2170 'native-ns.192.168.123.164.443' :
2271 {
2574 'hostname' : None ,
2675 'namespace' : 'native-ns' ,
2776 'port' : 443 ,
77+ 'transport' : 'ssh' ,
2878 'ignore_known_hosts' : False
79+ },
80+ 'native-ns.192.168.123.111.443' :
81+ {
82+ 'address' : '192.168.123.111' ,
83+ 'hostname' : None ,
84+ 'namespace' : 'native-ns' ,
85+ 'transport' : 'https' ,
86+ 'port' : 443
87+ },
88+ 'native-ns.192.168.123.110.22' :
89+ {
90+ 'address' : '192.168.123.110' ,
91+ 'hostname' : None ,
92+ 'namespace' : 'native-ns' ,
93+ 'transport' : 'ssh' ,
94+ 'port' : 22
95+ },
96+ 'native-ns.192.168.123.143.443' :
97+ {
98+ 'address' : '192.168.123.143' ,
99+ 'hostname' : None ,
100+ 'namespace' : 'native-ns' ,
101+ 'transport' : 'http' ,
102+ 'port' : 443
103+ },
104+ 'native-ns.192.168.123.171.22' :
105+ {
106+ 'address' : '192.168.123.171' ,
107+ 'hostname' : None ,
108+ 'namespace' : 'native-ns' ,
109+ 'transport' : 'http' ,
110+ 'port' : 80
29111 }
30- }]
112+ }
31113
32114
33115def set_inventory_mock (self , inventory : Dict ):
@@ -51,8 +133,9 @@ def set_inventory_mock(self, inventory: Dict):
51133@pytest .mark .poller_unit_tests
52134@pytest .mark .controller_unit_tests
53135@pytest .mark .asyncio
54- @pytest .mark .parametrize ('inventory' , _INVENTORY )
55- async def test_devices_set (inventory : Dict ):
136+ @pytest .mark .parametrize ('inventory, result_inventory' ,
137+ [(_INVENTORY , _RESULT_INVENTORY )])
138+ async def test_devices_set (inventory : Dict , result_inventory : Dict ):
56139 """Test devices are correctly set
57140
58141 Args:
@@ -66,7 +149,9 @@ async def test_devices_set(inventory: Dict):
66149 'jump-host-key-file' : None ,
67150 'devtype' : 'panos' ,
68151 'transport' : PollerTransport .ssh ,
69-
152+ 'slow_host' : False ,
153+ 'per_cmd_auth' : True ,
154+ 'retries-on-auth-fail' : 0
70155 }
71156 }
72157
@@ -80,14 +165,14 @@ async def test_devices_set(inventory: Dict):
80165
81166 # emulate what the function Source.set_device should do
82167 exp_inv = {}
83- for key , node in inventory .items ():
168+ for key , node in result_inventory .items ():
84169 exp_inv [key ] = node .copy ()
85170 for k , v in config ['device' ].items ():
86171 k = k .replace ('-' , '_' )
87172 if k not in exp_inv [key ]:
88173 exp_inv [key ][k ] = v
89174
90- assert inv == exp_inv
175+ assert inv == exp_inv , 'inventory do not match'
91176
92177
93178@pytest .mark .controller_device
0 commit comments