openstudio-analysis 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/lib/openstudio/analysis/translator/excel.rb +83 -18
- data/lib/openstudio/analysis/version.rb +2 -2
- data/lib/openstudio/templates/analysis.json.erb +5 -2
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +36 -0
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +375 -0
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +5 -0
- data/spec/files/no_variables.xlsx +0 -0
- data/spec/files/partial_weather.epw +32 -0
- data/spec/files/small_list.xlsx +0 -0
- data/spec/files/small_list_incomplete.xlsx +0 -0
- data/spec/files/small_list_repeat_vars.xlsx +0 -0
- data/spec/files/small_list_validation_errors.xlsx +0 -0
- data/spec/files/small_seed.osm +4622 -0
- data/spec/{openstudio-analysis → openstudio/analysis}/server_api_spec.rb +0 -3
- data/spec/openstudio/analysis/translator/excel_spec.rb +89 -0
- data/spec/spec_helper.rb +10 -0
- metadata +26 -4
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
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
|
+
@excel.measure_path.should eq("./measures")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have excel data" do
|
16
|
+
puts @excel
|
17
|
+
@excel.should_not be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should process the excel file" do
|
21
|
+
@excel.process.should eq(true)
|
22
|
+
|
23
|
+
# after processing the measures directory should be what is in the excel file
|
24
|
+
@excel.measure_path.should 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 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
|
+
@excel.models.first.should_not be_nil
|
76
|
+
puts @excel.models.first[:name].should eq("small_seed")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should have a weather file" do
|
80
|
+
@excel.weather_files.first.should_not be_nil
|
81
|
+
@excel.weather_files.first.include?("partial_weather.epw").should be_true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -4,5 +4,15 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
4
4
|
require 'rspec'
|
5
5
|
require 'openstudio-analysis'
|
6
6
|
|
7
|
+
RSpec.configure do |config|
|
8
|
+
# Use color in STDOUT
|
9
|
+
config.color_enabled = true
|
10
|
+
|
11
|
+
# Use color not only in STDOUT but also in pagers and files
|
12
|
+
config.tty = true
|
13
|
+
|
14
|
+
# Use the specified formatter
|
15
|
+
config.formatter = :documentation # :progress, :html, :textmate
|
16
|
+
end
|
7
17
|
|
8
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstudio-analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Long
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -102,7 +102,18 @@ files:
|
|
102
102
|
- README.md
|
103
103
|
- CHANGELOG.md
|
104
104
|
- Rakefile
|
105
|
-
- spec/
|
105
|
+
- spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json
|
106
|
+
- spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb
|
107
|
+
- spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml
|
108
|
+
- spec/files/no_variables.xlsx
|
109
|
+
- spec/files/partial_weather.epw
|
110
|
+
- spec/files/small_list.xlsx
|
111
|
+
- spec/files/small_list_incomplete.xlsx
|
112
|
+
- spec/files/small_list_repeat_vars.xlsx
|
113
|
+
- spec/files/small_list_validation_errors.xlsx
|
114
|
+
- spec/files/small_seed.osm
|
115
|
+
- spec/openstudio/analysis/server_api_spec.rb
|
116
|
+
- spec/openstudio/analysis/translator/excel_spec.rb
|
106
117
|
- spec/spec_helper.rb
|
107
118
|
homepage: http://openstudio.nrel.gov
|
108
119
|
licenses:
|
@@ -130,5 +141,16 @@ specification_version: 4
|
|
130
141
|
summary: Create JSON, ZIP to communicate with OpenStudio Distributed Analysis in the
|
131
142
|
Cloud
|
132
143
|
test_files:
|
133
|
-
- spec/
|
144
|
+
- spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json
|
145
|
+
- spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb
|
146
|
+
- spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml
|
147
|
+
- spec/files/no_variables.xlsx
|
148
|
+
- spec/files/partial_weather.epw
|
149
|
+
- spec/files/small_list.xlsx
|
150
|
+
- spec/files/small_list_incomplete.xlsx
|
151
|
+
- spec/files/small_list_repeat_vars.xlsx
|
152
|
+
- spec/files/small_list_validation_errors.xlsx
|
153
|
+
- spec/files/small_seed.osm
|
154
|
+
- spec/openstudio/analysis/server_api_spec.rb
|
155
|
+
- spec/openstudio/analysis/translator/excel_spec.rb
|
134
156
|
- spec/spec_helper.rb
|