Skip to content

Commit

Permalink
Merge pull request #2163 from NREL/PatMeasureTests
Browse files Browse the repository at this point in the history
Pat measure tests
  • Loading branch information
macumber committed Mar 18, 2016
2 parents 3ec69ac + eefb955 commit a0ebb7b
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 23 deletions.
70 changes: 65 additions & 5 deletions openstudiocore/ruby/openstudio/ruleset/test/PATMeasures_Test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,79 @@

class PATMeasures_Test < MiniTest::Unit::TestCase

def test_PATMeasures
def runPATMeasureTest(pat_measure_name, test_file_name, test_name)
patApplicationMeasuresDir = OpenStudio::BCLMeasure::patApplicationMeasuresDir

# copy measures to build directory and test there
test_dir = (OpenStudio::Path.new($OpenStudio_ResourcePath) /
OpenStudio::Path.new("ruleset/PATMeasures")).to_s
OpenStudio::Path.new("ruleset/PATMeasures/#{pat_measure_name}/#{test_name}")).to_s
if File.exists?(test_dir)
FileUtils.rm_rf(test_dir)
end
FileUtils.cp_r(patApplicationMeasuresDir.to_s,test_dir)
assert(File.exists?("#{patApplicationMeasuresDir}/#{pat_measure_name}"))
FileUtils.mkdir_p(test_dir)
FileUtils.cp_r("#{patApplicationMeasuresDir}/#{pat_measure_name}", test_dir)

test_file = "#{test_dir}/#{pat_measure_name}/tests/#{test_file_name}"
assert(File.exists?(test_file))

test_found = false
File.open(test_file, 'r') do |file|
while line = file.gets
if /^\s*def\s+#{test_name}/.match(line)
test_found = true
end
end
end
assert(test_found)

puts "#{$OpenStudio_RubyExe} -I'#{$OpenStudio_Dir}' '#{$OpenStudio_LibPath}openstudio/ruleset/TestAllMeasuresInDir.rb' '#{test_dir}'"
assert(system("#{$OpenStudio_RubyExe} -I'#{$OpenStudio_Dir}' '#{$OpenStudio_LibPath}openstudio/ruleset/TestAllMeasuresInDir.rb' '#{test_dir}'"))
test_string = "#{$OpenStudio_RubyExe} -I '#{$OpenStudio_Dir}' '#{test_file}' --name=#{test_name}"
puts test_string
assert(system(test_string))
end

def test_CalibrationMeasure_test_CalibrationReports
runPATMeasureTest("CalibrationReports", "CalibrationReports_Test.rb", "test_CalibrationReports")
end

def test_CalibrationMeasure_test_CalibrationReport_NoGas
runPATMeasureTest("CalibrationReports", "CalibrationReports_Test.rb", "test_CalibrationReport_NoGas")
end

def test_CalibrationMeasure_test_CalibrationReports_NoDemand
runPATMeasureTest("CalibrationReports", "CalibrationReports_Test.rb", "test_CalibrationReports_NoDemand")
end

def test_RadianceMeasure_test_number_of_arguments_and_argument_names
runPATMeasureTest("RadianceMeasure", "radiance_measure_test.rb", "test_number_of_arguments_and_argument_names")
end

def test_RadianceMeasure_test_measure
runPATMeasureTest("RadianceMeasure", "radiance_measure_test.rb", "test_measure")
end

def test_ReplaceModel_test_ReplaceModel
runPATMeasureTest("ReplaceModel", "ReplaceModel_Test.rb", "test_ReplaceModel")
end

def test_ReplaceModel_test_ReplaceModel_AltMeasures
runPATMeasureTest("ReplaceModel", "ReplaceModel_Test.rb", "test_ReplaceModel_AltMeasures")
end

def test_ReportRequest_test_number_of_arguments_and_argument_names
runPATMeasureTest("ReportRequest", "report_request_test.rb", "test_number_of_arguments_and_argument_names")
end

def test_StandardReports_test_example_model
runPATMeasureTest("StandardReports", "OpenStudioResults_Test.rb", "test_example_model")
end

def test_StandardReports_test_edge_model
runPATMeasureTest("StandardReports", "OpenStudioResults_Test.rb", "test_edge_model")
end

def test_StandardReports_test_empty_model
runPATMeasureTest("StandardReports", "OpenStudioResults_Test.rb", "test_empty_model")
end

def test_NewMeasures
Expand Down Expand Up @@ -69,5 +128,6 @@ def test_NewMeasures
assert(system("#{$OpenStudio_RubyExe} -I'#{$OpenStudio_Dir}' '#{$OpenStudio_LibPath}openstudio/ruleset/TestAllMeasuresInDir.rb' '#{test_dir}'"))

end

end

Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ def run(runner, user_arguments)
if yearDescription.empty?
missingData = true
runner.registerWarning("Model has no year description and cannot generate all data.")
end
calendarYear = yearDescription.get.calendarYear
if calendarYear.empty?
missingData = true
runner.registerWarning("Model has no calendar year and cannot generate all data.")
else
calendarYear = yearDescription.get.calendarYear
if calendarYear.empty?
missingData = true
runner.registerWarning("Model has no calendar year and cannot generate all data.")
end
end

bill_index = 1
Expand Down
26 changes: 13 additions & 13 deletions openstudiocore/src/pat_app/Measures/CalibrationReports/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>calibration_reports</name>
<uid>e6642d40-7366-4647-8724-53a37991d579</uid>
<version_id>e99970d6-389f-40aa-a6ad-588ff89ebd91</version_id>
<version_modified>20160310T051924Z</version_modified>
<version_id>4be3cdb1-2f7e-4da5-99e5-275e441e84b0</version_id>
<version_modified>20160318T233045Z</version_modified>
<xml_checksum>2C8A3EEF</xml_checksum>
<class_name>CalibrationReports</class_name>
<display_name>Calibration Reports</display_name>
Expand Down Expand Up @@ -39,17 +39,6 @@
<usage_type>test</usage_type>
<checksum>A930DF8D</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>1.7.0</identifier>
<min_compatible>1.7.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>C73203EF</checksum>
</file>
<file>
<filename>0111_cal_test_b.osm</filename>
<filetype>osm</filetype>
Expand All @@ -62,5 +51,16 @@
<usage_type>test</usage_type>
<checksum>5FAA0FD2</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>1.7.0</identifier>
<min_compatible>1.7.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>D4EC7DC7</checksum>
</file>
</files>
</measure>

2 comments on commit a0ebb7b

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (macumber) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2336 of 2406 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (macumber) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

Please sign in to comment.