39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/openstudio-standards/btap/btap_test_helper.rb', line 39
def evaluate_regression_files(test_instance:, cost_result:)
cost_result_json_path = "#{@run_dir}/cost_results.json"
cost_list_json_path = "#{@run_dir}/btap_items.json"
test_instance.assert(File.exist?(cost_result_json_path), "Could not find costing json at this path:#{cost_result_json_path}")
regression_files_folder = "#{File.dirname(@test_path)}/regression_files"
expected_result_filename = "#{regression_files_folder}/#{@model_name}_expected_result.cost.json"
test_result_filename = "#{regression_files_folder}/#{@model_name}_test_result.cost.json"
FileUtils.rm(test_result_filename) if File.exist?(test_result_filename)
if File.exist?(expected_result_filename)
unless FileUtils.compare_file(cost_result_json_path, expected_result_filename)
FileUtils.cp(cost_result_json_path, test_result_filename)
test_instance.assert(false, "Regression test for #{@model_name} produces differences. Examine expected and test result differences in the #{File.dirname(@test_filename)}/regression_files folder ")
end
else
puts "No expected test file...Generating expected file #{expected_result_filename}. Please verify."
FileUtils.cp(cost_result_json_path, expected_result_filename)
end
puts "Regression test for #{@model_name} passed."
if File.exist?(cost_list_json_path)
cost_list = JSON.parse(File.read(cost_list_json_path))
cost_list_output = BTAPCosting.new().cost_list_items(btap_items: cost_list)
cost_result = JSON.parse(File.read(cost_result_json_path))
cost_sum = cost_result['totals']
puts("")
puts("Comparing BTAP_Costing results and itemized costing list cost results:")
puts("Envelope Cost Difference: #{cost_sum['envelope'].to_f - cost_list_output['envelope'].to_f}")
puts("Lighting Cost Difference: #{cost_sum['lighting'].to_f - cost_list_output['lighting'].to_f}")
puts("Heating and Cooling Cost Difference: #{cost_sum['heating_and_cooling'].to_f - cost_list_output['heating_and_cooling'].to_f}")
puts("SHW Cost Difference: #{cost_sum['shw'].to_f - cost_list_output['shw'].to_f}")
puts("Ventilation Cost Difference: #{cost_sum['ventilation'].to_f - cost_list_output['ventilation'].to_f}")
cost_sum['renewables'].nil? ? sum_renew = 0.00 : sum_renew = cost_sum['renewables'].to_f
puts("Renewables Cost Difference: #{sum_renew - cost_list_output['renewables'].to_f}")
if cost_sum['grand_total'] == cost_list_output['grand_total']
puts("No difference in costing between BTAP_Costing results and itemized cost list results.")
else
puts("Total Cost Difference: #{cost_sum['grand_total'].to_f - cost_list_output['grand_total'].to_f}")
end
end
end
|