@@ -170,7 +170,6 @@ def test_del(self):
170170
171171 daemon_pcied .device_table .getKeys .return_value = ['device1' , 'device2' ]
172172 daemon_pcied .status_table .getKeys .return_value = ['status1' ]
173- daemon_pcied .detach_info .getKeys .return_value = ['detach1' , 'detach2' , 'detach3' ]
174173
175174 daemon_pcied .__del__ ()
176175
@@ -181,10 +180,6 @@ def test_del(self):
181180 assert daemon_pcied .status_table ._del .call_count == 1
182181 daemon_pcied .status_table ._del .assert_called_with ('status1' )
183182
184- assert daemon_pcied .detach_info ._del .call_count == 3
185- daemon_pcied .detach_info ._del .assert_any_call ('detach1' )
186- daemon_pcied .detach_info ._del .assert_any_call ('detach2' )
187- daemon_pcied .detach_info ._del .assert_any_call ('detach3' )
188183
189184 @mock .patch ('pcied.load_platform_pcieutil' , mock .MagicMock ())
190185 @mock .patch ('pcied.log.log_warning' )
@@ -202,11 +197,12 @@ def test_is_dpu_in_detaching_mode(self):
202197 daemon_pcied = pcied .DaemonPcied (SYSLOG_IDENTIFIER )
203198 daemon_pcied .detach_info = mock .MagicMock ()
204199 daemon_pcied .detach_info .getKeys = mock .MagicMock (return_value = ['DPU_0' , 'DPU_1' ])
200+ # Mock the get() method to return tuple of (exists, field_value_pairs)
205201 daemon_pcied .detach_info .get = mock .MagicMock (
206202 side_effect = lambda key : {
207- 'DPU_0' : { 'bus_info' : '0000:03:00.1' , 'dpu_state' : 'detaching' } ,
208- 'DPU_1' : { 'bus_info' : '0000:03:00.2' , 'dpu_state' : 'attached' }
209- }.get (key , None )
203+ 'DPU_0' : ( True , [( 'bus_info' , '0000:03:00.1' ), ( 'dpu_state' , 'detaching' )]) ,
204+ 'DPU_1' : ( True , [( 'bus_info' , '0000:03:00.2' ), ( 'dpu_state' , 'attached' )])
205+ }.get (key , ( False , []) )
210206 )
211207
212208 # Test when the device is in detaching mode
0 commit comments