From 0d7fb0780b9d22c10d46f9f347c29d1042b89b40 Mon Sep 17 00:00:00 2001 From: Anthony Fontanini Date: Mon, 6 Jan 2025 10:42:45 -0700 Subject: [PATCH] Update test_upgrade_columns --- test/test_analysis_tools.rb | 41 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/test/test_analysis_tools.rb b/test/test_analysis_tools.rb index f6baa6d03a..33e3c1e6cc 100644 --- a/test/test_analysis_tools.rb +++ b/test/test_analysis_tools.rb @@ -31,27 +31,36 @@ def test_baseline_columns end def test_upgrades_columns - ['national', 'testing'].each do |project| - results_csvs = Dir[File.join(@buildstock_directory, "buildstockbatch/project_#{project}/#{project}_upgrades/results_csvs/results_up*.csv")] - assert_equal(1, results_csvs.size) - buildstockbatch_path = results_csvs[0] - buildstockbatch = CSV.read(buildstockbatch_path, headers: true) + # Read BuildStockBatch results + results_csvs = Dir[File.join(@buildstock_directory, "project_national/sdr_upgrades_tmy3/results_csvs/results_up*.csv")] + assert_equal(17, results_csvs.size) + buildstockbatch_path = results_csvs[1] # Only test at one upgrade + buildstockbatch = CSV.read(buildstockbatch_path, headers: true) - run_analysis_path = File.join(@buildstock_directory, "run_analysis/project_#{project}/results-PackageUpgrade.csv") - run_analysis = CSV.read(run_analysis_path, headers: true) + # Identify empty columns and drop them + empty_columns = buildstockbatch.headers.select do |header| + buildstockbatch[header].all? { |cell| cell.nil? || cell.empty? } + end - buildstockbatch_extras = buildstockbatch.headers - run_analysis.headers - buildstockbatch_extras -= ['apply_upgrade.reference_scenario'] - buildstockbatch_extras -= ['simulation_output_report.applicable'] # buildstockbatch contains simulation_output_report.applicable (old workflow) + # Read run_analysis results + run_analysis_path = File.join(@buildstock_directory, "sdr_upgrades_tmy3/results-ENERGYSTARheatpumpwithelecbackup.csv") + run_analysis = CSV.read(run_analysis_path, headers: true) - puts "#{project}_upgrades, buildstockbatch - run_analysis: #{buildstockbatch_extras}" if !buildstockbatch_extras.empty? + # Test if BuildStockBatch has extra columns that are not empty + buildstockbatch_extras = buildstockbatch.headers - run_analysis.headers + buildstockbatch_extras -= ['simulation_output_report.applicable'] # buildstockbatch contains simulation_output_report.applicable (old workflow) + empty_columns.each do |col| # Remove empty columns from the diff. BuildStockBatch sometimes has empty blank columns + buildstockbatch_extras -= [col] + end - run_analysis_extras = run_analysis.headers - buildstockbatch.headers - puts "#{project}_upgrades, run_analysis - buildstockbatch: #{run_analysis_extras}" if !run_analysis_extras.empty? + puts "sdr_upgrades_tmy3, buildstockbatch - run_analysis: #{buildstockbatch_extras}" if !buildstockbatch_extras.empty? - assert_equal(0, buildstockbatch_extras.size) - assert_equal(0, run_analysis_extras.size) - end + # Test if run_analysis has extra columns + run_analysis_extras = run_analysis.headers - buildstockbatch.headers + puts "sdr_upgrades_tmy3, run_analysis - buildstockbatch: #{run_analysis_extras}" if !run_analysis_extras.empty? + + assert_equal(0, buildstockbatch_extras.size) + assert_equal(0, run_analysis_extras.size) end def test_baseline_results