openstudio-analysis 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openstudio/analysis/translator/excel.rb +2 -1
  3. data/lib/openstudio/analysis/version.rb +1 -1
  4. data/spec/files/analysis/medium_office.json +192 -192
  5. data/spec/files/analysis/medium_office.zip +0 -0
  6. data/spec/files/export/analysis/Kats model v2.json +461 -0
  7. data/spec/files/export/analysis/Kats model v2.zip +0 -0
  8. data/spec/files/export/analysis/discrete_dynamic_seed.json +461 -0
  9. data/spec/files/export/analysis/discrete_dynamic_seed.zip +0 -0
  10. data/spec/files/export/analysis/discrete_seed.json +736 -0
  11. data/spec/files/export/analysis/discrete_seed.zip +0 -0
  12. data/spec/files/export/analysis/output_vars.json +707 -0
  13. data/spec/files/export/analysis/output_vars.zip +0 -0
  14. data/spec/files/export/analysis/small_seed.json +665 -0
  15. data/spec/files/export/analysis/small_seed.zip +0 -0
  16. data/spec/files/template_0_2_0_simpletest.xlsx +0 -0
  17. data/spec/files/{~$template_0_2_0.xlsx → ~$template_0_2_0_simpletest.xlsx} +0 -0
  18. data/spec/openstudio/analysis/translator/excel_spec.rb +316 -289
  19. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-create-a-new-localhost-instance.64.xml +9 -0
  20. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi-test-not-localhost.64.xml +9 -0
  21. data/spec/reports/SPEC-OpenStudio-Analysis-ServerApi.64.xml +7 -0
  22. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-variables.22.xml +18 -0
  23. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-discrete-with-dynamic-columns.6.xml +17 -0
  24. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-no-variables-defined.64.xml +20 -0
  25. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup-with-user.30.xml +9 -0
  26. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-proxy-setup.36.xml +9 -0
  27. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-output-variables.16.xml +36 -0
  28. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-setup-version-0-1-9.13.xml +21 -0
  29. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-incomplete-variables.64.xml +9 -0
  30. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables-should-not-validate.64.xml +9 -0
  31. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-of-variables.64.xml +23 -0
  32. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-small-list-with-with-repeated-variable-names.64.xml +9 -0
  33. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-1-10.13.xml +13 -0
  34. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel-version-0-2-0.xml +32 -0
  35. data/spec/reports/SPEC-OpenStudio-Analysis-Translator-Excel.64.xml +7 -0
  36. metadata +60 -6
  37. data/spec/files/~$template_input_0.1.10.xlsx +0 -0
