gooddata 0.6.18 → 0.6.19

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 (133) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +8 -19
  4. data/Guardfile +5 -0
  5. data/README.md +1 -3
  6. data/bin/gooddata +1 -1
  7. data/gooddata.gemspec +6 -4
  8. data/lib/gooddata.rb +1 -1
  9. data/lib/gooddata/bricks/middleware/aws_middleware.rb +24 -0
  10. data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
  11. data/lib/gooddata/cli/commands/project_cmd.rb +29 -9
  12. data/lib/gooddata/cli/hooks.rb +9 -3
  13. data/lib/gooddata/commands/datawarehouse.rb +1 -7
  14. data/lib/gooddata/commands/project.rb +4 -3
  15. data/lib/gooddata/core/logging.rb +14 -2
  16. data/lib/gooddata/exceptions/execution_limit_exceeded.rb +9 -0
  17. data/lib/gooddata/exceptions/uncomputable_report.rb +8 -0
  18. data/lib/gooddata/exceptions/validation_error.rb +1 -1
  19. data/lib/gooddata/goodzilla/goodzilla.rb +5 -1
  20. data/lib/gooddata/helpers/data_helper.rb +40 -9
  21. data/lib/gooddata/mixins/md_finders.rb +35 -0
  22. data/lib/gooddata/models/blueprint/anchor_field.rb +46 -0
  23. data/lib/gooddata/models/blueprint/attribute_field.rb +25 -0
  24. data/lib/gooddata/models/blueprint/blueprint.rb +7 -0
  25. data/lib/gooddata/models/blueprint/blueprint_field.rb +66 -0
  26. data/lib/gooddata/models/{dashboard_builder.rb → blueprint/dashboard_builder.rb} +0 -0
  27. data/lib/gooddata/models/{schema_blueprint.rb → blueprint/dataset_blueprint.rb} +176 -117
  28. data/lib/gooddata/models/blueprint/date_dimension.rb +10 -0
  29. data/lib/gooddata/models/blueprint/fact_field.rb +16 -0
  30. data/lib/gooddata/models/blueprint/label_field.rb +39 -0
  31. data/lib/gooddata/models/{project_blueprint.rb → blueprint/project_blueprint.rb} +366 -168
  32. data/lib/gooddata/models/blueprint/project_builder.rb +79 -0
  33. data/lib/gooddata/models/blueprint/reference_field.rb +39 -0
  34. data/lib/gooddata/models/blueprint/schema_blueprint.rb +156 -0
  35. data/lib/gooddata/models/blueprint/schema_builder.rb +85 -0
  36. data/lib/gooddata/models/{to_manifest.rb → blueprint/to_manifest.rb} +25 -20
  37. data/lib/gooddata/models/{to_wire.rb → blueprint/to_wire.rb} +33 -52
  38. data/lib/gooddata/models/datawarehouse.rb +2 -2
  39. data/lib/gooddata/models/domain.rb +3 -2
  40. data/lib/gooddata/models/execution.rb +2 -2
  41. data/lib/gooddata/models/execution_detail.rb +7 -2
  42. data/lib/gooddata/models/from_wire.rb +60 -71
  43. data/lib/gooddata/models/from_wire_parse.rb +125 -125
  44. data/lib/gooddata/models/metadata.rb +14 -0
  45. data/lib/gooddata/models/metadata/dashboard.rb +2 -2
  46. data/lib/gooddata/models/metadata/label.rb +1 -1
  47. data/lib/gooddata/models/metadata/report.rb +6 -5
  48. data/lib/gooddata/models/metadata/report_definition.rb +44 -59
  49. data/lib/gooddata/models/model.rb +131 -43
  50. data/lib/gooddata/models/process.rb +13 -11
  51. data/lib/gooddata/models/profile.rb +12 -1
  52. data/lib/gooddata/models/project.rb +223 -19
  53. data/lib/gooddata/models/project_creator.rb +4 -15
  54. data/lib/gooddata/models/schedule.rb +1 -0
  55. data/lib/gooddata/models/user_filters/user_filter_builder.rb +2 -2
  56. data/lib/gooddata/rest/client.rb +18 -18
  57. data/lib/gooddata/rest/connection.rb +113 -94
  58. data/lib/gooddata/version.rb +1 -1
  59. data/lib/templates/project/model/model.rb.erb +15 -16
  60. data/spec/data/blueprints/additional_dataset_module.json +32 -0
  61. data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
  62. data/spec/data/blueprints/invalid_blueprint.json +103 -0
  63. data/spec/data/blueprints/m_n_model.json +104 -0
  64. data/spec/data/blueprints/model_module.json +25 -0
  65. data/spec/data/blueprints/test_blueprint.json +38 -0
  66. data/spec/data/blueprints/test_project_model_spec.json +106 -0
  67. data/spec/data/gd_gse_data_manifest.json +34 -34
  68. data/spec/data/manifests/test_blueprint.json +32 -0
  69. data/spec/data/{manifest_test_project.json → manifests/test_project.json} +9 -18
  70. data/spec/data/wire_models/test_blueprint.json +63 -0
  71. data/spec/data/wire_test_project.json +5 -5
  72. data/spec/environment/default.rb +33 -0
  73. data/spec/environment/develop.rb +26 -0
  74. data/spec/environment/environment.rb +14 -0
  75. data/spec/environment/hotfix.rb +17 -0
  76. data/spec/environment/production.rb +31 -0
  77. data/spec/environment/release.rb +17 -0
  78. data/spec/helpers/blueprint_helper.rb +10 -7
  79. data/spec/helpers/cli_helper.rb +24 -22
  80. data/spec/helpers/connection_helper.rb +27 -25
  81. data/spec/helpers/crypto_helper.rb +7 -5
  82. data/spec/helpers/csv_helper.rb +5 -3
  83. data/spec/helpers/process_helper.rb +15 -10
  84. data/spec/helpers/project_helper.rb +40 -33
  85. data/spec/helpers/schedule_helper.rb +15 -9
  86. data/spec/helpers/spec_helper.rb +11 -0
  87. data/spec/integration/blueprint_updates_spec.rb +93 -0
  88. data/spec/integration/command_datawarehouse_spec.rb +2 -1
  89. data/spec/integration/command_projects_spec.rb +9 -8
  90. data/spec/integration/create_from_template_spec.rb +1 -1
  91. data/spec/integration/create_project_spec.rb +1 -1
  92. data/spec/integration/full_process_schedule_spec.rb +1 -1
  93. data/spec/integration/full_project_spec.rb +91 -30
  94. data/spec/integration/over_to_user_filters_spec.rb +24 -28
  95. data/spec/integration/partial_md_export_import_spec.rb +4 -4
  96. data/spec/integration/project_spec.rb +1 -1
  97. data/spec/integration/rest_spec.rb +1 -1
  98. data/spec/integration/user_filters_spec.rb +19 -24
  99. data/spec/integration/variables_spec.rb +7 -9
  100. data/spec/logging_in_logging_out_spec.rb +1 -1
  101. data/spec/spec_helper.rb +10 -1
  102. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +47 -0
  103. data/spec/unit/core/connection_spec.rb +2 -2
  104. data/spec/unit/core/logging_spec.rb +12 -4
  105. data/spec/unit/helpers/data_helper_spec.rb +60 -0
  106. data/spec/unit/models/blueprint/attributes_spec.rb +24 -0
  107. data/spec/unit/models/blueprint/dataset_spec.rb +116 -0
  108. data/spec/unit/models/blueprint/labels_spec.rb +39 -0
  109. data/spec/unit/models/blueprint/project_blueprint_spec.rb +643 -0
  110. data/spec/unit/models/blueprint/reference_spec.rb +24 -0
  111. data/spec/unit/models/{schema_builder_spec.rb → blueprint/schema_builder_spec.rb} +12 -4
  112. data/spec/unit/models/blueprint/to_wire_spec.rb +169 -0
  113. data/spec/unit/models/domain_spec.rb +13 -2
  114. data/spec/unit/models/from_wire_spec.rb +277 -98
  115. data/spec/unit/models/metadata_spec.rb +22 -4
  116. data/spec/unit/models/model_spec.rb +49 -39
  117. data/spec/unit/models/profile_spec.rb +1 -0
  118. data/spec/unit/models/project_spec.rb +7 -7
  119. data/spec/unit/models/schedule_spec.rb +20 -0
  120. data/spec/unit/models/to_manifest_spec.rb +31 -11
  121. data/spec/unit/rest/polling_spec.rb +86 -0
  122. metadata +102 -30
  123. data/lib/gooddata/models/project_builder.rb +0 -136
  124. data/lib/gooddata/models/schema_builder.rb +0 -77
  125. data/out.txt +0 -0
  126. data/spec/data/additional_dataset_module.json +0 -18
  127. data/spec/data/blueprint_invalid.json +0 -38
  128. data/spec/data/m_n_model/blueprint.json +0 -76
  129. data/spec/data/model_module.json +0 -18
  130. data/spec/data/test_project_model_spec.json +0 -76
  131. data/spec/unit/models/attribute_column_spec.rb +0 -7
  132. data/spec/unit/models/project_blueprint_spec.rb +0 -239
  133. data/spec/unit/models/to_wire_spec.rb +0 -71
@@ -1,7 +0,0 @@
1
- # # encoding: UTF-8
2
- #
3
- # require 'gooddata/models/columns/attribute'
4
- #
5
- # describe GoodData::Model::Attribute do
6
- #
7
- # end
@@ -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