1
1
import os
2
2
import sys
3
+ import yaml
3
4
import multiprocessing
4
5
from imp import load_source
5
6
from unittest import mock
@@ -106,7 +107,7 @@ class TestVoltageUpdater(object):
106
107
"""
107
108
def test_deinit (self ):
108
109
chassis = MockChassis ()
109
- voltage_updater = sensormond .VoltageUpdater (chassis )
110
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
110
111
voltage_updater .voltage_status_dict = {'key1' : 'value1' , 'key2' : 'value2' }
111
112
voltage_updater .table = Table ("STATE_DB" , "xtable" )
112
113
voltage_updater .table ._del = mock .MagicMock ()
@@ -127,7 +128,7 @@ def test_deinit(self):
127
128
def test_over_voltage (self ):
128
129
chassis = MockChassis ()
129
130
chassis .make_over_threshold_voltage_sensor ()
130
- voltage_updater = sensormond .VoltageUpdater (chassis )
131
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
131
132
voltage_updater .update ()
132
133
voltage_sensor_list = chassis .get_all_voltage_sensors ()
133
134
assert voltage_updater .log_warning .call_count == 1
@@ -141,7 +142,7 @@ def test_over_voltage(self):
141
142
def test_under_voltage (self ):
142
143
chassis = MockChassis ()
143
144
chassis .make_under_threshold_voltage_sensor ()
144
- voltage_updater = sensormond .VoltageUpdater (chassis )
145
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
145
146
voltage_updater .update ()
146
147
voltage_sensor_list = chassis .get_all_voltage_sensors ()
147
148
assert voltage_updater .log_warning .call_count == 1
@@ -159,7 +160,7 @@ def test_update_voltage_sensor_with_exception(self):
159
160
voltage_sensor .make_over_threshold ()
160
161
chassis .get_all_voltage_sensors ().append (voltage_sensor )
161
162
162
- voltage_updater = sensormond .VoltageUpdater (chassis )
163
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
163
164
voltage_updater .update ()
164
165
assert voltage_updater .log_warning .call_count == 2
165
166
@@ -179,7 +180,7 @@ def test_update_module_voltage_sensors(self):
179
180
chassis = MockChassis ()
180
181
chassis .make_module_voltage_sensor ()
181
182
chassis .set_modular_chassis (True )
182
- voltage_updater = sensormond .VoltageUpdater (chassis )
183
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
183
184
voltage_updater .update ()
184
185
assert len (voltage_updater .module_voltage_sensors ) == 1
185
186
@@ -194,7 +195,7 @@ class TestCurrentUpdater(object):
194
195
"""
195
196
def test_deinit (self ):
196
197
chassis = MockChassis ()
197
- current_updater = sensormond .CurrentUpdater (chassis )
198
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
198
199
current_updater .current_status_dict = {'key1' : 'value1' , 'key2' : 'value2' }
199
200
current_updater .table = Table ("STATE_DB" , "xtable" )
200
201
current_updater .table ._del = mock .MagicMock ()
@@ -215,7 +216,7 @@ def test_deinit(self):
215
216
def test_over_current (self ):
216
217
chassis = MockChassis ()
217
218
chassis .make_over_threshold_current_sensor ()
218
- current_updater = sensormond .CurrentUpdater (chassis )
219
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
219
220
current_updater .update ()
220
221
current_sensor_list = chassis .get_all_current_sensors ()
221
222
assert current_updater .log_warning .call_count == 1
@@ -229,7 +230,7 @@ def test_over_current(self):
229
230
def test_under_current (self ):
230
231
chassis = MockChassis ()
231
232
chassis .make_under_threshold_current_sensor ()
232
- current_updater = sensormond .CurrentUpdater (chassis )
233
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
233
234
current_updater .update ()
234
235
current_sensor_list = chassis .get_all_current_sensors ()
235
236
assert current_updater .log_warning .call_count == 1
@@ -247,7 +248,7 @@ def test_update_current_sensor_with_exception(self):
247
248
current_sensor .make_over_threshold ()
248
249
chassis .get_all_current_sensors ().append (current_sensor )
249
250
250
- current_updater = sensormond .CurrentUpdater (chassis )
251
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
251
252
current_updater .update ()
252
253
assert current_updater .log_warning .call_count == 2
253
254
@@ -267,7 +268,7 @@ def test_update_module_current_sensors(self):
267
268
chassis = MockChassis ()
268
269
chassis .make_module_current_sensor ()
269
270
chassis .set_modular_chassis (True )
270
- current_updater = sensormond .CurrentUpdater (chassis )
271
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
271
272
current_updater .update ()
272
273
assert len (current_updater .module_current_sensors ) == 1
273
274
@@ -282,17 +283,17 @@ def test_updater_voltage_sensor_check_modular_chassis():
282
283
chassis = MockChassis ()
283
284
assert chassis .is_modular_chassis () == False
284
285
285
- voltage_updater = sensormond .VoltageUpdater (chassis )
286
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
286
287
assert voltage_updater .chassis_table == None
287
288
288
289
chassis .set_modular_chassis (True )
289
290
chassis .set_my_slot (- 1 )
290
- voltage_updater = sensormond .VoltageUpdater (chassis )
291
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
291
292
assert voltage_updater .chassis_table == None
292
293
293
294
my_slot = 1
294
295
chassis .set_my_slot (my_slot )
295
- voltage_updater = sensormond .VoltageUpdater (chassis )
296
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
296
297
assert voltage_updater .chassis_table != None
297
298
assert voltage_updater .chassis_table .table_name == '{}_{}' .format (VOLTAGE_INFO_TABLE_NAME , str (my_slot ))
298
299
@@ -305,7 +306,7 @@ def test_updater_voltage_sensor_check_chassis_table():
305
306
306
307
chassis .set_modular_chassis (True )
307
308
chassis .set_my_slot (1 )
308
- voltage_updater = sensormond .VoltageUpdater (chassis )
309
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
309
310
310
311
voltage_updater .update ()
311
312
assert voltage_updater .chassis_table .get_size () == chassis .get_num_voltage_sensors ()
@@ -323,7 +324,7 @@ def test_updater_voltage_sensor_check_min_max():
323
324
324
325
chassis .set_modular_chassis (True )
325
326
chassis .set_my_slot (1 )
326
- voltage_updater = sensormond .VoltageUpdater (chassis )
327
+ voltage_updater = sensormond .VoltageUpdater (chassis , [] )
327
328
328
329
voltage_updater .update ()
329
330
slot_dict = voltage_updater .chassis_table .get (voltage_sensor .get_name ())
@@ -335,17 +336,17 @@ def test_updater_current_sensor_check_modular_chassis():
335
336
chassis = MockChassis ()
336
337
assert chassis .is_modular_chassis () == False
337
338
338
- current_updater = sensormond .CurrentUpdater (chassis )
339
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
339
340
assert current_updater .chassis_table == None
340
341
341
342
chassis .set_modular_chassis (True )
342
343
chassis .set_my_slot (- 1 )
343
- current_updater = sensormond .CurrentUpdater (chassis )
344
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
344
345
assert current_updater .chassis_table == None
345
346
346
347
my_slot = 1
347
348
chassis .set_my_slot (my_slot )
348
- current_updater = sensormond .CurrentUpdater (chassis )
349
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
349
350
assert current_updater .chassis_table != None
350
351
assert current_updater .chassis_table .table_name == '{}_{}' .format (CURRENT_INFO_TABLE_NAME , str (my_slot ))
351
352
@@ -358,7 +359,7 @@ def test_updater_current_sensor_check_chassis_table():
358
359
359
360
chassis .set_modular_chassis (True )
360
361
chassis .set_my_slot (1 )
361
- current_updater = sensormond .CurrentUpdater (chassis )
362
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
362
363
363
364
current_updater .update ()
364
365
assert current_updater .chassis_table .get_size () == chassis .get_num_current_sensors ()
@@ -377,7 +378,7 @@ def test_updater_current_sensor_check_min_max():
377
378
378
379
chassis .set_modular_chassis (True )
379
380
chassis .set_my_slot (1 )
380
- current_updater = sensormond .CurrentUpdater (chassis )
381
+ current_updater = sensormond .CurrentUpdater (chassis , [] )
381
382
382
383
current_updater .update ()
383
384
slot_dict = current_updater .chassis_table .get (current_sensor .get_name ())
@@ -437,7 +438,7 @@ def test_signal_handler():
437
438
assert daemon_sensormond .stop_event .set .call_count == 0
438
439
assert sensormond .exit_code == 1
439
440
440
-
441
+ @ mock . patch ( 'sonic_py_common.device_info.get_paths_to_platform_and_hwsku_dirs' , mock . MagicMock ( return_value = ( tests_path , '' )))
441
442
def test_daemon_run ():
442
443
443
444
import sonic_platform .platform
0 commit comments