Class: AddExteriorBlindsAndControlTest

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/measures/add_exterior_blinds_and_control/tests/add_exterior_blinds_and_control_test.rb,
lib/measures/add_interior_blinds_and_control/tests/add_exterior_blinds_and_control_test.rb

Instance Method Summary collapse

Instance Method Details

#test_bad_argument_valuesObject



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
# File 'lib/measures/add_exterior_blinds_and_control/tests/add_exterior_blinds_and_control_test.rb', line 32

def test_bad_argument_values
  # create an instance of the measure
  measure = AddExteriorBlindsAndControl.new

  # create runner with empty OSW
  osw = OpenStudio::WorkflowJSON.new
  runner = OpenStudio::Measure::OSRunner.new(osw)

  # make an empty model
  model = OpenStudio::Model::Model.new

  # get arguments
  arguments = measure.arguments(model)
  argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)

  # create hash of argument values
  args_hash = {}
  args_hash['space_name'] = ''

  # 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(model, runner, argument_map)
  result = runner.result

  # show the output
  show_output(result)

  # assert that it ran correctly
  assert_equal('Fail', result.value.valueName)
end

#test_good_argument_valuesObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/measures/add_exterior_blinds_and_control/tests/add_exterior_blinds_and_control_test.rb', line 71

def test_good_argument_values
  # create an instance of the measure
  measure = AddExteriorBlindsAndControl.new

  # create runner with empty OSW
  osw = OpenStudio::WorkflowJSON.new
  runner = OpenStudio::Measure::OSRunner.new(osw)

  # load the test model
  translator = OpenStudio::OSVersion::VersionTranslator.new
  path = "#{File.dirname(__FILE__)}/example_model.osm"
  model = translator.loadModel(path)
  assert(!model.empty?)
  model = model.get

  # store the number of spaces in the seed model
  num_spaces_seed = model.getSpaces.size

  # get arguments
  arguments = measure.arguments(model)
  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['space_name'] = 'New Space'
  # 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(model, runner, argument_map)
  result = runner.result

  # show the output
  show_output(result)

  # assert that it ran correctly
  assert_equal('Success', result.value.valueName)
  assert(result.info.size == 1)
  assert(result.warnings.empty?)

  # check that there is now 1 space
  assert_equal(1, model.getSpaces.size - num_spaces_seed)

  # save the model to test output directory
  output_file_path = "#{File.dirname(__FILE__)}//output/test_output.osm"
  model.save(output_file_path, true)
end

#test_number_of_arguments_and_argument_namesObject

def teardown end



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/measures/add_exterior_blinds_and_control/tests/add_exterior_blinds_and_control_test.rb', line 19

def test_number_of_arguments_and_argument_names
  # create an instance of the measure
  measure = AddExteriorBlindsAndControl.new

  # make an empty model
  model = OpenStudio::Model::Model.new

  # get arguments and test that they are what we are expecting
  arguments = measure.arguments(model)
  assert_equal(1, arguments.size)
  assert_equal('space_name', arguments[0].name)
end