5
5
import pytest
6
6
7
7
from tests .common .helpers .platform_api import chassis , psu , psu_fan
8
+ from tests .platform_tests .cli .util import get_skip_mod_list
9
+ from tests .platform_tests .api .conftest import skip_absent_psu
8
10
from tests .common .platform .device_utils import platform_api_conn , start_platform_api_service # noqa F401
9
11
10
12
from .platform_api_test_base import PlatformApiTestBase
@@ -46,7 +48,7 @@ class TestPsuFans(PlatformApiTestBase):
46
48
# level, so we must do the same here to prevent a scope mismatch.
47
49
48
50
@pytest .fixture (scope = "function" , autouse = True )
49
- def setup (self , platform_api_conn ): # noqa F811
51
+ def setup (self , platform_api_conn , duthosts , enum_rand_one_per_hwsku_hostname ): # noqa F811
50
52
if self .num_psus is None :
51
53
try :
52
54
self .num_psus = chassis .get_num_psus (platform_api_conn )
@@ -56,6 +58,9 @@ def setup(self, platform_api_conn): # noqa F811
56
58
if self .num_psus == 0 :
57
59
pytest .skip ("No psus found on device" )
58
60
61
+ duthost = duthosts [enum_rand_one_per_hwsku_hostname ]
62
+ self .psu_skip_list = get_skip_mod_list (duthost , ['psus' ])
63
+
59
64
#
60
65
# Helper functions
61
66
#
@@ -99,6 +104,8 @@ def get_fan_facts(self, duthost, psu_idx, fan_idx, def_value, *keys):
99
104
def test_get_name (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost , platform_api_conn ): # noqa F811
100
105
duthost = duthosts [enum_rand_one_per_hwsku_hostname ]
101
106
for j in range (self .num_psus ):
107
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
108
+ continue
102
109
num_fans = psu .get_num_fans (platform_api_conn , j )
103
110
104
111
for i in range (num_fans ):
@@ -135,6 +142,8 @@ def test_get_name(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, p
135
142
136
143
def test_get_presence (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost , platform_api_conn ): # noqa F811
137
144
for j in range (self .num_psus ):
145
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
146
+ continue
138
147
num_fans = psu .get_num_fans (platform_api_conn , j )
139
148
140
149
for i in range (num_fans ):
@@ -151,6 +160,8 @@ def test_get_presence(self, duthosts, enum_rand_one_per_hwsku_hostname, localhos
151
160
152
161
def test_get_model (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost , platform_api_conn ): # noqa F811
153
162
for j in range (self .num_psus ):
163
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
164
+ continue
154
165
num_fans = psu .get_num_fans (platform_api_conn , j )
155
166
156
167
for i in range (num_fans ):
@@ -163,6 +174,8 @@ def test_get_model(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
163
174
164
175
def test_get_serial (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost , platform_api_conn ): # noqa F811
165
176
for j in range (self .num_psus ):
177
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
178
+ continue
166
179
num_fans = psu .get_num_fans (platform_api_conn , j )
167
180
168
181
for i in range (num_fans ):
@@ -176,6 +189,8 @@ def test_get_serial(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
176
189
177
190
def test_get_status (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost , platform_api_conn ): # noqa F811
178
191
for j in range (self .num_psus ):
192
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
193
+ continue
179
194
num_fans = psu .get_num_fans (platform_api_conn , j )
180
195
181
196
for i in range (num_fans ):
@@ -188,6 +203,8 @@ def test_get_status(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
188
203
189
204
def test_get_position_in_parent (self , platform_api_conn ): # noqa F811
190
205
for j in range (self .num_psus ):
206
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
207
+ continue
191
208
num_fans = psu .get_num_fans (platform_api_conn , j )
192
209
for i in range (num_fans ):
193
210
position = psu_fan .get_position_in_parent (platform_api_conn , j , i )
@@ -199,6 +216,8 @@ def test_get_position_in_parent(self, platform_api_conn): # noqa F811
199
216
200
217
def test_is_replaceable (self , platform_api_conn ): # noqa F811
201
218
for j in range (self .num_psus ):
219
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
220
+ continue
202
221
num_fans = psu .get_num_fans (platform_api_conn , j )
203
222
for i in range (num_fans ):
204
223
replaceable = psu_fan .is_replaceable (platform_api_conn , j , i )
@@ -216,6 +235,8 @@ def test_is_replaceable(self, platform_api_conn): # noqa F811
216
235
def test_get_speed (self , duthosts , enum_rand_one_per_hwsku_hostname , localhost , platform_api_conn ): # noqa F811
217
236
duthost = duthosts [enum_rand_one_per_hwsku_hostname ]
218
237
for j in range (self .num_psus ):
238
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
239
+ continue
219
240
num_fans = psu .get_num_fans (platform_api_conn , j )
220
241
221
242
for i in range (num_fans ):
@@ -241,6 +262,8 @@ def test_get_direction(self, duthosts, enum_rand_one_per_hwsku_hostname, localho
241
262
]
242
263
243
264
for j in range (self .num_psus ):
265
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
266
+ continue
244
267
num_fans = psu .get_num_fans (platform_api_conn , j )
245
268
246
269
for i in range (num_fans ):
@@ -257,6 +280,8 @@ def test_get_fans_target_speed(self, duthosts, enum_rand_one_per_hwsku_hostname,
257
280
psus_skipped = 0
258
281
259
282
for j in range (self .num_psus ):
283
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
284
+ continue
260
285
num_fans = psu .get_num_fans (platform_api_conn , j )
261
286
fans_skipped = 0
262
287
@@ -297,6 +322,8 @@ def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localh
297
322
psus_skipped = 0
298
323
299
324
for j in range (self .num_psus ):
325
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
326
+ continue
300
327
target_speed = random .randint (1 , 100 )
301
328
num_fans = psu .get_num_fans (platform_api_conn , j )
302
329
fans_skipped = 0
@@ -344,6 +371,8 @@ def test_set_fans_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhos
344
371
psus_skipped = 0
345
372
346
373
for j in range (self .num_psus ):
374
+ if skip_absent_psu (j , platform_api_conn , self .psu_skip_list , logger ):
375
+ continue
347
376
num_fans = psu .get_num_fans (platform_api_conn , j )
348
377
fans_skipped = 0
349
378
0 commit comments