def flush(modified_env): if not is_mocked_environment: return if not modified_env: #TODO now this would not happen #for more information see comment in #pcs.cli.common.lib_wrapper.lib_env_to_cli_env raise console_report.error("Error during library communication") env_file.process_no_existing_file_expectation( "booth config file", modified_env["config_file"], config_path) env_file.process_no_existing_file_expectation("booth key file", modified_env["key_file"], key_path) env_file.write(modified_env["key_file"], key_path) env_file.write(modified_env["config_file"], config_path)
def test_exit_when_cannot_open_file(self): self.mock_open.side_effect = EnvironmentError() self.mock_error.side_effect = SystemExit() self.assertRaises( SystemExit, lambda: env_file.write({"content": "filecontent"}, FILE_PATH) )
def flush(modified_env): if not is_mocked_environment: return if not modified_env: #TODO now this would not happen #for more information see comment in #pcs.cli.common.lib_wrapper.lib_env_to_cli_env raise console_report.error("Error during library communication") env_file.process_no_existing_file_expectation( "booth config file", modified_env["config_file"], config_path ) env_file.process_no_existing_file_expectation( "booth key file", modified_env["key_file"], key_path ) env_file.write(modified_env["key_file"], key_path) env_file.write(modified_env["config_file"], config_path)
def assert_params_causes_calls(self, env_file_dict, calls, path=FILE_PATH): with patch_env_file("open", self.mock_open, create=True): env_file.write(env_file_dict, path) self.assertEqual(self.mock_open.mock_calls, calls)