Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ycoheNvidia committed Feb 23, 2023
1 parent 21693d5 commit ea44c53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sonic_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ def install(url, force, skip_platform_check=False, skip_migration=False, skip_pa
else:
echo_and_log('Verification successful')
except AttributeError:
echo_and_log("Skip Verifing image {} signature,".format(binary_image_version) +
"method not implemented for the current bootloader type: {}".format(bootloader.__class__.__name__))
pass
echo_and_log("Skip Verifing image {} signature,".format(binary_image_version) +
" method not implemented for the current bootloader type: {}".format(bootloader.__class__.__name__))
pass

echo_and_log("Installing image {} and setting it as default...".format(binary_image_version))
with SWAPAllocator(not skip_setup_swap, swap_mem_size, total_mem_threshold, available_mem_threshold):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_sonic_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ def rootfs_path_mock(path):
print(result.output)

assert result.exit_code == 0
mock_bootloader_verify_image_sign_fail = mock_bootloader
mock_bootloader_verify_image_sign_fail = mock_bootloader.copy()
mock_bootloader_verify_image_sign_fail.verify_image_sign = Mock(return_value=False)
get_bootloader.return_value=mock_bootloader_verify_image_sign_fail
result = runner.invoke(sonic_installer.commands["install"], [sonic_image_filename, "-y"])
print(result.output)

assert result.exit_code != 0
mock_bootloader_verify_image_sign_not_implemented = mock_bootloader
mock_bootloader_verify_image_sign_not_implemented = mock_bootloader.copy()
mock_bootloader_verify_image_sign_not_implemented.verify_image_sign = Mock(side_effect=AttributeError)
get_bootloader.return_value=mock_bootloader_verify_image_sign_not_implemented
result = runner.invoke(sonic_installer.commands["install"], [sonic_image_filename, "-y"])
print(result.output)

assert result.exit_code == 0
assert result.exit_code != 0
# Assert bootloader install API was called
mock_bootloader.install_image.assert_called_with(f"./{sonic_image_filename}")
# Assert all below commands were called, so we ensure that
Expand Down

0 comments on commit ea44c53

Please sign in to comment.