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..b4b258f16b 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,14 +862,22 @@ 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) - results_ed = get_decision_problem_results(results, "ED") - @test isnothing(get_system(results_ed)) + @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) - results_ed = get_decision_problem_results(results, "ED"; populate_system = true) - @test !isnothing(get_system(results_ed)) - @test PSY.get_units_base(get_system(results_ed)) == "NATURAL_UNITS" + test_decision_problem_results_values(results_ed, results_uc, c_sys5_hy_ed, c_sys5_hy_uc) +end - @test_throws IS.InvalidValue set_system!(results_uc, c_sys5_hy_ed) +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") current_file = joinpath( results_uc.execution_path, @@ -870,14 +885,19 @@ function test_simulation_results_from_file(path::AbstractString, c_sys5_hy_ed, c results_uc.problem, PSI.make_system_filename(results_uc.system_uuid), ) - mv(current_file, "system-temporary-file-name.json"; force = true) + @test isfile(current_file) - @test_throws ErrorException get_decision_problem_results( - results, - "UC"; - populate_system = true, - ) - mv("system-temporary-file-name.json", current_file) + # 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)) + + results_ed = get_decision_problem_results(results, "ED"; populate_system = true) + @test !isnothing(get_system(results_ed)) + @test PSY.get_units_base(get_system(results_ed)) == "NATURAL_UNITS" + + @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)