From c03fac8c3bf506300dbf028dd133c66749e05fe6 Mon Sep 17 00:00:00 2001 From: Daniel Thom Date: Wed, 6 Mar 2024 15:12:58 -0700 Subject: [PATCH] Fix merge errors with #1060 and #1062 --- test/runtests.jl | 45 ++++++++++++++++----------------- test/test_simulation_results.jl | 42 +++++++++++++++++++----------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 4e6232ec94..8a1ecf86d9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -26,7 +26,6 @@ using DataStructures import UUIDs using Random import Serialization -using Base.Filesystem # Code Quality Tests import Aqua @@ -55,28 +54,28 @@ const LOG_FILE = "power-simulations-test.log" ENV["RUNNING_PSI_TESTS"] = "true" const DISABLED_TEST_FILES = [ -# "test_basic_model_structs.jl", -# "test_device_branch_constructors.jl", -# "test_device_hydro_generation_constructors.jl", -# "test_device_load_constructors.jl", -# "test_device_hybrid_generation_constructors.jl", -# "test_device_renewable_generation_constructors.jl", -# "test_device_storage_constructors.jl", -# "test_device_thermal_generation_constructors.jl", -# "test_jump_model_utils.jl", -# "test_model_decision.jl", -# "test_problem_template.jl", -# "test_model_emulation.jl", -# "test_network_constructors.jl", -"test_services_constructor.jl", -# "test_simulation_models.jl", -# "test_simulation_sequence.jl", -# "test_simulation_build.jl", -# "test_initialization_problem.jl", -# "test_simulation_execute.jl", -# "test_simulation_results.jl", -# "test_simulation_results_export.jl", -# "test_simulation_store.jl", + # "test_basic_model_structs.jl", + # "test_device_branch_constructors.jl", + # "test_device_hydro_generation_constructors.jl", + # "test_device_load_constructors.jl", + # "test_device_hybrid_generation_constructors.jl", + # "test_device_renewable_generation_constructors.jl", + # "test_device_storage_constructors.jl", + # "test_device_thermal_generation_constructors.jl", + # "test_jump_model_utils.jl", + # "test_model_decision.jl", + # "test_problem_template.jl", + # "test_model_emulation.jl", + # "test_network_constructors.jl", + "test_services_constructor.jl", + # "test_simulation_models.jl", + # "test_simulation_sequence.jl", + # "test_simulation_build.jl", + # "test_initialization_problem.jl", + # "test_simulation_execute.jl", + # "test_simulation_results.jl", + # "test_simulation_results_export.jl", + # "test_simulation_store.jl", ] LOG_LEVELS = Dict( diff --git a/test/test_simulation_results.jl b/test/test_simulation_results.jl index 3f5e035d8e..a2202d3782 100644 --- a/test/test_simulation_results.jl +++ b/test/test_simulation_results.jl @@ -259,6 +259,13 @@ function test_simulation_results( ) results = SimulationResults(sim) test_decision_problem_results(results, c_sys5_hy_ed, c_sys5_hy_uc, in_memory) + if !in_memory + test_decision_problem_results_kwargs_handling( + dirname(results.path), + c_sys5_hy_ed, + c_sys5_hy_uc, + ) + end test_emulation_problem_results(results, in_memory) results_ed = get_decision_problem_results(results, "ED") @@ -855,6 +862,26 @@ function test_simulation_results_from_file(path::AbstractString, c_sys5_hy_ed, c @test get_system(results_uc) === nothing @test length(read_realized_variables(results_uc)) == length(UC_EXPECTED_VARS) + @test_throws IS.InvalidValue set_system!(results_uc, c_sys5_hy_ed) + set_system!(results_ed, c_sys5_hy_ed) + set_system!(results_uc, c_sys5_hy_uc) + + test_decision_problem_results_values(results_ed, results_uc, c_sys5_hy_ed, c_sys5_hy_uc) +end + +function test_decision_problem_results_kwargs_handling( + path::AbstractString, + c_sys5_hy_ed, + c_sys5_hy_uc, +) + results = SimulationResults(path, "no_cache") + @test list_decision_problems(results) == ["ED", "UC"] + results_uc = get_decision_problem_results(results, "UC") + results_ed = get_decision_problem_results(results, "ED") + + # Verify this works without system. + @test get_system(results_uc) === nothing + results_ed = get_decision_problem_results(results, "ED") @test isnothing(get_system(results_ed)) @@ -864,21 +891,6 @@ function test_simulation_results_from_file(path::AbstractString, c_sys5_hy_ed, c @test_throws IS.InvalidValue set_system!(results_uc, c_sys5_hy_ed) - current_file = joinpath( - results_uc.execution_path, - "problems", - results_uc.problem, - PSI.make_system_filename(results_uc.system_uuid), - ) - mv(current_file, "system-temporary-file-name.json"; force = true) - - @test_throws ErrorException get_decision_problem_results( - results, - "UC"; - populate_system = true, - ) - mv("system-temporary-file-name.json", current_file) - set_system!(results_ed, c_sys5_hy_ed) set_system!(results_uc, c_sys5_hy_uc)