Generate simplified solution reports in CSV format

This commit is contained in:
2020-09-18 11:12:15 -05:00
parent ec0fd7aed6
commit ff23004022
26 changed files with 8023 additions and 23 deletions

28
test/reports_test.jl Normal file
View File

@@ -0,0 +1,28 @@
# RELOG: Reverse Logistics Optimization
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using RELOG, JSON, GZip
load_json_gz(filename) = JSON.parse(GZip.gzopen(filename))
function check(func, expected_csv_filename::String)
solution = load_json_gz("fixtures/nimh_solution.json.gz")
actual_csv_filename = tempname()
func(solution, actual_csv_filename)
@test isfile(actual_csv_filename)
if readlines(actual_csv_filename) != readlines(expected_csv_filename)
out_filename = replace(expected_csv_filename, ".csv" => "_actual.csv")
@error "$func: Unexpected CSV contents: $out_filename"
write(out_filename, read(actual_csv_filename))
@test false
end
end
@testset "Reports" begin
check(RELOG.write_plants_report, "fixtures/nimh_plants.csv")
check(RELOG.write_plant_outputs_report, "fixtures/nimh_plant_outputs.csv")
check(RELOG.write_plant_emissions_report, "fixtures/nimh_plant_emissions.csv")
check(RELOG.write_transportation_report, "fixtures/nimh_transportation.csv")
check(RELOG.write_transportation_emissions_report, "fixtures/nimh_transportation_emissions.csv")
end