gooddata 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.rubocop.yml +23 -0
- data/.travis.yml +9 -4
- data/CLI.md +439 -0
- data/Gemfile +0 -1
- data/README.md +2 -2
- data/Rakefile +60 -8
- data/doc/templates/default/module/setup.rb +1 -1
- data/examples.rb +2 -0
- data/gooddata +2 -0
- data/gooddata.gemspec +12 -8
- data/lib/gooddata.rb +0 -2
- data/lib/gooddata/bricks/base_downloader.rb +52 -47
- data/lib/gooddata/bricks/brick.rb +20 -31
- data/lib/gooddata/bricks/bricks.rb +1 -1
- data/lib/gooddata/bricks/middleware/base_middleware.rb +9 -7
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +12 -10
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +28 -28
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +20 -16
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +21 -19
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +10 -8
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +36 -34
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +11 -9
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +14 -12
- data/lib/gooddata/bricks/pipeline.rb +28 -0
- data/lib/gooddata/bricks/utils.rb +10 -8
- data/lib/gooddata/cli/cli.rb +1 -6
- data/lib/gooddata/cli/commands/auth_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +7 -5
- data/lib/gooddata/cli/commands/domain_cmd.rb +45 -0
- data/lib/gooddata/cli/commands/process_cmd.rb +42 -5
- data/lib/gooddata/cli/commands/project_cmd.rb +96 -36
- data/lib/gooddata/cli/commands/projects_cmd.rb +21 -0
- data/lib/gooddata/cli/commands/role_cmd.rb +28 -0
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +5 -5
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/{profile_cmd.rb → user_cmd.rb} +7 -9
- data/lib/gooddata/cli/shared.rb +3 -2
- data/lib/gooddata/client.rb +16 -304
- data/lib/gooddata/commands/api.rb +13 -5
- data/lib/gooddata/commands/auth.rb +47 -40
- data/lib/gooddata/commands/base.rb +4 -2
- data/lib/gooddata/commands/commands.rb +1 -1
- data/lib/gooddata/commands/datasets.rb +20 -7
- data/lib/gooddata/commands/domain.rb +23 -0
- data/lib/gooddata/commands/process.rb +23 -117
- data/lib/gooddata/commands/project.rb +147 -0
- data/lib/gooddata/commands/projects.rb +8 -102
- data/lib/gooddata/commands/role.rb +26 -0
- data/lib/gooddata/commands/runners.rb +41 -38
- data/lib/gooddata/commands/scaffold.rb +46 -43
- data/lib/gooddata/commands/user.rb +33 -0
- data/lib/gooddata/connection.rb +43 -353
- data/lib/gooddata/core/connection.rb +389 -0
- data/lib/gooddata/core/core.rb +5 -4
- data/lib/gooddata/core/logging.rb +48 -0
- data/lib/gooddata/core/nil_logger.rb +13 -0
- data/lib/gooddata/core/project.rb +70 -0
- data/lib/gooddata/core/rest.rb +120 -0
- data/lib/gooddata/core/threaded.rb +14 -0
- data/lib/gooddata/core/user.rb +19 -0
- data/lib/gooddata/data/data.rb +2 -1
- data/lib/gooddata/data/guesser.rb +16 -12
- data/lib/gooddata/exceptions/command_failed.rb +1 -1
- data/lib/gooddata/exceptions/exceptions.rb +2 -1
- data/lib/gooddata/exceptions/no_project_error.rb +11 -0
- data/lib/gooddata/exceptions/project_not_found.rb +1 -1
- data/lib/gooddata/extensions/big_decimal.rb +6 -2
- data/lib/gooddata/extract.rb +10 -8
- data/lib/gooddata/goodzilla/goodzilla.rb +61 -59
- data/lib/gooddata/helpers.rb +15 -9
- data/lib/gooddata/models/account_settings.rb +124 -0
- data/lib/gooddata/models/attributes/anchor.rb +37 -0
- data/lib/gooddata/models/attributes/attributes.rb +8 -0
- data/lib/gooddata/models/attributes/date_attribute.rb +25 -0
- data/lib/gooddata/models/attributes/time_attribute.rb +24 -0
- data/lib/gooddata/models/columns/attribute.rb +71 -0
- data/lib/gooddata/models/columns/columns.rb +8 -0
- data/lib/gooddata/models/columns/date_column.rb +63 -0
- data/lib/gooddata/models/columns/fact_model.rb +54 -0
- data/lib/gooddata/models/columns/label.rb +55 -0
- data/lib/gooddata/models/columns/reference.rb +57 -0
- data/lib/gooddata/models/dashboard_builder.rb +26 -0
- data/lib/gooddata/models/data_result.rb +10 -9
- data/lib/gooddata/models/domain.rb +131 -0
- data/lib/gooddata/models/empty_result.rb +5 -8
- data/lib/gooddata/models/facts/facts.rb +8 -0
- data/lib/gooddata/models/facts/time_fact.rb +20 -0
- data/lib/gooddata/models/folders/attribute_folder.rb +20 -0
- data/lib/gooddata/models/folders/fact_folder.rb +20 -0
- data/lib/gooddata/models/folders/folders.rb +8 -0
- data/lib/gooddata/models/invitation.rb +78 -0
- data/lib/gooddata/models/links.rb +6 -6
- data/lib/gooddata/models/md_object.rb +25 -0
- data/lib/gooddata/models/metadata.rb +160 -62
- data/lib/gooddata/models/metadata/attribute.rb +81 -0
- data/lib/gooddata/models/metadata/column.rb +61 -0
- data/lib/gooddata/models/{dashboard.rb → metadata/dashboard.rb} +12 -7
- data/lib/gooddata/models/{data_set.rb → metadata/data_set.rb} +5 -4
- data/lib/gooddata/models/metadata/date_dimension.rb +26 -0
- data/lib/gooddata/models/metadata/display_form.rb +61 -0
- data/lib/gooddata/models/metadata/fact.rb +36 -0
- data/lib/gooddata/models/metadata/folder.rb +24 -0
- data/lib/gooddata/models/metadata/metadata.rb +8 -0
- data/lib/gooddata/models/metadata/metric.rb +197 -0
- data/lib/gooddata/models/metadata/report.rb +115 -0
- data/lib/gooddata/models/{report_definition.rb → metadata/report_definition.rb} +16 -10
- data/lib/gooddata/models/metadata/schema.rb +227 -0
- data/lib/gooddata/models/model.rb +38 -1339
- data/lib/gooddata/models/models.rb +5 -2
- data/lib/gooddata/models/module_constants.rb +29 -0
- data/lib/gooddata/models/process.rb +142 -13
- data/lib/gooddata/models/profile.rb +4 -6
- data/lib/gooddata/models/project.rb +406 -136
- data/lib/gooddata/models/project_blueprint.rb +221 -0
- data/lib/gooddata/models/project_builder.rb +136 -0
- data/lib/gooddata/models/project_creator.rb +138 -0
- data/lib/gooddata/models/project_metadata.rb +11 -10
- data/lib/gooddata/models/project_role.rb +92 -0
- data/lib/gooddata/models/references/date_reference.rb +44 -0
- data/lib/gooddata/models/references/references.rb +8 -0
- data/lib/gooddata/models/references/time_reference.rb +13 -0
- data/lib/gooddata/models/report_data_result.rb +11 -11
- data/lib/gooddata/models/schedule.rb +284 -0
- data/lib/gooddata/models/schema_blueprint.rb +158 -0
- data/lib/gooddata/models/schema_builder.rb +81 -0
- data/lib/gooddata/models/tab_builder.rb +23 -0
- data/lib/gooddata/models/user.rb +165 -0
- data/lib/gooddata/version.rb +1 -1
- data/lib/templates/project/data/devs.csv +1 -1
- data/lib/templates/project/data/repos.csv +1 -1
- data/lib/templates/project/model/model.rb.erb +7 -11
- data/spec/bricks/bricks_spec.rb +2 -0
- data/spec/data/test-ci-data.csv +2 -0
- data/spec/data/test_project_model_spec.json +7 -27
- data/spec/helpers/blueprint_helper.rb +2 -0
- data/spec/helpers/cli_helper.rb +2 -0
- data/spec/helpers/connection_helper.rb +14 -1
- data/spec/helpers/project_helper.rb +16 -0
- data/spec/helpers/schema_helper.rb +16 -0
- data/spec/integration/command_projects_spec.rb +7 -7
- data/spec/integration/create_from_template_spec.rb +2 -2
- data/spec/integration/full_project_spec.rb +160 -7
- data/spec/integration/partial_md_export_import_spec.rb +3 -3
- data/spec/logging_in_logging_out_spec.rb +2 -1
- data/spec/spec_helper.rb +26 -4
- data/spec/unit/bricks/bricks_spec.rb +15 -7
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +2 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +2 -0
- data/spec/unit/cli/cli_spec.rb +2 -0
- data/spec/unit/cli/commands/cmd_api_spec.rb +23 -15
- data/spec/unit/cli/commands/cmd_auth_spec.rb +8 -4
- data/spec/unit/cli/commands/cmd_domain_spec.rb +82 -0
- data/spec/unit/cli/commands/cmd_process_spec.rb +29 -13
- data/spec/unit/cli/commands/cmd_project_spec.rb +51 -30
- data/spec/unit/cli/commands/cmd_role_spec.rb +44 -0
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +8 -4
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +48 -11
- data/spec/unit/cli/commands/cmd_user_spec.rb +29 -0
- data/spec/unit/commands/command_api_spec.rb +1 -1
- data/spec/unit/commands/command_auth_spec.rb +100 -18
- data/spec/unit/commands/command_dataset_spec.rb +4 -0
- data/spec/unit/commands/command_process_spec.rb +9 -4
- data/spec/unit/commands/command_projects_spec.rb +10 -6
- data/spec/unit/commands/command_scaffold_spec.rb +5 -1
- data/spec/unit/commands/command_user_spec.rb +22 -0
- data/spec/unit/core/connection_spec.rb +35 -6
- data/spec/unit/core/logging_spec.rb +65 -0
- data/spec/unit/core/nil_logger_spec.rb +9 -0
- data/spec/unit/core/project_spec.rb +51 -0
- data/spec/unit/core/rest_spec.rb +33 -0
- data/spec/unit/data/guesser_spec.rb +5 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +2 -0
- data/spec/unit/models/account_settings_spec.rb +28 -0
- data/spec/unit/models/anchor_spec.rb +32 -0
- data/spec/unit/models/attribute_column_spec.rb +7 -0
- data/spec/unit/models/domain_spec.rb +45 -0
- data/spec/unit/models/invitation_spec.rb +13 -0
- data/spec/unit/models/md_object_spec.rb +47 -0
- data/spec/unit/models/metric.rb +92 -0
- data/spec/unit/{model → models}/model_spec.rb +9 -7
- data/spec/unit/models/project_blueprint_spec.rb +202 -0
- data/spec/unit/models/project_creator.rb +73 -0
- data/spec/unit/models/project_role_spec.rb +90 -0
- data/spec/unit/models/project_spec.rb +143 -0
- data/spec/unit/models/schedule_spec.rb +491 -0
- data/spec/unit/{model → models}/schema_builder_spec.rb +2 -0
- data/spec/unit/{model → models}/tools_spec.rb +13 -7
- data/spec/unit/models/user_spec.rb +16 -0
- data/test/test_upload.rb +2 -0
- metadata +189 -86
- data/lib/gooddata/commands/profile.rb +0 -11
- data/lib/gooddata/models/attribute.rb +0 -29
- data/lib/gooddata/models/display_form.rb +0 -9
- data/lib/gooddata/models/fact.rb +0 -19
- data/lib/gooddata/models/metric.rb +0 -99
- data/lib/gooddata/models/report.rb +0 -89
- data/spec/data/blueprint_valid.json +0 -37
- data/spec/unit/cli/commands/cmd_profile_spec.rb +0 -16
- data/spec/unit/commands/command_profile_spec.rb +0 -18
- data/spec/unit/core/core_spec.rb +0 -7
- data/spec/unit/model/blueprint_spec.rb +0 -132
- data/spec/unit/model/project_blueprint_spec.rb +0 -44
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'pry'
|
2
4
|
require 'gooddata/models/model'
|
3
5
|
|
@@ -33,16 +35,16 @@ describe GoodData::Model do
|
|
33
35
|
end
|
34
36
|
|
35
37
|
it "should be possible to merge Schema blueprints" do
|
36
|
-
first_dataset = @base_blueprint.
|
37
|
-
additional_blueprint = @additional_blueprint.
|
38
|
+
first_dataset = @base_blueprint.find_dataset("devs").to_hash
|
39
|
+
additional_blueprint = @additional_blueprint.find_dataset("devs").to_hash
|
38
40
|
stuff = GoodData::Model.merge_dataset_columns(first_dataset, additional_blueprint)
|
39
41
|
stuff[:columns].include?({:type => "attribute", :name => "region"}).should == true
|
40
42
|
stuff[:columns].include?({:type => "anchor", :name => "id"}).should == true
|
41
43
|
end
|
42
44
|
|
43
45
|
it "should pass when merging 2 columns with the same name if both columns are identical" do
|
44
|
-
first_dataset = @base_blueprint.
|
45
|
-
additional_blueprint = @blueprint_with_duplicate.
|
46
|
+
first_dataset = @base_blueprint.find_dataset("commits").to_hash
|
47
|
+
additional_blueprint = @blueprint_with_duplicate.find_dataset("commits").to_hash
|
46
48
|
|
47
49
|
stuff = GoodData::Model.merge_dataset_columns(first_dataset, additional_blueprint)
|
48
50
|
|
@@ -52,15 +54,15 @@ describe GoodData::Model do
|
|
52
54
|
end
|
53
55
|
|
54
56
|
it "should pass when merging 2 columns with the same name if all attributes are identical" do
|
55
|
-
first_dataset = @base_blueprint.
|
56
|
-
additional_blueprint = @conflicting_blueprint.
|
57
|
+
first_dataset = @base_blueprint.find_dataset("commits").to_hash
|
58
|
+
additional_blueprint = @conflicting_blueprint.find_dataset("commits").to_hash
|
57
59
|
|
58
60
|
expect { GoodData::Model.merge_dataset_columns(first_dataset, additional_blueprint) }.to raise_error
|
59
61
|
end
|
60
62
|
|
61
63
|
it "should be possible to merge directly whole bleuprints. Blueprint is changed in place when merge! is used" do
|
62
64
|
@base_blueprint.merge!(@additional_blueprint)
|
63
|
-
@base_blueprint.
|
65
|
+
@base_blueprint.find_dataset("repos").attributes.include?({:type => "attribute", :name => "department"})
|
64
66
|
end
|
65
67
|
|
66
68
|
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata'
|
4
|
+
|
5
|
+
describe GoodData::Model::ProjectBlueprint do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/test_project_model_spec.json')
|
9
|
+
@invalid_blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprint_invalid.json')
|
10
|
+
|
11
|
+
@repos = @blueprint.find_dataset('repos')
|
12
|
+
@repos_schema = @repos.to_schema
|
13
|
+
|
14
|
+
@commits = @blueprint.find_dataset('commits')
|
15
|
+
@commits_schema = @commits.to_schema
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return the title" do
|
19
|
+
@blueprint.title.should == "RubyGem Dev Week test"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'valid blueprint should be marked as valid' do
|
23
|
+
@blueprint.model_valid?.should == true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'valid blueprint should give you empty array of errors' do
|
27
|
+
expect(@blueprint.validate_model).to be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'invalid blueprint should be marked as invalid' do
|
31
|
+
@invalid_blueprint.model_valid?.should == false
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'invalid blueprint should give you list of violating references' do
|
35
|
+
errors = @invalid_blueprint.validate_model
|
36
|
+
errors.size.should == 1
|
37
|
+
errors.first.should == {
|
38
|
+
type: 'reference',
|
39
|
+
name: 'user_id',
|
40
|
+
dataset: 'users',
|
41
|
+
reference: 'user_id'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'references return empty array if there is no reference' do
|
46
|
+
refs = @blueprint.find_dataset('devs').references
|
47
|
+
expect(refs).to be_empty
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should be able to get dataset by name' do
|
51
|
+
ds = @blueprint.find_dataset('devs')
|
52
|
+
ds.name.should == 'devs'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should throw an error if the dataset with a given name could not be found' do
|
56
|
+
expect { @blueprint.find_dataset('nonexisting_dataset') }.to raise_error
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should be able to tell me if ceratain dataset by name is in the blueprint' do
|
60
|
+
@blueprint.dataset?('devs').should be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should tell you it has anchor when it does' do
|
64
|
+
@repos.anchor?.should == true
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should tell you it does not have anchor when it does not' do
|
68
|
+
@commits.anchor?.should == false
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should be able to grab attribute' do
|
72
|
+
@repos_schema.labels.size.should == 1
|
73
|
+
@repos_schema.labels.first.attribute.name.should == 'repo_id'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'anchor should have labels' do
|
77
|
+
@repos_schema.anchor.labels.first.identifier.should == 'label.repos.repo_id'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'attribute should have labels' do
|
81
|
+
@repos_schema.attributes.first.labels.first.identifier.should == 'label.repos.department'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'commits should have one fact' do
|
85
|
+
@commits_schema.facts.size.should == 1
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'Anchor on repos should have a label' do
|
89
|
+
@repos_schema.anchor.labels.size.should == 2
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should not have a label for a dataset without anchor with label' do
|
93
|
+
@commits.anchor.should == nil
|
94
|
+
@commits.to_schema.anchor.labels.empty?.should == true
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should be able to provide wire representation' do
|
98
|
+
@commits.to_wire_model
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'invalid label is caught correctly' do
|
102
|
+
builder = GoodData::Model::ProjectBuilder.create("my_bp") do |p|
|
103
|
+
p.add_date_dimension("committed_on")
|
104
|
+
|
105
|
+
p.add_dataset("repos") do |d|
|
106
|
+
d.add_anchor("repo_id")
|
107
|
+
d.add_label("name", :reference => "invalid_ref")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
bp = GoodData::Model::ProjectBlueprint.from_json(builder.to_hash)
|
111
|
+
bp.model_valid?.should == false
|
112
|
+
errors = bp.validate_model
|
113
|
+
errors.count.should == 1
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return attributes form all datasets" do
|
117
|
+
@blueprint.attributes.count.should == 1
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return facts form all datasets" do
|
121
|
+
@blueprint.facts.count.should == 1
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return labels form all datasets" do
|
125
|
+
@blueprint.labels.count.should == 2
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should return labels form all datasets" do
|
129
|
+
@blueprint.attributes_and_anchors.count.should == 3
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should be able to add datasets on the fly" do
|
133
|
+
builder = GoodData::Model::SchemaBuilder.new("stuff") do |d|
|
134
|
+
d.add_attribute("id", :title => "My Id")
|
135
|
+
d.add_fact("amount", :title => "Amount")
|
136
|
+
end
|
137
|
+
dataset = builder.to_blueprint
|
138
|
+
@blueprint.datasets.count.should == 3
|
139
|
+
@blueprint.add_dataset(dataset)
|
140
|
+
@blueprint.datasets.count.should == 4
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should be able to remove dataset by name" do
|
144
|
+
@blueprint.datasets.count.should == 3
|
145
|
+
@blueprint.remove_dataset('repos')
|
146
|
+
@blueprint.datasets.count.should == 2
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should be able to remove dataset by reference" do
|
150
|
+
@blueprint.datasets.count.should == 3
|
151
|
+
dataset = @blueprint.find_dataset('repos')
|
152
|
+
@blueprint.remove_dataset(dataset)
|
153
|
+
@blueprint.datasets.count.should == 2
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should be able to serialize itself to a hash" do
|
157
|
+
ser = @blueprint.to_hash
|
158
|
+
ser.is_a?(Hash)
|
159
|
+
ser.keys.should == [:title, :datasets, :date_dimensions]
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be able to tell you whether a dataset is referenced by any other" do
|
163
|
+
referenced_datasets = @blueprint.referenced_by('commits')
|
164
|
+
referenced_datasets.count.should == 2
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should be able to find star centers - datasets that are not referenced by any other - these are typical fact tables" do
|
168
|
+
centers = @blueprint.find_star_centers
|
169
|
+
centers.count.should == 1
|
170
|
+
centers.first.name.should == 'commits'
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should be able to return all attributes or anchors that can break metrics computed in the context of given dataset" do
|
174
|
+
attrs = @blueprint.can_break('commits')
|
175
|
+
attrs.count.should == 3
|
176
|
+
|
177
|
+
pending("At least those from the same dataset should be able to break")
|
178
|
+
attrs = @blueprint.can_break('devs')
|
179
|
+
attrs.count.should == 1
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should be able to merge models" do
|
183
|
+
additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/additional_dataset_module.json")
|
184
|
+
@blueprint.datasets.count.should == 3
|
185
|
+
@blueprint.merge!(additional_blueprint)
|
186
|
+
@blueprint.datasets.count.should == 4
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should be merging in the additive matter. Order should not matter." do
|
190
|
+
builder = GoodData::Model::ProjectBuilder.create("my_bp") do |p|
|
191
|
+
p.add_date_dimension("created_on")
|
192
|
+
p.add_dataset("stuff") do |d|
|
193
|
+
d.add_anchor("repo_id")
|
194
|
+
d.add_label("name", :reference => "invalid_ref")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
dataset = builder.to_blueprint
|
198
|
+
|
199
|
+
merged1 = @blueprint.merge(dataset)
|
200
|
+
merged2 = dataset.merge(@blueprint)
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata/models/project_creator'
|
4
|
+
|
5
|
+
describe GoodData::Model::ProjectCreator do
|
6
|
+
|
7
|
+
it 'should say it contains a depending metric if it does' do
|
8
|
+
# response['projectModelDiff']['updateScripts']
|
9
|
+
|
10
|
+
data = [
|
11
|
+
{ 'updateScript' => {
|
12
|
+
'preserveData' => true,
|
13
|
+
'cascadeDrops' => false,
|
14
|
+
'maqlDdlChunks' => "a"
|
15
|
+
}},
|
16
|
+
{ 'updateScript' => {
|
17
|
+
'preserveData' => false,
|
18
|
+
'cascadeDrops' => false,
|
19
|
+
'maqlDdlChunks' => "b"
|
20
|
+
}}
|
21
|
+
]
|
22
|
+
chunk = GoodData::Model::ProjectCreator.pick_correct_chunks(data)
|
23
|
+
chunk.should == {
|
24
|
+
'updateScript' => {
|
25
|
+
'preserveData' => true,
|
26
|
+
'cascadeDrops' => false,
|
27
|
+
'maqlDdlChunks' => "a"
|
28
|
+
}}
|
29
|
+
|
30
|
+
|
31
|
+
data = [
|
32
|
+
{ 'updateScript' => {
|
33
|
+
'preserveData' => true,
|
34
|
+
'cascadeDrops' => true,
|
35
|
+
'maqlDdlChunks' => "a"
|
36
|
+
}},
|
37
|
+
{ 'updateScript' => {
|
38
|
+
'preserveData' => false,
|
39
|
+
'cascadeDrops' => true,
|
40
|
+
'maqlDdlChunks' => "b"
|
41
|
+
}}
|
42
|
+
]
|
43
|
+
chunk = GoodData::Model::ProjectCreator.pick_correct_chunks(data)
|
44
|
+
chunk.should == {
|
45
|
+
'updateScript' => {
|
46
|
+
'preserveData' => true,
|
47
|
+
'cascadeDrops' => true,
|
48
|
+
'maqlDdlChunks' => "a"
|
49
|
+
}}
|
50
|
+
|
51
|
+
|
52
|
+
data = [
|
53
|
+
{ 'updateScript' => {
|
54
|
+
'preserveData' => false,
|
55
|
+
'cascadeDrops' => true,
|
56
|
+
'maqlDdlChunks' => "a"
|
57
|
+
}},
|
58
|
+
{ 'updateScript' => {
|
59
|
+
'preserveData' => true,
|
60
|
+
'cascadeDrops' => true,
|
61
|
+
'maqlDdlChunks' => "b"
|
62
|
+
}}
|
63
|
+
]
|
64
|
+
chunk = GoodData::Model::ProjectCreator.pick_correct_chunks(data)
|
65
|
+
chunk.should == {
|
66
|
+
'updateScript' => {
|
67
|
+
'preserveData' => true,
|
68
|
+
'cascadeDrops' => true,
|
69
|
+
'maqlDdlChunks' => "b"
|
70
|
+
}}
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata/models/project'
|
4
|
+
require 'gooddata/models/project_role'
|
5
|
+
|
6
|
+
describe GoodData::ProjectRole do
|
7
|
+
before(:all) do
|
8
|
+
ConnectionHelper.create_default_connection
|
9
|
+
@project = ProjectHelper.get_default_project
|
10
|
+
@roles = @project.roles
|
11
|
+
@role = @roles.first
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:all) do
|
15
|
+
GoodData.disconnect
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#author' do
|
19
|
+
it 'Returns author as GoodData::AccountSettings' do
|
20
|
+
res = @role.author
|
21
|
+
expect(res).to be_an_instance_of(GoodData::AccountSettings)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#contributor' do
|
26
|
+
it 'Returns contributor as GoodData::AccountSettings' do
|
27
|
+
res = @role.contributor
|
28
|
+
expect(res).to be_an_instance_of(GoodData::AccountSettings)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#created' do
|
33
|
+
it 'Returns created date as DateTime' do
|
34
|
+
res = @role.created
|
35
|
+
expect(res).to be_an_instance_of(DateTime)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#identifier' do
|
40
|
+
it 'Returns identifier as String' do
|
41
|
+
res = @role.identifier
|
42
|
+
expect(res).to be_an_instance_of(String)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#permissions' do
|
47
|
+
it 'Returns summary as Hash' do
|
48
|
+
res = @role.permissions
|
49
|
+
expect(res).to be_an_instance_of(Hash)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#summary' do
|
54
|
+
it 'Returns summary as String' do
|
55
|
+
res = @role.summary
|
56
|
+
expect(res).to be_an_instance_of(String)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#title' do
|
61
|
+
it 'Returns title as String' do
|
62
|
+
res = @role.title
|
63
|
+
expect(res).to be_an_instance_of(String)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#updated' do
|
68
|
+
it 'Returns updated date as DateTime' do
|
69
|
+
res = @role.updated
|
70
|
+
expect(res).to be_an_instance_of(DateTime)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#uri' do
|
75
|
+
it 'Returns URI as String' do
|
76
|
+
res = @role.uri
|
77
|
+
expect(res).to be_an_instance_of(String)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#users' do
|
82
|
+
it 'Returns users as Array<GoodData::AccountSettings>' do
|
83
|
+
res = @role.users
|
84
|
+
expect(res).to be_an_instance_of(Array)
|
85
|
+
res.each do |user|
|
86
|
+
expect(user).to be_an_instance_of(GoodData::AccountSettings)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata'
|
4
|
+
|
5
|
+
describe GoodData::Project do
|
6
|
+
before(:each) do
|
7
|
+
ConnectionHelper::create_default_connection
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
GoodData.disconnect
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#[]' do
|
15
|
+
it 'Accepts :all parameter' do
|
16
|
+
pending 'Investigate which credentials use'
|
17
|
+
|
18
|
+
project = GoodData::Project[:all]
|
19
|
+
project.should_not be_nil
|
20
|
+
project.should be_a_kind_of(Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'Returns project if ID passed' do
|
24
|
+
project = ProjectHelper.get_default_project
|
25
|
+
project.should_not be_nil
|
26
|
+
project.should be_a_kind_of(GoodData::Project)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'Returns project if URL passed' do
|
30
|
+
project = ProjectHelper.get_default_project
|
31
|
+
project.should_not be_nil
|
32
|
+
project.should be_a_kind_of(GoodData::Project)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'Throws an exception when invalid format of URL passed' do
|
36
|
+
invalid_url = '/gdc/invalid_url'
|
37
|
+
expect { GoodData::Project[invalid_url] }.to raise_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#all' do
|
42
|
+
it 'Returns all projects' do
|
43
|
+
pending 'Investigate which credentials use'
|
44
|
+
|
45
|
+
GoodData::Project.all
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#get_role_by_identifier' do
|
50
|
+
it 'Looks up for role by identifier' do
|
51
|
+
project = ProjectHelper.get_default_project
|
52
|
+
role = project.get_role_by_identifier('readOnlyUserRole')
|
53
|
+
role.should_not be_nil
|
54
|
+
role.should be_a_kind_of(GoodData::ProjectRole)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#get_role_by_summary' do
|
59
|
+
it 'Looks up for role by summary' do
|
60
|
+
project = ProjectHelper.get_default_project
|
61
|
+
role = project.get_role_by_summary('read only user role')
|
62
|
+
role.should_not be_nil
|
63
|
+
role.should be_a_kind_of(GoodData::ProjectRole)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#get_role_by_title' do
|
68
|
+
it 'Looks up for role by title' do
|
69
|
+
project = ProjectHelper.get_default_project
|
70
|
+
role = project.get_role_by_title('Viewer')
|
71
|
+
role.should_not be_nil
|
72
|
+
role.should be_a_kind_of(GoodData::ProjectRole)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#processes' do
|
77
|
+
it 'Returns the processes' do
|
78
|
+
pending 'Investigate which credentials to use'
|
79
|
+
|
80
|
+
GoodData.project = ProjectHelper::PROJECT_ID
|
81
|
+
|
82
|
+
proj = GoodData.project
|
83
|
+
procs = proj.processes
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#roles' do
|
88
|
+
it 'Returns array of GoodData::ProjectRole' do
|
89
|
+
project = ProjectHelper.get_default_project
|
90
|
+
roles = project.roles
|
91
|
+
expect(roles).to be_instance_of(Array)
|
92
|
+
|
93
|
+
roles.each do |role|
|
94
|
+
expect(role).to be_instance_of(GoodData::ProjectRole)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#users' do
|
100
|
+
it 'Returns array of GoodData::Users' do
|
101
|
+
pending 'Investigate which credentials to use'
|
102
|
+
|
103
|
+
project = GoodData::Project[ProjectHelper::PROJECT_ID]
|
104
|
+
|
105
|
+
invitations = project.invitations
|
106
|
+
invitations.should_not be_nil
|
107
|
+
expect(invitations).to be_instance_of(Array)
|
108
|
+
|
109
|
+
users = project.users
|
110
|
+
expect(users).to be_instance_of(Array)
|
111
|
+
|
112
|
+
users.each do |user|
|
113
|
+
expect(user).to be_instance_of(GoodData::User)
|
114
|
+
|
115
|
+
roles = user.roles
|
116
|
+
roles.should_not be_nil
|
117
|
+
expect(roles).to be_instance_of(Array)
|
118
|
+
|
119
|
+
roles.each do |role|
|
120
|
+
expect(role).to be_instance_of(GoodData::ProjectRole)
|
121
|
+
end
|
122
|
+
|
123
|
+
permissions = user.permissions
|
124
|
+
permissions.should_not be_nil
|
125
|
+
permissions.should_not be_nil
|
126
|
+
expect(permissions).to be_instance_of(Hash)
|
127
|
+
|
128
|
+
# invitations = user.invitations
|
129
|
+
# invitations.should_not be_nil
|
130
|
+
|
131
|
+
if(user.email == 'tomas.korcak@gooddata.com')
|
132
|
+
projects = user.projects
|
133
|
+
projects.should_not be_nil
|
134
|
+
expect(projects).to be_instance_of(Array)
|
135
|
+
|
136
|
+
projects.each do |project|
|
137
|
+
expect(project).to be_instance_of(GoodData::Project)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|