def test_run_bicep_command_raise_error_if_not_installed_and_not_auto_install( self, isfile_stub): isfile_stub.return_value = False with self.assertRaisesRegex( CLIError, 'Bicep CLI not found. Install it now by running "az bicep install".' ): run_bicep_command(["--version"], auto_install=False)
def test_run_bicep_command_check_version( self, isfile_stub, _get_bicep_installed_version_stub, get_bicep_latest_release_tag_stub, ensure_bicep_installation_mock, _run_command_mock, warning_mock, ): isfile_stub.return_value = True _get_bicep_installed_version_stub.return_value = "1.0.0" get_bicep_latest_release_tag_stub.return_value = "v2.0.0" run_bicep_command(["--version"], check_version=True) warning_mock.assert_called_once_with( 'A new Bicep release is available: %s. Upgrade now by running "az bicep upgrade".', "v2.0.0", )
def test_run_bicep_command_check_version_cache_read_write( self, isfile_stub, _get_bicep_installed_version_stub, get_bicep_latest_release_tag_stub, ensure_bicep_installation_mock, _run_command_mock, warning_mock, ): try: self._remove_bicep_version_check_file() isfile_stub.return_value = True _get_bicep_installed_version_stub.return_value = "1.0.0" get_bicep_latest_release_tag_stub.return_value = "v2.0.0" run_bicep_command(["--version"], check_version=True) self.assertTrue(os.path.isfile(_bicep_version_check_file_path)) finally: self._remove_bicep_version_check_file()