Class: ApplyDynamicCoatingToRoofWallTest
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- ApplyDynamicCoatingToRoofWallTest
- Defined in:
- lib/measures/apply_dynamic_coating_to_roof_wall/tests/apply_dynamic_coating_to_roof_wall_test.rb
Instance Method Summary collapse
-
#test_good_argument_values_dynamic_coating ⇒ Object
def teardown.
Instance Method Details
#test_good_argument_values_dynamic_coating ⇒ Object
def teardown
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
# File 'lib/measures/apply_dynamic_coating_to_roof_wall/tests/apply_dynamic_coating_to_roof_wall_test.rb', line 16 def test_good_argument_values_dynamic_coating # create an instance of the measure measure = ApplyDynamicCoatingToRoofWall.new # create runner with empty OSW runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new) # load the test model translator = OpenStudio::OSVersion::VersionTranslator.new # path = OpenStudio::Path.new(File.dirname(__FILE__) + '/MediumOffice-90.1-2010-ASHRAE 169-2013-5A.osm') path = OpenStudio::Path.new(File.dirname(__FILE__) + '/SF-CACZ6-HPWH-pre1978.osm') model = translator.loadModel(path) assert(!model.empty?) model = model.get # forward translate OSM file to IDF file ft = OpenStudio::EnergyPlus::ForwardTranslator.new workspace = ft.translateModel(model) # get arguments and test that they are what we are expecting arguments = measure.arguments(workspace) argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments) # create hash of argument values. # If the argument has a default that you want to use, you don't need it in the hash args_hash = {} args_hash['temp_lo'] = 19 args_hash['temp_hi'] = 27 args_hash['apply_where'] = 'Both' # using defaults values from measure.rb for other arguments # populate argument with specified hash value if specified arguments.each do |arg| temp_arg_var = arg.clone if args_hash.key?(arg.name) assert(temp_arg_var.setValue(args_hash[arg.name])) end argument_map[arg.name] = temp_arg_var end # run the measure measure.run(workspace, runner, argument_map) result = runner.result assert_equal('Success', result.value.valueName) # save the workspace to output directory output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + '/output/test_output.idf') workspace.save(output_file_path, true) # test run the modified model epw_file_path = File.join(File.dirname(__FILE__ ), "USA_NY_Buffalo.Niagara.Intl.AP.725280_TMY3.epw") cmd = "#{OpenStudio.getEnergyPlusDirectory.to_s}/energyplus -d #{File.join(File.dirname(__FILE__), 'output')} -w \"#{epw_file_path}\" #{output_file_path}" puts cmd system(cmd) # stdout_str, stderr_str, status = Open3.capture3(get_run_env(), cmd) # if status.success? # OpenStudio.logFree(OpenStudio::Debug, 'openstudio.standards.command', "Successfully ran command: '#{cmd}'") # else # OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "Error running command: '#{cmd}'") # OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "stdout: #{stdout_str}") # OpenStudio.logFree(OpenStudio::Error, 'openstudio.standards.command', "stderr: #{stderr_str}") # end end |