gooddata 0.6.18 → 0.6.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +8 -19
- data/Guardfile +5 -0
- data/README.md +1 -3
- data/bin/gooddata +1 -1
- data/gooddata.gemspec +6 -4
- data/lib/gooddata.rb +1 -1
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +24 -0
- data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/project_cmd.rb +29 -9
- data/lib/gooddata/cli/hooks.rb +9 -3
- data/lib/gooddata/commands/datawarehouse.rb +1 -7
- data/lib/gooddata/commands/project.rb +4 -3
- data/lib/gooddata/core/logging.rb +14 -2
- data/lib/gooddata/exceptions/execution_limit_exceeded.rb +9 -0
- data/lib/gooddata/exceptions/uncomputable_report.rb +8 -0
- data/lib/gooddata/exceptions/validation_error.rb +1 -1
- data/lib/gooddata/goodzilla/goodzilla.rb +5 -1
- data/lib/gooddata/helpers/data_helper.rb +40 -9
- data/lib/gooddata/mixins/md_finders.rb +35 -0
- data/lib/gooddata/models/blueprint/anchor_field.rb +46 -0
- data/lib/gooddata/models/blueprint/attribute_field.rb +25 -0
- data/lib/gooddata/models/blueprint/blueprint.rb +7 -0
- data/lib/gooddata/models/blueprint/blueprint_field.rb +66 -0
- data/lib/gooddata/models/{dashboard_builder.rb → blueprint/dashboard_builder.rb} +0 -0
- data/lib/gooddata/models/{schema_blueprint.rb → blueprint/dataset_blueprint.rb} +176 -117
- data/lib/gooddata/models/blueprint/date_dimension.rb +10 -0
- data/lib/gooddata/models/blueprint/fact_field.rb +16 -0
- data/lib/gooddata/models/blueprint/label_field.rb +39 -0
- data/lib/gooddata/models/{project_blueprint.rb → blueprint/project_blueprint.rb} +366 -168
- data/lib/gooddata/models/blueprint/project_builder.rb +79 -0
- data/lib/gooddata/models/blueprint/reference_field.rb +39 -0
- data/lib/gooddata/models/blueprint/schema_blueprint.rb +156 -0
- data/lib/gooddata/models/blueprint/schema_builder.rb +85 -0
- data/lib/gooddata/models/{to_manifest.rb → blueprint/to_manifest.rb} +25 -20
- data/lib/gooddata/models/{to_wire.rb → blueprint/to_wire.rb} +33 -52
- data/lib/gooddata/models/datawarehouse.rb +2 -2
- data/lib/gooddata/models/domain.rb +3 -2
- data/lib/gooddata/models/execution.rb +2 -2
- data/lib/gooddata/models/execution_detail.rb +7 -2
- data/lib/gooddata/models/from_wire.rb +60 -71
- data/lib/gooddata/models/from_wire_parse.rb +125 -125
- data/lib/gooddata/models/metadata.rb +14 -0
- data/lib/gooddata/models/metadata/dashboard.rb +2 -2
- data/lib/gooddata/models/metadata/label.rb +1 -1
- data/lib/gooddata/models/metadata/report.rb +6 -5
- data/lib/gooddata/models/metadata/report_definition.rb +44 -59
- data/lib/gooddata/models/model.rb +131 -43
- data/lib/gooddata/models/process.rb +13 -11
- data/lib/gooddata/models/profile.rb +12 -1
- data/lib/gooddata/models/project.rb +223 -19
- data/lib/gooddata/models/project_creator.rb +4 -15
- data/lib/gooddata/models/schedule.rb +1 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +2 -2
- data/lib/gooddata/rest/client.rb +18 -18
- data/lib/gooddata/rest/connection.rb +113 -94
- data/lib/gooddata/version.rb +1 -1
- data/lib/templates/project/model/model.rb.erb +15 -16
- data/spec/data/blueprints/additional_dataset_module.json +32 -0
- data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
- data/spec/data/blueprints/invalid_blueprint.json +103 -0
- data/spec/data/blueprints/m_n_model.json +104 -0
- data/spec/data/blueprints/model_module.json +25 -0
- data/spec/data/blueprints/test_blueprint.json +38 -0
- data/spec/data/blueprints/test_project_model_spec.json +106 -0
- data/spec/data/gd_gse_data_manifest.json +34 -34
- data/spec/data/manifests/test_blueprint.json +32 -0
- data/spec/data/{manifest_test_project.json → manifests/test_project.json} +9 -18
- data/spec/data/wire_models/test_blueprint.json +63 -0
- data/spec/data/wire_test_project.json +5 -5
- data/spec/environment/default.rb +33 -0
- data/spec/environment/develop.rb +26 -0
- data/spec/environment/environment.rb +14 -0
- data/spec/environment/hotfix.rb +17 -0
- data/spec/environment/production.rb +31 -0
- data/spec/environment/release.rb +17 -0
- data/spec/helpers/blueprint_helper.rb +10 -7
- data/spec/helpers/cli_helper.rb +24 -22
- data/spec/helpers/connection_helper.rb +27 -25
- data/spec/helpers/crypto_helper.rb +7 -5
- data/spec/helpers/csv_helper.rb +5 -3
- data/spec/helpers/process_helper.rb +15 -10
- data/spec/helpers/project_helper.rb +40 -33
- data/spec/helpers/schedule_helper.rb +15 -9
- data/spec/helpers/spec_helper.rb +11 -0
- data/spec/integration/blueprint_updates_spec.rb +93 -0
- data/spec/integration/command_datawarehouse_spec.rb +2 -1
- data/spec/integration/command_projects_spec.rb +9 -8
- data/spec/integration/create_from_template_spec.rb +1 -1
- data/spec/integration/create_project_spec.rb +1 -1
- data/spec/integration/full_process_schedule_spec.rb +1 -1
- data/spec/integration/full_project_spec.rb +91 -30
- data/spec/integration/over_to_user_filters_spec.rb +24 -28
- data/spec/integration/partial_md_export_import_spec.rb +4 -4
- data/spec/integration/project_spec.rb +1 -1
- data/spec/integration/rest_spec.rb +1 -1
- data/spec/integration/user_filters_spec.rb +19 -24
- data/spec/integration/variables_spec.rb +7 -9
- data/spec/logging_in_logging_out_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -1
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +47 -0
- data/spec/unit/core/connection_spec.rb +2 -2
- data/spec/unit/core/logging_spec.rb +12 -4
- data/spec/unit/helpers/data_helper_spec.rb +60 -0
- data/spec/unit/models/blueprint/attributes_spec.rb +24 -0
- data/spec/unit/models/blueprint/dataset_spec.rb +116 -0
- data/spec/unit/models/blueprint/labels_spec.rb +39 -0
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +643 -0
- data/spec/unit/models/blueprint/reference_spec.rb +24 -0
- data/spec/unit/models/{schema_builder_spec.rb → blueprint/schema_builder_spec.rb} +12 -4
- data/spec/unit/models/blueprint/to_wire_spec.rb +169 -0
- data/spec/unit/models/domain_spec.rb +13 -2
- data/spec/unit/models/from_wire_spec.rb +277 -98
- data/spec/unit/models/metadata_spec.rb +22 -4
- data/spec/unit/models/model_spec.rb +49 -39
- data/spec/unit/models/profile_spec.rb +1 -0
- data/spec/unit/models/project_spec.rb +7 -7
- data/spec/unit/models/schedule_spec.rb +20 -0
- data/spec/unit/models/to_manifest_spec.rb +31 -11
- data/spec/unit/rest/polling_spec.rb +86 -0
- metadata +102 -30
- data/lib/gooddata/models/project_builder.rb +0 -136
- data/lib/gooddata/models/schema_builder.rb +0 -77
- data/out.txt +0 -0
- data/spec/data/additional_dataset_module.json +0 -18
- data/spec/data/blueprint_invalid.json +0 -38
- data/spec/data/m_n_model/blueprint.json +0 -76
- data/spec/data/model_module.json +0 -18
- data/spec/data/test_project_model_spec.json +0 -76
- data/spec/unit/models/attribute_column_spec.rb +0 -7
- data/spec/unit/models/project_blueprint_spec.rb +0 -239
- data/spec/unit/models/to_wire_spec.rb +0 -71
@@ -1,239 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'gooddata'
|
3
|
-
|
4
|
-
describe GoodData::Model::ProjectBlueprint do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
@blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/test_project_model_spec.json')
|
8
|
-
@invalid_blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprint_invalid.json')
|
9
|
-
|
10
|
-
@repos = @blueprint.find_dataset('repos')
|
11
|
-
|
12
|
-
@commits = @blueprint.find_dataset('commits')
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should return the title" do
|
16
|
-
@blueprint.title.should == "RubyGem Dev Week test"
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'valid blueprint should be marked as valid' do
|
20
|
-
@blueprint.valid?.should == true
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'valid blueprint should give you empty array of errors' do
|
24
|
-
expect(@blueprint.validate).to be_empty
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'model should be invalid if it contains more than one anchor' do
|
28
|
-
builder = GoodData::Model::ProjectBuilder.create("my_bp") do |p|
|
29
|
-
p.add_dataset("repos") do |d|
|
30
|
-
d.add_anchor("repo_id")
|
31
|
-
d.add_anchor("repo_id2")
|
32
|
-
d.add_attribute("name")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
bp = GoodData::Model::ProjectBlueprint.new(builder)
|
36
|
-
bp.valid?.should == false
|
37
|
-
errors = bp.validate
|
38
|
-
errors.first.should == {:anchor => 2}
|
39
|
-
errors.count.should == 1
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'invalid blueprint should be marked as invalid' do
|
43
|
-
@invalid_blueprint.valid?.should == false
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'invalid blueprint should give you list of violating references' do
|
47
|
-
errors = @invalid_blueprint.validate
|
48
|
-
errors.size.should == 1
|
49
|
-
errors.first.should == {
|
50
|
-
type: 'reference',
|
51
|
-
name: 'user_id',
|
52
|
-
dataset: 'users',
|
53
|
-
reference: 'user_id'
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'references return empty array if there is no reference' do
|
58
|
-
refs = @blueprint.find_dataset('devs').references
|
59
|
-
expect(refs).to be_empty
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should be possible to create from ProjectBlueprint from ProjectBuilder in several ways" do
|
63
|
-
builder = GoodData::Model::SchemaBuilder.new("stuff") do |d|
|
64
|
-
d.add_attribute("id", :title => "My Id")
|
65
|
-
d.add_fact("amount", :title => "Amount")
|
66
|
-
end
|
67
|
-
bp1 = GoodData::Model::ProjectBlueprint.new(builder)
|
68
|
-
bp1.valid?.should == true
|
69
|
-
|
70
|
-
bp2 = builder.to_blueprint
|
71
|
-
bp2.valid?.should == true
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should be able to get dataset by name' do
|
75
|
-
ds = @blueprint.find_dataset('devs')
|
76
|
-
expect(ds.name).to eq 'devs'
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should throw an error if the dataset with a given name could not be found' do
|
80
|
-
expect { @blueprint.find_dataset('nonexisting_dataset') }.to raise_error
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should not matter if I try to find a dataset using dataset" do
|
84
|
-
ds = @blueprint.find_dataset('devs')
|
85
|
-
sds = @blueprint.find_dataset(ds)
|
86
|
-
ssds = @blueprint.find_dataset(ds.to_hash)
|
87
|
-
expect(ds).to eq sds
|
88
|
-
expect(ds).to eq ssds
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should be able to tell me if ceratain dataset by name is in the blueprint' do
|
92
|
-
@blueprint.dataset?('devs').should be_truthy
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should tell you it has anchor when it does' do
|
96
|
-
@repos.anchor?.should == true
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should tell you it does not have anchor when it does not' do
|
100
|
-
@commits.anchor?.should == false
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should be able to grab attribute' do
|
104
|
-
pending('Wrap into object')
|
105
|
-
@repos.labels.size.should == 1
|
106
|
-
@repos.labels.first.attribute.name.should == 'repo_id'
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'anchor should have labels' do
|
110
|
-
pending('Wrap into object')
|
111
|
-
@repos.anchor.labels.first.identifier.should == 'label.repos.repo_id'
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'attribute should have labels' do
|
115
|
-
pending('Wrap into object')
|
116
|
-
@repos.attributes.first.labels.first.identifier.should == 'label.repos.department'
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'commits should have one fact' do
|
120
|
-
pending('Wrap into object')
|
121
|
-
@commits.facts.size.should == 1
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'Anchor on repos should have a label' do
|
125
|
-
pending('Wrap into object')
|
126
|
-
@repos.anchor.labels.size.should == 2
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should not have a label for a dataset without anchor with label' do
|
130
|
-
pending('Wrap into object')
|
131
|
-
@commits.anchor.should == nil
|
132
|
-
# @commits.to_schema.anchor.labels.empty?.should == true
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'should be able to provide wire representation' do
|
136
|
-
@blueprint.to_wire
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'invalid label is caught correctly' do
|
140
|
-
builder = GoodData::Model::ProjectBuilder.create("my_bp") do |p|
|
141
|
-
p.add_date_dimension("committed_on")
|
142
|
-
|
143
|
-
p.add_dataset("repos") do |d|
|
144
|
-
d.add_anchor("repo_id")
|
145
|
-
d.add_label("name", :reference => "invalid_ref")
|
146
|
-
end
|
147
|
-
end
|
148
|
-
bp = GoodData::Model::ProjectBlueprint.new(builder)
|
149
|
-
bp.valid?.should == false
|
150
|
-
errors = bp.validate
|
151
|
-
errors.count.should == 1
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should return attributes form all datasets" do
|
155
|
-
@blueprint.attributes.count.should == 1
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should return facts form all datasets" do
|
159
|
-
@blueprint.facts.count.should == 1
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should return labels form all datasets" do
|
163
|
-
@blueprint.labels.count.should == 2
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should return labels form all datasets" do
|
167
|
-
@blueprint.attributes_and_anchors.count.should == 3
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should be able to add datasets on the fly" do
|
171
|
-
builder = GoodData::Model::SchemaBuilder.new("stuff") do |d|
|
172
|
-
d.add_attribute("id", :title => "My Id")
|
173
|
-
d.add_fact("amount", :title => "Amount")
|
174
|
-
end
|
175
|
-
dataset = builder.to_blueprint
|
176
|
-
@blueprint.datasets.count.should == 3
|
177
|
-
@blueprint.add_dataset!(dataset)
|
178
|
-
@blueprint.datasets.count.should == 4
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should be able to remove dataset by name" do
|
182
|
-
@blueprint.datasets.count.should == 3
|
183
|
-
@blueprint.remove_dataset!('repos')
|
184
|
-
@blueprint.datasets.count.should == 2
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should be able to remove dataset by reference" do
|
188
|
-
@blueprint.datasets.count.should == 3
|
189
|
-
dataset = @blueprint.find_dataset('repos')
|
190
|
-
@blueprint.remove_dataset!(dataset)
|
191
|
-
@blueprint.datasets.count.should == 2
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should be able to serialize itself to a hash" do
|
195
|
-
ser = @blueprint.to_hash
|
196
|
-
ser.is_a?(Hash)
|
197
|
-
ser.keys.should == [:title, :datasets, :date_dimensions]
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should be able to tell you whether a dataset is referencing any others including date dimensions" do
|
201
|
-
referenced_datasets = @blueprint.referenced_by('commits')
|
202
|
-
referenced_datasets.count.should == 3
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should be able to find star centers - datasets that are not referenced by any other - these are typical fact tables" do
|
206
|
-
centers = @blueprint.find_star_centers
|
207
|
-
centers.count.should == 1
|
208
|
-
centers.first.name.should == 'commits'
|
209
|
-
end
|
210
|
-
|
211
|
-
it "should be able to return all attributes or anchors that can break metrics computed in the context of given dataset" do
|
212
|
-
attrs = @blueprint.can_break('commits')
|
213
|
-
attrs.count.should == 3
|
214
|
-
|
215
|
-
attrs = @blueprint.can_break('devs')
|
216
|
-
attrs.count.should == 1
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should be able to merge models" do
|
220
|
-
additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/additional_dataset_module.json")
|
221
|
-
@blueprint.datasets.count.should == 3
|
222
|
-
@blueprint.merge!(additional_blueprint)
|
223
|
-
@blueprint.datasets.count.should == 4
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should be merging in the additive matter. Order should not matter." do
|
227
|
-
builder = GoodData::Model::ProjectBuilder.create("my_bp") do |p|
|
228
|
-
p.add_date_dimension("created_on")
|
229
|
-
p.add_dataset("stuff") do |d|
|
230
|
-
d.add_anchor("repo_id")
|
231
|
-
d.add_label("name", :reference => "invalid_ref")
|
232
|
-
end
|
233
|
-
end
|
234
|
-
dataset = builder.to_blueprint
|
235
|
-
|
236
|
-
merged1 = @blueprint.merge(dataset)
|
237
|
-
merged2 = dataset.merge(@blueprint)
|
238
|
-
end
|
239
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'gooddata'
|
3
|
-
|
4
|
-
include GoodData::Model
|
5
|
-
|
6
|
-
describe GoodData::Model::ProjectBlueprint do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
|
10
|
-
@result = JSON.parse(File.read("./spec/data/wire_test_project.json"), :symbolize_names => true)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should parse the model view and return the blueprint" do
|
14
|
-
expect(ToWire.to_wire(@spec)).to eq @result
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should generate anchor" do
|
18
|
-
|
19
|
-
dataset_with_anchor = {
|
20
|
-
type: "dataset",
|
21
|
-
name: "repos",
|
22
|
-
columns: [{ type: "anchor", name: "repo_id"}]}
|
23
|
-
|
24
|
-
dataset_without_anchor = {
|
25
|
-
type: "dataset",
|
26
|
-
name: "repos",
|
27
|
-
columns: [{ type: "attribute", name: "repo_id"}]}
|
28
|
-
|
29
|
-
res = ToWire.anchor_to_wire(@spec, dataset_without_anchor)
|
30
|
-
expect(res).to eq({ attribute: { identifier: 'attr.repos.factsof', title: 'Records of Repos', folder: 'Repos' }})
|
31
|
-
|
32
|
-
res = ToWire.anchor_to_wire(@spec, dataset_with_anchor)
|
33
|
-
expect(res).to eq({:attribute=>
|
34
|
-
{:identifier=>"attr.repos.repo_id",
|
35
|
-
:title=>"Repo",
|
36
|
-
:folder => 'Repos',
|
37
|
-
:labels=>
|
38
|
-
[{:label=>
|
39
|
-
{:identifier=>"label.repos.repo_id",
|
40
|
-
:title=>"Repo",
|
41
|
-
:type=>nil,
|
42
|
-
:dataType=>nil}}],
|
43
|
-
:defaultLabel=>"label.repos.repo_id"}})
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should parse the model view and return the blueprint" do
|
47
|
-
fact_table = {
|
48
|
-
:type=>"dataset",
|
49
|
-
:name=>"commits",
|
50
|
-
:columns=>
|
51
|
-
[{:type=>"reference",
|
52
|
-
:name=>"dev_id",
|
53
|
-
:dataset=>"devs",
|
54
|
-
:reference=>"dev_id"}]}
|
55
|
-
expect(ToWire.references_to_wire(@spec, fact_table)).to eq ["dataset.devs"]
|
56
|
-
|
57
|
-
fact_table = {
|
58
|
-
:type=>"dataset",
|
59
|
-
:name=>"commits",
|
60
|
-
:columns=>
|
61
|
-
[{:type=>"date", :name=>"committed_on", :dataset=>"committed_on"}]}
|
62
|
-
expect(ToWire.references_to_wire(@spec, fact_table)).to eq ["committed_on"]
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should generate descriptions' do
|
66
|
-
res = ToWire.to_wire(@spec)
|
67
|
-
payload_datasets = res[:diffRequest][:targetModel][:projectModel][:datasets]
|
68
|
-
repos = payload_datasets.find { |d| d[:dataset][:identifier] == 'dataset.repos' }
|
69
|
-
expect(repos[:dataset][:anchor][:attribute][:description]).to eq 'This is anchor description'
|
70
|
-
end
|
71
|
-
end
|