@@ -199,38 +199,32 @@ def test_get_file_not_found(self, mock_print, _mock_open):
199199 )
200200 self .assertFalse (result )
201201
202- @mock .patch ("amd_debug.ttm.is_root" , return_value = False )
203- @mock .patch ("amd_debug.ttm.print_color" )
204- def test_set_not_root (self , mock_print , _mock_is_root ):
205- """Test set() when not root"""
206- result = self .tool .set (2 )
207- mock_print .assert_called_with ("Root privileges required" , "❌" )
208- self .assertFalse (result )
209-
210- @mock .patch ("amd_debug.ttm.is_root" , return_value = True )
202+ @mock .patch ("amd_debug.ttm.relaunch_sudo" , return_value = True )
211203 @mock .patch ("amd_debug.ttm.get_system_mem" , return_value = 8.0 )
212204 @mock .patch ("amd_debug.ttm.print_color" )
213- def test_set_gb_greater_than_total (self , mock_print , _mock_mem , _mock_is_root ):
205+ def test_set_gb_greater_than_total (
206+ self , mock_print , _mock_mem , _mock_relaunch_sudo
207+ ):
214208 """Test set() when gb_value > total system memory"""
215209 result = self .tool .set (16 )
216210 mock_print .assert_any_call (
217211 "16.00 GB is greater than total system memory (8.00 GB)" , "❌"
218212 )
219213 self .assertFalse (result )
220214
221- @mock .patch ("amd_debug.ttm.is_root " , return_value = True )
215+ @mock .patch ("amd_debug.ttm.relaunch_sudo " , return_value = True )
222216 @mock .patch ("amd_debug.ttm.get_system_mem" , return_value = 10.0 )
223217 @mock .patch ("amd_debug.ttm.print_color" )
224218 @mock .patch ("builtins.input" , return_value = "n" )
225219 def test_set_gb_exceeds_max_percentage_cancel (
226- self , _mock_input , mock_print , _mock_mem , mock_is_root
220+ self , _mock_input , mock_print , _mock_mem , mock_relaunch_sudo
227221 ):
228222 """Test set() when gb_value exceeds max percentage and user cancels"""
229223 result = self .tool .set (9.5 )
230224 self .assertFalse (result )
231225 mock_print .assert_any_call ("Operation cancelled." , "🚦" )
232226
233- @mock .patch ("amd_debug.ttm.is_root " , return_value = True )
227+ @mock .patch ("amd_debug.ttm.relaunch_sudo " , return_value = True )
234228 @mock .patch ("amd_debug.ttm.get_system_mem" , return_value = 10.0 )
235229 @mock .patch ("amd_debug.ttm.gb_to_pages" , return_value = 20480 )
236230 @mock .patch ("amd_debug.ttm.print_color" )
@@ -244,8 +238,8 @@ def test_set_success(
244238 mock_open ,
245239 mock_print ,
246240 _mock_gb_to_pages ,
247- mock_mem ,
248- mock_is_root ,
241+ _mock_mem ,
242+ _relaunch_sudo ,
249243 ):
250244 """Test set() success path"""
251245 result = self .tool .set (5 )
@@ -266,21 +260,12 @@ def test_clear_file_not_exists(self, mock_print, _mock_exists):
266260 self .assertFalse (result )
267261
268262 @mock .patch ("os.path.exists" , return_value = True )
269- @mock .patch ("amd_debug.ttm.is_root" , return_value = False )
270- @mock .patch ("amd_debug.ttm.print_color" )
271- def test_clear_not_root (self , mock_print , _mock_is_root , _mock_exists ):
272- """Test clear() when not root"""
273- result = self .tool .clear ()
274- mock_print .assert_called_with ("Root privileges required" , "❌" )
275- self .assertFalse (result )
276-
277- @mock .patch ("os.path.exists" , return_value = True )
278- @mock .patch ("amd_debug.ttm.is_root" , return_value = True )
263+ @mock .patch ("amd_debug.ttm.relaunch_sudo" , return_value = True )
279264 @mock .patch ("os.remove" )
280265 @mock .patch ("amd_debug.ttm.print_color" )
281266 @mock .patch ("amd_debug.ttm.maybe_reboot" , return_value = True )
282267 def test_clear_success (
283- self , _mock_reboot , mock_print , mock_remove , _mock_is_root , mock_exists
268+ self , _mock_reboot , mock_print , mock_remove , _mock_relaunch_sudo , _mock_exists
284269 ):
285270 """Test clear() success path"""
286271 result = self .tool .clear ()
0 commit comments