@@ -264,12 +264,14 @@ def test_file_copy_error(mock_cftv, aireos_device_path, aireos_send_command_timi
264264@mock .patch .object (AIREOSDevice , "set_boot_options" )
265265@mock .patch .object (AIREOSDevice , "reboot" )
266266@mock .patch .object (AIREOSDevice , "_wait_for_device_reboot" )
267- def test_install_os (mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
267+ @mock .patch .object (AIREOSDevice , "peer_redundancy_state" , new_callable = mock .PropertyMock )
268+ def test_install_os (mock_prs , mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
268269 device = aireos_image_booted ([False , True ])
269270 assert device .install_os (aireos_boot_image ) is True
270271 device ._image_booted .assert_has_calls ([mock .call (aireos_boot_image )] * 2 )
271272 mock_sbo .assert_has_calls ([mock .call (aireos_boot_image )])
272273 mock_reboot .assert_called_with (confirm = True , controller = "both" , save_config = True )
274+ mock_prs .assert_called ()
273275
274276
275277def test_install_os_no_install (aireos_image_booted , aireos_boot_image ):
@@ -281,17 +283,33 @@ def test_install_os_no_install(aireos_image_booted, aireos_boot_image):
281283@mock .patch .object (AIREOSDevice , "set_boot_options" )
282284@mock .patch .object (AIREOSDevice , "reboot" )
283285@mock .patch .object (AIREOSDevice , "_wait_for_device_reboot" )
284- def test_install_os_error (mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
286+ @mock .patch .object (AIREOSDevice , "peer_redundancy_state" , new_callable = mock .PropertyMock )
287+ def test_install_os_error (mock_prs , mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
285288 device = aireos_image_booted ([False , False ])
286- with pytest .raises (OSInstallError ):
289+ with pytest .raises (OSInstallError ) as boot_error :
287290 device .install_os (aireos_boot_image )
291+ assert boot_error .value .message == f"{ device .host } was unable to boot into { aireos_boot_image } "
288292 device ._image_booted .assert_has_calls ([mock .call (aireos_boot_image )] * 2 )
289293
290294
291295@mock .patch .object (AIREOSDevice , "set_boot_options" )
292296@mock .patch .object (AIREOSDevice , "reboot" )
293297@mock .patch .object (AIREOSDevice , "_wait_for_device_reboot" )
294- def test_install_os_pass_args (mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
298+ @mock .patch .object (AIREOSDevice , "peer_redundancy_state" , new_callable = mock .PropertyMock )
299+ def test_install_os_error_peer (mock_prs , mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
300+ mock_prs .side_effect = ["standby hot" , "unknown" ]
301+ device = aireos_image_booted ([False , True ])
302+ with pytest .raises (OSInstallError ) as boot_error :
303+ device .install_os (aireos_boot_image )
304+ assert boot_error .value .message == f"{ device .host } -standby was unable to boot into { aireos_boot_image } "
305+ device ._image_booted .assert_has_calls ([mock .call (aireos_boot_image )] * 2 )
306+
307+
308+ @mock .patch .object (AIREOSDevice , "set_boot_options" )
309+ @mock .patch .object (AIREOSDevice , "reboot" )
310+ @mock .patch .object (AIREOSDevice , "_wait_for_device_reboot" )
311+ @mock .patch .object (AIREOSDevice , "peer_redundancy_state" , new_callable = mock .PropertyMock )
312+ def test_install_os_pass_args (mock_prs , mock_wait , mock_reboot , mock_sbo , aireos_image_booted , aireos_boot_image ):
295313 device = aireos_image_booted ([False , True ])
296314 assert device .install_os (aireos_boot_image , controller = "self" , save_config = False ) is True
297315 mock_reboot .assert_called_with (confirm = True , controller = "self" , save_config = False )
@@ -340,6 +358,16 @@ def test_open_standby(mock_ch, aireos_device, aireos_redundancy_state_path):
340358 assert aireos_device .connected is False
341359
342360
361+ def test_peer_redundancy_state_standby_hot (aireos_show ):
362+ device = aireos_show (["show_redundancy_summary_sso_enabled.txt" ])
363+ assert device .peer_redundancy_state == "standby hot"
364+
365+
366+ def test_peer_redundancy_state_standalone (aireos_show ):
367+ device = aireos_show (["show_redundancy_summary_standalone.txt" ])
368+ assert device .peer_redundancy_state == "n/a"
369+
370+
343371@mock .patch ("pyntc.devices.aireos_device.RebootSignal" )
344372@mock .patch .object (AIREOSDevice , "save" )
345373def test_reboot_confirm (mock_save , mock_reboot , aireos_send_command_timing , aireos_redundancy_mode_path ):
0 commit comments