Skip to content

Commit aacda6b

Browse files
Update test_cmis.py
1 parent 3f0f011 commit aacda6b

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

tests/sonic_xcvr/test_cmis.py

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,39 +3038,37 @@ def test_set_module_OutputAmplitudeTargetRx_settings(self):
30383038
assert self.api.xcvr_eeprom.write.call_count == 4
30393039

30403040
def test_get_error_description(self):
3041-
old_func = self.api.is_flat_memory
3042-
self.api.is_flat_memory = MagicMock()
3043-
self.api.is_flat_memory.return_value = False
3044-
self.api.get_module_state = MagicMock()
3045-
self.api.get_module_state.return_value = 'ModuleReady'
3046-
self.api.get_datapath_state = MagicMock()
3047-
self.api.get_datapath_state.return_value = {
3048-
'DP1State': 'DataPathActivated',
3049-
'DP2State': 'DataPathActivated',
3050-
'DP3State': 'DataPathActivated',
3051-
'DP4State': 'DataPathActivated',
3052-
'DP5State': 'DataPathActivated',
3053-
'DP6State': 'DataPathActivated',
3054-
'DP7State': 'DataPathActivated',
3055-
'DP8State': 'DataPathActivated'
3056-
}
3057-
self.api.get_config_datapath_hostlane_status = MagicMock()
3058-
self.api.get_config_datapath_hostlane_status.return_value = {
3059-
'ConfigStatusLane1': 'ConfigSuccess',
3060-
'ConfigStatusLane2': 'ConfigSuccess',
3061-
'ConfigStatusLane3': 'ConfigSuccess',
3062-
'ConfigStatusLane4': 'ConfigSuccess',
3063-
'ConfigStatusLane5': 'ConfigSuccess',
3064-
'ConfigStatusLane6': 'ConfigSuccess',
3065-
'ConfigStatusLane7': 'ConfigSuccess',
3066-
'ConfigStatusLane8': 'ConfigSuccess'
3067-
}
3068-
self.api.xcvr_eeprom.read = MagicMock()
3069-
self.api.xcvr_eeprom.read.return_value = 0x10
3070-
3071-
result = self.api.get_error_description()
3072-
assert result is 'OK'
3073-
self.api.is_flat_memory = old_func
3041+
with patch.object(self.api, 'is_flat_memory') as mock_method:
3042+
mock_method.return_value = False
3043+
self.api.get_module_state = MagicMock()
3044+
self.api.get_module_state.return_value = 'ModuleReady'
3045+
self.api.get_datapath_state = MagicMock()
3046+
self.api.get_datapath_state.return_value = {
3047+
'DP1State': 'DataPathActivated',
3048+
'DP2State': 'DataPathActivated',
3049+
'DP3State': 'DataPathActivated',
3050+
'DP4State': 'DataPathActivated',
3051+
'DP5State': 'DataPathActivated',
3052+
'DP6State': 'DataPathActivated',
3053+
'DP7State': 'DataPathActivated',
3054+
'DP8State': 'DataPathActivated'
3055+
}
3056+
self.api.get_config_datapath_hostlane_status = MagicMock()
3057+
self.api.get_config_datapath_hostlane_status.return_value = {
3058+
'ConfigStatusLane1': 'ConfigSuccess',
3059+
'ConfigStatusLane2': 'ConfigSuccess',
3060+
'ConfigStatusLane3': 'ConfigSuccess',
3061+
'ConfigStatusLane4': 'ConfigSuccess',
3062+
'ConfigStatusLane5': 'ConfigSuccess',
3063+
'ConfigStatusLane6': 'ConfigSuccess',
3064+
'ConfigStatusLane7': 'ConfigSuccess',
3065+
'ConfigStatusLane8': 'ConfigSuccess'
3066+
}
3067+
self.api.xcvr_eeprom.read = MagicMock()
3068+
self.api.xcvr_eeprom.read.return_value = 0x10
3069+
3070+
result = self.api.get_error_description()
3071+
assert result is 'OK'
30743072

30753073
def test_random_read_fail(self):
30763074
def mock_read_raw(offset, size):

0 commit comments

Comments
 (0)