@@ -1,300 +1,300 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OpenStudio::Analysis::Translator::Excel do
4
- #context "no variables defined" do
5
- # let(:path) { "spec/files/no_variables.xlsx" }
6
- #
7
- # before(:each) do
8
- # @excel = OpenStudio::Analysis::Translator::Excel.new(path)
9
- # end
10
- #
11
- # it "should have measure path" do
12
- # expect(@excel.measure_path).to eq("./measures")
13
- # end
14
- #
15
- # it "should have excel data" do
16
- # puts @excel
17
- # expect(@excel).not_to be_nil
18
- # end
19
- #
20
- # it "should process the excel file" do
21
- # expect(@excel.process).to eq(true)
22
- #
23
- # # after processing the measures directory should be what is in the excel file
24
- # expect(@excel.measure_path).to eq(File.expand_path(File.join("spec", "files", "measures")))
25
- # end
26
- #
27
- # it "should not work because no variables defined" do
28
- # #old_path = @excel.measure_path
29
- # #@excel.measure_path = "path/does/not/exist"
30
- # #
31
- # end
32
- #
33
- # it "should not export to a JSON" do
34
- # @excel.process
35
- # expect { @excel.save_analysis }.to raise_error("Argument 'r_value' did not process. Most likely it did not have all parameters defined.")
36
- # end
37
- #end
38
- #
39
- #context "small list of incomplete variables" do
40
- # before(:all) do
41
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list_incomplete.xlsx")
42
- # end
43
- #
44
- # it "should fail to process" do
45
- # expect { @excel.process }.to raise_error("Variable adjust_thermostat_setpoints_by_degrees:cooling_adjustment must have a mean")
46
- # end
47
- #end
48
- #
49
- #context "small list with with repeated variable names" do
50
- # before(:all) do
51
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list_repeat_vars.xlsx")
52
- # end
53
- #
54
- # it "should fail to process" do
55
- # expect { @excel.process }.to raise_error("duplicate variable names found in list [\"Insulation R-value (ft^2*h*R/Btu).\"]")
56
- # end
57
- #end
58
- #
59
- #context "small list of variables should not validate" do
60
- # before(:all) do
61
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list_validation_errors.xlsx")
62
- # end
63
- #
64
- # it "should fail to process" do
65
- # expect { @excel.process }.to raise_error("Variable min is greater than variable max for adjust_thermostat_setpoints_by_degrees:heating_adjustment")
66
- # end
67
- #end
68
- #
69
- #context "small list of variables" do
70
- # before(:all) do
71
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list.xlsx")
72
- # @excel.process
73
- # end
74
- # it "should have a model" do
75
- # expect(@excel.models.first).not_to be_nil
76
- # expect(@excel.models.first[:name]).to eq("small_seed")
77
- # end
78
- #
79
- # it "should have a weather file" do
80
- # expect(@excel.weather_files.first).not_to be_nil
81
- # puts @excel.weather_files.first
82
- # expect(@excel.weather_files.first.include?("partial_weather.epw")).to eq(true)
83
- # end
84
- #
85
- # it "should have notes and source" do
86
- # @excel.variables['data'].each do |measure|
87
- # measure['variables'].each do |var|
88
- # if var['machine_name'] == 'lighting_power_reduction'
89
- # expect(var['distribution']['source']).to eq("some data source")
90
- # elsif var['machine_name'] == 'demo_cost_initial_const'
91
- # expect(var['notes']).to eq("some note")
92
- # end
93
- # end
94
- # end
95
- # end
96
- #
97
- # it "should write a json" do
98
- # @excel.save_analysis
99
- # expect(File).to exist("spec/files/export/analysis/small_seed.json")
100
- # expect(File).to exist("spec/files/export/analysis/small_seed.zip")
101
- #
102
- # expect(JSON.parse(File.read("spec/files/export/analysis/small_seed.json"))).not_to be_nil
103
- #
104
- # end
105
- #end
106
- #
107
- #context "setup version 0.1.9" do
108
- # before(:all) do
109
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/setup_version_2.xlsx")
110
- # @excel.process
111
- # end
112
- #
113
- # it "should have a version and machine name" do
114
- # expect(@excel.version).to eq("0.1.9")
115
- # expect(@excel.machine_name).to eq("example_analysis")
116
- # end
117
- # it "should have the new settings" do
118
- # expect(@excel.settings["server_instance_type"]).to eq("m2.xlarge")
119
- # end
120
- #
121
- # it "should have algorithm setup" do
122
- # expect(@excel.algorithm["number_of_samples"]).to eq(100)
123
- # expect(@excel.algorithm["number_of_generations"]).to eq(20)
124
- # expect(@excel.algorithm["sample_method"]).to eq("all_variables")
125
- # expect(@excel.algorithm["number_of_generations"]).to be_a Integer
126
- # expect(@excel.algorithm["tolerance"]).to eq(0.115)
127
- # expect(@excel.algorithm["tolerance"]).to be_a Float
128
- #
129
- # end
130
- #
131
- # it "should create a valid hash" do
132
- # h = @excel.create_analysis_hash
133
- #
134
- # expect(h['analysis']['problem']['analysis_type']).to eq("lhs")
135
- # expect(h['analysis']['problem']['algorithm']).not_to be_nil
136
- # expect(h['analysis']['problem']['algorithm']['number_of_samples']).to eq(100)
137
- # expect(h['analysis']['problem']['algorithm']['sample_method']).to eq("all_variables")
138
- # end
139
- #end
140
- #
141
- #context "proxy setup" do
142
- # before(:all) do
143
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/proxy.xlsx")
144
- # @excel.process
145
- # end
146
- #
147
- # it "should have a proxy setting" do
148
- # expect(@excel.settings["proxy_host"]).to eq("192.168.0.1")
149
- # expect(@excel.settings["proxy_port"]).to eq(8080)
150
- # expect(@excel.settings["proxy_username"]).to be_nil
151
- #
152
- # end
153
- #end
154
- #
155
- #context "proxy setup with user" do
156
- # before(:all) do
157
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/proxy_user.xlsx")
158
- # @excel.process
159
- # end
160
- #
161
- # it "should have a user" do
162
- # expect(@excel.settings["proxy_host"]).to eq("192.168.0.1")
163
- # expect(@excel.settings["proxy_port"]).to eq(8080)
164
- # expect(@excel.settings["proxy_username"]).to eq("a_user")
165
- # end
166
- #end
167
- #
168
- #context "discrete variables" do
169
- # before(:all) do
170
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/discrete_variables.xlsx")
171
- # @excel.process
172
- # end
173
- #
174
- # it "should have parsed the spreadsheet" do
175
- # @excel.variables['data'].each do |measure|
176
- # measure['variables'].each do |var|
177
- #
178
- # end
179
- # end
180
- # end
181
- #
182
- # it "should save the file" do
183
- # @excel.save_analysis
184
- # end
185
- #end
186
- #
187
- #context "discrete with dynamic columns" do
188
- # before(:all) do
189
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/discrete_dynamic_columns.xlsx")
190
- # @excel.process
191
- # end
192
- #
193
- # it "should have parsed the spreadsheet" do
194
- # @excel.variables['data'].each do |measure|
195
- # measure['variables'].each do |var|
196
- # puts var.inspect
197
- # end
198
- # end
199
- # end
200
- #
201
- # it "should save the file" do
202
- # @excel.save_analysis
203
- # end
204
- #end
205
- #
206
- #context "setup output variables" do
207
- # before(:all) do
208
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/outputvars.xlsx")
209
- # @excel.process
210
- # end
211
- #
212
- # it "should have a model" do
213
- # expect(@excel.models.first).not_to be_nil
214
- # expect(@excel.models.first[:name]).to eq("output_vars")
215
- # end
216
- #
217
- # it "should have a weather file" do
218
- # expect(@excel.weather_files.first).not_to be_nil
219
- # puts @excel.weather_files.first
220
- # expect(@excel.weather_files.first.include?("partial_weather.epw")).to eq(true)
221
- # end
222
- #
223
- # it "should have notes and source" do
224
- # @excel.variables['data'].each do |measure|
225
- # measure['variables'].each do |var|
226
- # if var['machine_name'] == 'lighting_power_reduction'
227
- # expect(var['distribution']['source']).to eq("some data source")
228
- # elsif var['machine_name'] == 'demo_cost_initial_const'
229
- # expect(var['notes']).to eq("some note")
230
- # end
231
- # end
232
- # end
233
- # end
234
- #
235
- # it "should have typed booleans" do
236
- # expect(@excel.run_setup['use_server_as_worker']).to eq(true)
237
- # expect(@excel.run_setup['allow_multiple_jobs']).to eq(true)
238
- # end
239
- #
240
- # it "should have algorithm setup" do
241
- # expect(@excel.algorithm["number_of_samples"]).to eq(100)
242
- # expect(@excel.algorithm["number_of_generations"]).to eq(20)
243
- # expect(@excel.algorithm["sample_method"]).to eq("all_variables")
244
- # expect(@excel.algorithm["number_of_generations"]).to be_a Integer
245
- # #expect(@excel.algorithm["tolerance"]).to eq(0.115)
246
- # #expect(@excel.algorithm["tolerance"]).to be_a Float
247
- #
248
- # end
249
- #
250
- # it "should create a valid hash" do
251
- # h = @excel.create_analysis_hash
252
- #
253
- # expect(h['analysis']['problem']['analysis_type']).to eq("nsga")
254
- # expect(h['analysis']['problem']['algorithm']).not_to be_nil
255
- # expect(h['analysis']['problem']['algorithm']['number_of_samples']).to eq(100)
256
- # expect(h['analysis']['problem']['algorithm']['sample_method']).to eq("all_variables")
257
- # end
258
- #
259
- #
260
- # it "should write a json" do
261
- # @excel.save_analysis
262
- # expect(File).to exist("spec/files/export/analysis/output_vars.json")
263
- # expect(File).to exist("spec/files/export/analysis/output_vars.zip")
264
- #
265
- # expect(JSON.parse(File.read("spec/files/export/analysis/output_vars.json"))).not_to be_nil
266
- #
267
- # end
268
- #end
269
- #
270
- #context "version 0.1.10" do
271
- # before(:all) do
272
- # @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/template_input_0.1.10.xlsx")
273
- # end
274
- #
275
- # it "should process" do
276
- # expect(@excel.process).to eq(true)
277
- # end
278
- #
279
- # it "should have new setting variables" do
280
- # puts @excel.settings.inspect
281
- # expect(@excel.settings["user_id"]).to eq('new_user')
282
- # expect(@excel.settings["openstudio_server_version"]).to eq('1.3.2')
283
- # expect(@excel.cluster_name).to eq('analysis_cluster')
284
- # puts @excel.run_setup.inspect
285
- # expect(@excel.run_setup["analysis_name"]).to eq('LHS Example Project')
286
- # end
287
- #end
288
-
4
+ context "no variables defined" do
5
+ let(:path) { "spec/files/no_variables.xlsx" }
6
+
7
+ before(:each) do
8
+ @excel = OpenStudio::Analysis::Translator::Excel.new(path)
9
+ end
10
+
11
+ it "should have measure path" do
12
+ expect(@excel.measure_path).to eq("./measures")
13
+ end
14
+
15
+ it "should have excel data" do
16
+ puts @excel
17
+ expect(@excel).not_to be_nil
18
+ end
19
+
20
+ it "should process the excel file" do
21
+ expect(@excel.process).to eq(true)
22
+
23
+ # after processing the measures directory should be what is in the excel file
24
+ expect(@excel.measure_path).to eq(File.expand_path(File.join("spec", "files", "measures")))
25
+ end
26
+
27
+ it "should not work because no variables defined" do
28
+ #old_path = @excel.measure_path
29
+ #@excel.measure_path = "path/does/not/exist"
30
+ #
31
+ end
32
+
33
+ it "should not export to a JSON" do
34
+ @excel.process
35
+ expect { @excel.save_analysis }.to raise_error("Argument 'r_value' did not process. Most likely it did not have all parameters defined.")
36
+ end
37
+ end
38
+
39
+ context "small list of incomplete variables" do
40
+ before(:all) do
41
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list_incomplete.xlsx")
42
+ end
43
+
44
+ it "should fail to process" do
45
+ expect { @excel.process }.to raise_error("Variable adjust_thermostat_setpoints_by_degrees:cooling_adjustment must have a mean")
46
+ end
47
+ end
48
+
49
+ context "small list with with repeated variable names" do
50
+ before(:all) do
51
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list_repeat_vars.xlsx")
52
+ end
53
+
54
+ it "should fail to process" do
55
+ expect { @excel.process }.to raise_error("duplicate variable names found in list [\"Insulation R-value (ft^2*h*R/Btu).\"]")
56
+ end
57
+ end
58
+
59
+ context "small list of variables should not validate" do
60
+ before(:all) do
61
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list_validation_errors.xlsx")
62
+ end
63
+
64
+ it "should fail to process" do
65
+ expect { @excel.process }.to raise_error("Variable min is greater than variable max for adjust_thermostat_setpoints_by_degrees:heating_adjustment")
66
+ end
67
+ end
68
+
69
+ context "small list of variables" do
70
+ before(:all) do
71
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/small_list.xlsx")
72
+ @excel.process
73
+ end
74
+ it "should have a model" do
75
+ expect(@excel.models.first).not_to be_nil
76
+ expect(@excel.models.first[:name]).to eq("small_seed")
77
+ end
78
+
79
+ it "should have a weather file" do
80
+ expect(@excel.weather_files.first).not_to be_nil
81
+ puts @excel.weather_files.first
82
+ expect(@excel.weather_files.first.include?("partial_weather.epw")).to eq(true)
83
+ end
84
+
85
+ it "should have notes and source" do
86
+ @excel.variables['data'].each do |measure|
87
+ measure['variables'].each do |var|
88
+ if var['machine_name'] == 'lighting_power_reduction'
89
+ expect(var['distribution']['source']).to eq("some data source")
90
+ elsif var['machine_name'] == 'demo_cost_initial_const'
91
+ expect(var['notes']).to eq("some note")
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ it "should write a json" do
98
+ @excel.save_analysis
99
+ expect(File).to exist("spec/files/export/analysis/small_seed.json")
100
+ expect(File).to exist("spec/files/export/analysis/small_seed.zip")
101
+
102
+ expect(JSON.parse(File.read("spec/files/export/analysis/small_seed.json"))).not_to be_nil
103
+
104
+ end
105
+ end
106
+
107
+ context "setup version 0.1.9" do
108
+ before(:all) do
109
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/setup_version_2.xlsx")
110
+ @excel.process
111
+ end
112
+
113
+ it "should have a version and machine name" do
114
+ expect(@excel.version).to eq("0.1.9")
115
+ expect(@excel.machine_name).to eq("example_analysis")
116
+ end
117
+ it "should have the new settings" do
118
+ expect(@excel.settings["server_instance_type"]).to eq("m2.xlarge")
119
+ end
120
+
121
+ it "should have algorithm setup" do
122
+ expect(@excel.algorithm["number_of_samples"]).to eq(100)
123
+ expect(@excel.algorithm["number_of_generations"]).to eq(20)
124
+ expect(@excel.algorithm["sample_method"]).to eq("all_variables")
125
+ expect(@excel.algorithm["number_of_generations"]).to be_a Integer
126
+ expect(@excel.algorithm["tolerance"]).to eq(0.115)
127
+ expect(@excel.algorithm["tolerance"]).to be_a Float
128
+
129
+ end
130
+
131
+ it "should create a valid hash" do
132
+ h = @excel.create_analysis_hash
133
+
134
+ expect(h['analysis']['problem']['analysis_type']).to eq("lhs")
135
+ expect(h['analysis']['problem']['algorithm']).not_to be_nil
136
+ expect(h['analysis']['problem']['algorithm']['number_of_samples']).to eq(100)
137
+ expect(h['analysis']['problem']['algorithm']['sample_method']).to eq("all_variables")
138
+ end
139
+ end
140
+
141
+ context "proxy setup" do
142
+ before(:all) do
143
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/proxy.xlsx")
144
+ @excel.process
145
+ end
146
+
147
+ it "should have a proxy setting" do
148
+ expect(@excel.settings["proxy_host"]).to eq("192.168.0.1")
149
+ expect(@excel.settings["proxy_port"]).to eq(8080)
150
+ expect(@excel.settings["proxy_username"]).to be_nil
151
+
152
+ end
153
+ end
154
+
155
+ context "proxy setup with user" do
156
+ before(:all) do
157
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/proxy_user.xlsx")
158
+ @excel.process
159
+ end
160
+
161
+ it "should have a user" do
162
+ expect(@excel.settings["proxy_host"]).to eq("192.168.0.1")
163
+ expect(@excel.settings["proxy_port"]).to eq(8080)
164
+ expect(@excel.settings["proxy_username"]).to eq("a_user")
165
+ end
166
+ end
167
+
168
+ context "discrete variables" do
169
+ before(:all) do
170
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/discrete_variables.xlsx")
171
+ @excel.process
172
+ end
173
+
174
+ it "should have parsed the spreadsheet" do
175
+ @excel.variables['data'].each do |measure|
176
+ measure['variables'].each do |var|
177
+
178
+ end
179
+ end
180
+ end
181
+
182
+ it "should save the file" do
183
+ @excel.save_analysis
184
+ end
185
+ end
186
+
187
+ context "discrete with dynamic columns" do
188
+ before(:all) do
189
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/discrete_dynamic_columns.xlsx")
190
+ @excel.process
191
+ end
192
+
193
+ it "should have parsed the spreadsheet" do
194
+ @excel.variables['data'].each do |measure|
195
+ measure['variables'].each do |var|
196
+ puts var.inspect
197
+ end
198
+ end
199
+ end
200
+
201
+ it "should save the file" do
202
+ @excel.save_analysis
203
+ end
204
+ end
205
+
206
+ context "setup output variables" do
207
+ before(:all) do
208
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/outputvars.xlsx")
209
+ @excel.process
210
+ end
211
+
212
+ it "should have a model" do
213
+ expect(@excel.models.first).not_to be_nil
214
+ expect(@excel.models.first[:name]).to eq("output_vars")
215
+ end
216
+
217
+ it "should have a weather file" do
218
+ expect(@excel.weather_files.first).not_to be_nil
219
+ puts @excel.weather_files.first
220
+ expect(@excel.weather_files.first.include?("partial_weather.epw")).to eq(true)
221
+ end
222
+
223
+ it "should have notes and source" do
224
+ @excel.variables['data'].each do |measure|
225
+ measure['variables'].each do |var|
226
+ if var['machine_name'] == 'lighting_power_reduction'
227
+ expect(var['distribution']['source']).to eq("some data source")
228
+ elsif var['machine_name'] == 'demo_cost_initial_const'
229
+ expect(var['notes']).to eq("some note")
230
+ end
231
+ end
232
+ end
233
+ end
234
+
235
+ it "should have typed booleans" do
236
+ expect(@excel.run_setup['use_server_as_worker']).to eq(true)
237
+ expect(@excel.run_setup['allow_multiple_jobs']).to eq(true)
238
+ end
239
+
240
+ it "should have algorithm setup" do
241
+ expect(@excel.algorithm["number_of_samples"]).to eq(100)
242
+ expect(@excel.algorithm["number_of_generations"]).to eq(20)
243
+ expect(@excel.algorithm["sample_method"]).to eq("all_variables")
244
+ expect(@excel.algorithm["number_of_generations"]).to be_a Integer
245
+ #expect(@excel.algorithm["tolerance"]).to eq(0.115)
246
+ #expect(@excel.algorithm["tolerance"]).to be_a Float
247
+
248
+ end
249
+
250
+ it "should create a valid hash" do
251
+ h = @excel.create_analysis_hash
252
+
253
+ expect(h['analysis']['problem']['analysis_type']).to eq("nsga")
254
+ expect(h['analysis']['problem']['algorithm']).not_to be_nil
255
+ expect(h['analysis']['problem']['algorithm']['number_of_samples']).to eq(100)
256
+ expect(h['analysis']['problem']['algorithm']['sample_method']).to eq("all_variables")
257
+ end
258
+
259
+
260
+ it "should write a json" do
261
+ @excel.save_analysis
262
+ expect(File).to exist("spec/files/export/analysis/output_vars.json")
263
+ expect(File).to exist("spec/files/export/analysis/output_vars.zip")
264
+
265
+ expect(JSON.parse(File.read("spec/files/export/analysis/output_vars.json"))).not_to be_nil
266
+
267
+ end
268
+ end
269
+
270
+ context "version 0.1.10" do
271
+ before(:all) do
272
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/template_input_0.1.10.xlsx")
273
+ end
274
+
275
+ it "should process" do
276
+ expect(@excel.process).to eq(true)
277
+ end
278
+
279
+ it "should have new setting variables" do
280
+ puts @excel.settings.inspect
281
+ expect(@excel.settings["user_id"]).to eq('new_user')
282
+ expect(@excel.settings["openstudio_server_version"]).to eq('1.3.2')
283
+ expect(@excel.cluster_name).to eq('analysis_cluster')
284
+ puts @excel.run_setup.inspect
285
+ expect(@excel.run_setup["analysis_name"]).to eq('LHS Example Project')
286
+ end
287
+ end
288
+
289
289
  context "version 0.2.0" do
290
290
  before(:all) do
291
291
  @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/template_0_2_0.xlsx")
292
292
  end
293
-
293
+
294
294
  it "should process" do
295
295
  expect(@excel.process).to eq(true)
296
296
  end
297
-
297
+
298
298
  it "should have new setting variables" do
299
299
  puts @excel.settings.inspect
300
300
  expect(@excel.settings["user_id"]).to eq('new_user')
@@ -307,12 +307,39 @@ describe OpenStudio::Analysis::Translator::Excel do
307
307
  it "should have the new measure directory column" do
308
308
  expect(@excel.variables['data'][1]['measure_file_name_directory']).to eq('ReduceLightingLoadsByPercentage')
309
309
  end
310
-
310
+
311
311
  it "should write a json" do
312
312
  @excel.save_analysis
313
313
  end
314
314
  end
315
-
315
+
316
+ context "version 0.2.0 simple" do
317
+ before(:all) do
318
+ @excel = OpenStudio::Analysis::Translator::Excel.new("spec/files/template_0_2_0_simpletest.xlsx")
319
+ end
320
+
321
+ it "should process" do
322
+ expect(@excel.process).to eq(true)
323
+ end
324
+
325
+ it "should have new setting variables" do
326
+ puts @excel.settings.inspect
327
+ expect(@excel.settings["user_id"]).to eq('new_user')
328
+ expect(@excel.settings["openstudio_server_version"]).to eq('1.3.2')
329
+ puts @excel.run_setup.inspect
330
+ end
331
+
332
+ it "should have the new measure directory column" do
333
+ expect(@excel.variables['data'][1]['measure_file_name_directory']).to eq('AdjustThermostatSetpointsByDegrees')
334
+ expect(@excel.variables['data'][0]['measure_file_name_directory']).to eq('baseline')
335
+ end
336
+
337
+ it "should write a json" do
338
+ @excel.save_analysis
339
+ end
340
+ end
341
+
342
+
316
343
 
317
344
  end
318
345
 
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Analysis::ServerApi create a new localhost instance" tests="1" time="0.033967" failures="0" errors="0" skipped="0" timestamp="2014-04-17T15:12:48-06:00">
3
+ <testcase name="OpenStudio::Analysis::ServerApi create a new localhost instance should set the default host to localhost" time="0.000534">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Analysis::ServerApi test not localhost" tests="1" time="0.000779" failures="0" errors="0" skipped="0" timestamp="2014-04-17T15:12:48-06:00">
3
+ <testcase name="OpenStudio::Analysis::ServerApi test not localhost should have a not localhost URL" time="0.00045">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>