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
@@ -2,48 +2,44 @@ require 'gooddata'
|
|
2
2
|
|
3
3
|
describe "Variables implementation", :constraint => 'slow' do
|
4
4
|
before(:all) do
|
5
|
-
@spec = JSON.parse(File.read("./spec/data/m_n_model
|
5
|
+
@spec = JSON.parse(File.read("./spec/data/blueprints/m_n_model.json"), :symbolize_names => true)
|
6
6
|
@client = ConnectionHelper::create_default_connection
|
7
|
-
@
|
7
|
+
@blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
8
|
+
@project = @client.create_project_from_blueprint(@blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
8
9
|
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
10
|
+
@label = @project.attributes('attr.permission.id').label_by_name('label.permission.id.email')
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
@blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
13
|
-
commits_data = [
|
14
|
-
['commit_id', 'lines_changed', 'user_id'],
|
12
|
+
data = [
|
13
|
+
['label.commits.id', 'fact.commits.lines_changed', 'dataset.users'],
|
15
14
|
[1, 1, 1],
|
16
15
|
[2, 3, 2],
|
17
16
|
[3, 5, 3]]
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
["user_id", "email"],
|
17
|
+
@project.upload(data, @blueprint, 'dataset.commits')
|
18
|
+
|
19
|
+
data = [
|
20
|
+
["label.users.id", "label.users.id.email"],
|
23
21
|
[1, "tomas@gooddata.com"],
|
24
22
|
[2, "petr@gooddata.com"],
|
25
23
|
[3, "jirka@gooddata.com"]]
|
26
|
-
|
24
|
+
@project.upload(data, @blueprint, 'dataset.users')
|
27
25
|
|
28
|
-
|
29
|
-
["
|
26
|
+
data = [
|
27
|
+
["label.permission.id", "label.permission.id.email"],
|
30
28
|
[1, "tomas@gooddata.com"],
|
31
29
|
[2, "petr@gooddata.com"],
|
32
30
|
[3, "jirka@gooddata.com"]]
|
33
|
-
|
34
|
-
# blueprint.find_dataset('devs').upload(devs_data)
|
31
|
+
@project.upload(data, @blueprint, 'dataset.permission_users')
|
35
32
|
|
36
|
-
|
37
|
-
['
|
33
|
+
data = [
|
34
|
+
['label.visibility.id', 'dataset.permission_users', 'dataset.commits'],
|
38
35
|
[1, 1, 1],
|
39
|
-
# [2, 1, 2],
|
40
36
|
[3, 1, 3]]
|
41
|
-
|
37
|
+
@project.upload(data, @blueprint, 'dataset.visibility')
|
42
38
|
|
43
39
|
@variable = @project.create_variable(title: 'uaaa', attribute: @label.attribute).save
|
44
40
|
|
45
|
-
@attr1 =
|
46
|
-
@attr2 =
|
41
|
+
@attr1 = @project.attributes('attr.visibility.id')
|
42
|
+
@attr2 = @project.attributes('attr.commits.id')
|
47
43
|
|
48
44
|
@filters = [
|
49
45
|
{
|
@@ -70,21 +66,21 @@ describe "Variables implementation", :constraint => 'slow' do
|
|
70
66
|
end
|
71
67
|
|
72
68
|
it "should create an over to filter transparently" do
|
73
|
-
metric = @project.create_metric("SELECT SUM(#\"Lines Changed\")", :title => 'x')
|
69
|
+
metric = @project.create_metric("SELECT SUM(#\"Fact.Commits.Lines Changed\")", :title => 'x')
|
74
70
|
expect(metric.execute).to eq 9
|
75
71
|
@project.add_data_permissions(@filters)
|
76
72
|
expect(metric.execute).to eq 6
|
77
73
|
|
78
|
-
r = @project.compute_report(left: [metric], top:
|
74
|
+
r = @project.compute_report(left: [metric], top: ['label.users.id.email'])
|
79
75
|
expect(r.include_column?(['tomas@gooddata.com', 1])).to eq true
|
80
76
|
expect(r.include_column?(['jirka@gooddata.com', 5])).to eq true
|
81
77
|
expect(r.include_column?(['petr@gooddata.com', 3])).to eq false
|
82
78
|
|
83
|
-
|
84
|
-
|
79
|
+
data = [['label.visibility.id', 'dataset.permission_users', 'dataset.commits'], [1, 1, 1]]
|
80
|
+
@project.upload(data, @blueprint, 'dataset.visibility')
|
85
81
|
|
86
82
|
expect(metric.execute).to eq 1
|
87
|
-
r = @project.compute_report(left: [metric], top:
|
83
|
+
r = @project.compute_report(left: [metric], top: ['label.users.id.email'])
|
88
84
|
expect(r.include_column?(['tomas@gooddata.com', 1])).to eq true
|
89
85
|
expect(r.include_column?(['jirka@gooddata.com', 5])).to eq false
|
90
86
|
expect(r.include_column?(['petr@gooddata.com', 3])).to eq false
|
@@ -4,10 +4,10 @@ describe "Object export between projects", :constraint => 'slow' do
|
|
4
4
|
before(:all) do
|
5
5
|
@client = ConnectionHelper.create_default_connection
|
6
6
|
|
7
|
-
spec = MultiJson.load(File.read("./spec/data/test_project_model_spec.json"), :symbolize_keys => true)
|
8
|
-
|
9
|
-
@source_project = @client.create_project_from_blueprint(spec,
|
10
|
-
@target_project = @client.create_project_from_blueprint(spec,
|
7
|
+
spec = MultiJson.load(File.read("./spec/data/blueprints/test_project_model_spec.json"), :symbolize_keys => true)
|
8
|
+
|
9
|
+
@source_project = @client.create_project_from_blueprint(spec, token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
10
|
+
@target_project = @client.create_project_from_blueprint(spec, token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:all) do
|
@@ -6,7 +6,7 @@ require 'gooddata'
|
|
6
6
|
describe GoodData::Project, :constraint => 'slow' do
|
7
7
|
before(:all) do
|
8
8
|
@client = ConnectionHelper::create_default_connection
|
9
|
-
@project = @client.create_project(title: ProjectHelper::PROJECT_TITLE, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
|
9
|
+
@project = @client.create_project(title: ProjectHelper::PROJECT_TITLE, auth_token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
10
10
|
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
11
11
|
end
|
12
12
|
|
@@ -7,7 +7,7 @@ describe GoodData do
|
|
7
7
|
before(:each) do
|
8
8
|
@client = ConnectionHelper.create_default_connection
|
9
9
|
# @project = ProjectHelper.get_default_project(:client => @client)
|
10
|
-
@project = @client.create_project(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
|
10
|
+
@project = @client.create_project(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:each) do
|
@@ -2,32 +2,27 @@ require 'gooddata'
|
|
2
2
|
|
3
3
|
describe "User filters implementation", :constraint => 'slow' do
|
4
4
|
before(:all) do
|
5
|
-
@spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
|
5
|
+
@spec = JSON.parse(File.read("./spec/data/blueprints/test_project_model_spec.json"), :symbolize_names => true)
|
6
6
|
@client = ConnectionHelper::create_default_connection
|
7
|
-
|
7
|
+
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
8
|
+
@project = @client.create_project_from_blueprint(blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
8
9
|
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
9
10
|
|
10
|
-
GoodData.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
[2, "petr@gooddata.com"],
|
26
|
-
[3, "jirka@gooddata.com"]]
|
27
|
-
GoodData::Model.upload_data(devs_data, blueprint, 'devs', :client => @client, :project => @project)
|
28
|
-
# blueprint.find_dataset('devs').upload(devs_data)
|
29
|
-
end
|
30
|
-
|
11
|
+
@label = GoodData::Attribute.find_first_by_title('Dev', client: @client, project: @project).label_by_name('email')
|
12
|
+
|
13
|
+
commits_data = [
|
14
|
+
["lines_changed","committed_on","dev_id","repo_id"],
|
15
|
+
[1,"01/01/2014",1,1],
|
16
|
+
[3,"01/02/2014",2,2],
|
17
|
+
[5,"05/02/2014",3,1]]
|
18
|
+
@project.upload(commits_data, blueprint, 'dataset.commits')
|
19
|
+
|
20
|
+
devs_data = [
|
21
|
+
["dev_id", "email"],
|
22
|
+
[1, "tomas@gooddata.com"],
|
23
|
+
[2, "petr@gooddata.com"],
|
24
|
+
[3, "jirka@gooddata.com"]]
|
25
|
+
@project.upload(devs_data, blueprint, 'dataset.devs')
|
31
26
|
end
|
32
27
|
|
33
28
|
after(:all) do
|
@@ -124,7 +119,7 @@ describe "User filters implementation", :constraint => 'slow' do
|
|
124
119
|
perms = @project.data_permissions
|
125
120
|
pretty = perms.pmap {|f| [f.related.login, f.pretty_expression]}
|
126
121
|
expect(perms.first.related).to eq @client.user
|
127
|
-
expect(pretty).to eq [[
|
122
|
+
expect(pretty).to eq [[ConnectionHelper::DEFAULT_USERNAME, "[Dev] IN ([tomas@gooddata.com])"]]
|
128
123
|
end
|
129
124
|
|
130
125
|
it "sets up mandatory users based on the state given as an end state by default." do
|
@@ -2,29 +2,27 @@ require 'gooddata'
|
|
2
2
|
|
3
3
|
describe "Variables implementation", :constraint => 'slow' do
|
4
4
|
before(:all) do
|
5
|
-
@spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
|
5
|
+
@spec = JSON.parse(File.read("./spec/data/blueprints/test_project_model_spec.json"), :symbolize_names => true)
|
6
6
|
@client = ConnectionHelper::create_default_connection
|
7
|
-
|
7
|
+
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
8
|
+
@project = @client.create_project_from_blueprint(blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
|
8
9
|
@domain = @client.domain(ConnectionHelper::DEFAULT_DOMAIN)
|
9
10
|
|
10
11
|
@label = GoodData::Attribute.find_first_by_title('Dev', client: @client, project: @project).label_by_name('email')
|
11
|
-
|
12
|
-
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
12
|
+
|
13
13
|
commits_data = [
|
14
14
|
["lines_changed","committed_on","dev_id","repo_id"],
|
15
15
|
[1,"01/01/2014",1,1],
|
16
16
|
[3,"01/02/2014",2,2],
|
17
17
|
[5,"05/02/2014",3,1]]
|
18
|
-
|
19
|
-
# blueprint.find_dataset('commits').upload(commits_data)
|
18
|
+
@project.upload(commits_data, blueprint, 'dataset.commits')
|
20
19
|
|
21
20
|
devs_data = [
|
22
21
|
["dev_id", "email"],
|
23
22
|
[1, "tomas@gooddata.com"],
|
24
23
|
[2, "petr@gooddata.com"],
|
25
24
|
[3, "jirka@gooddata.com"]]
|
26
|
-
|
27
|
-
# blueprint.find_dataset('devs').upload(devs_data)
|
25
|
+
@project.upload(devs_data, blueprint, 'dataset.devs')
|
28
26
|
|
29
27
|
@variable = @project.create_variable(title: 'uaaa', attribute: @label.attribute).save
|
30
28
|
|
@@ -122,7 +120,7 @@ describe "Variables implementation", :constraint => 'slow' do
|
|
122
120
|
perms = @variable.user_values
|
123
121
|
pretty = perms.pmap {|f| [f.related.login, f.pretty_expression]}
|
124
122
|
expect(perms.first.related).to eq @client.user
|
125
|
-
expect(pretty).to eq [[
|
123
|
+
expect(pretty).to eq [[ConnectionHelper::DEFAULT_USERNAME, "[Dev] IN ([tomas@gooddata.com])"]]
|
126
124
|
end
|
127
125
|
|
128
126
|
it "sets up mandatory users based on the state given as an end state by default." do
|
@@ -18,7 +18,7 @@ describe GoodData::Rest::Connection, :constraint => 'slow' do
|
|
18
18
|
regular_client = ConnectionHelper::create_default_connection
|
19
19
|
sst = regular_client.connection.sst_token
|
20
20
|
|
21
|
-
sst_client = GoodData.connect(sst_token: sst)
|
21
|
+
sst_client = GoodData.connect(sst_token: sst, verify_ssl: false)
|
22
22
|
expect(sst_client.projects.count).to be > 0
|
23
23
|
sst_client.disconnect
|
24
24
|
|
data/spec/spec_helper.rb
CHANGED
@@ -5,16 +5,24 @@ require 'pmap'
|
|
5
5
|
require 'rspec'
|
6
6
|
require 'coveralls'
|
7
7
|
require 'pathname'
|
8
|
+
require 'webmock/rspec'
|
8
9
|
|
10
|
+
WebMock.disable!
|
9
11
|
Coveralls.wear_merged!
|
10
12
|
|
11
13
|
# Automagically include all helpers/*_helper.rb
|
12
14
|
|
15
|
+
require_relative 'environment/environment'
|
16
|
+
|
17
|
+
GoodData::Environment.load
|
18
|
+
|
13
19
|
base = Pathname(__FILE__).dirname.expand_path
|
14
20
|
Dir.glob(base + 'helpers/*_helper.rb').each do |file|
|
15
21
|
require file
|
16
22
|
end
|
17
23
|
|
24
|
+
include GoodData::Helpers
|
25
|
+
|
18
26
|
RSpec.configure do |config|
|
19
27
|
config.include BlueprintHelper
|
20
28
|
config.include CliHelper
|
@@ -28,7 +36,7 @@ RSpec.configure do |config|
|
|
28
36
|
|
29
37
|
config.filter_run_excluding :broken => true
|
30
38
|
|
31
|
-
config.fail_fast =
|
39
|
+
config.fail_fast = false
|
32
40
|
|
33
41
|
config.before(:all) do
|
34
42
|
# TODO: Move this to some method.
|
@@ -49,6 +57,7 @@ RSpec.configure do |config|
|
|
49
57
|
|
50
58
|
config.before(:suite) do
|
51
59
|
# TODO: Setup test project
|
60
|
+
GoodData.logging_on
|
52
61
|
end
|
53
62
|
|
54
63
|
config.after(:suite) do
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata/bricks/brick'
|
4
|
+
require 'gooddata/bricks/bricks'
|
5
|
+
require 'gooddata/bricks/middleware/aws_middleware'
|
6
|
+
|
7
|
+
describe GoodData::Bricks::AWSMiddleware do
|
8
|
+
it 'should do nothing if the key "aws_client" is not there at all' do
|
9
|
+
middleware = GoodData::Bricks::AWSMiddleware.new(app: lambda {|params| 'Doing nothing'})
|
10
|
+
middleware.call({})
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should fail gracefully if value aws_client param not present even though the key is' do
|
14
|
+
middleware = GoodData::Bricks::AWSMiddleware.new(app: lambda {|params| 'Doing nothing'})
|
15
|
+
expect do
|
16
|
+
middleware.call('aws_client' => nil)
|
17
|
+
end.to raise_exception 'Unable to connect to AWS. Parameter "aws_client" seems to be empty'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should fail gracefully if value secret_access_key is missing' do
|
21
|
+
middleware = GoodData::Bricks::AWSMiddleware.new(app: lambda {|params| 'Doing nothing'})
|
22
|
+
expect do
|
23
|
+
middleware.call('aws_client' => {
|
24
|
+
'access_key_id' => 'something'
|
25
|
+
})
|
26
|
+
end.to raise_exception 'Unable to connect to AWS. Parameter "secret_access_key" is missing'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should fail gracefully if value access_key_id is missing' do
|
30
|
+
middleware = GoodData::Bricks::AWSMiddleware.new(app: lambda {|params| 'Doing nothing'})
|
31
|
+
expect do
|
32
|
+
middleware.call('aws_client' => {
|
33
|
+
'secret_access_key' => 'something'
|
34
|
+
})
|
35
|
+
end.to raise_exception 'Unable to connect to AWS. Parameter "access_key_id" is missing'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should preapre aws middleware for aws_client param" do
|
39
|
+
middleware = GoodData::Bricks::AWSMiddleware.new(app: lambda do |params|
|
40
|
+
expect(params['aws_client']['s3_client']).to be_kind_of(AWS::S3)
|
41
|
+
end)
|
42
|
+
middleware.call('aws_client' => {
|
43
|
+
'secret_access_key' => 'something',
|
44
|
+
'access_key_id' => 'something'
|
45
|
+
})
|
46
|
+
end
|
47
|
+
end
|
@@ -20,7 +20,7 @@ describe GoodData::Rest::Connection do
|
|
20
20
|
|
21
21
|
describe '#connect' do
|
22
22
|
it "Connects using username and password" do
|
23
|
-
c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD)
|
23
|
+
c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD, :verify_ssl => 0)
|
24
24
|
c.should be_a(GoodData::Rest::Client)
|
25
25
|
c.disconnect
|
26
26
|
end
|
@@ -28,7 +28,7 @@ describe GoodData::Rest::Connection do
|
|
28
28
|
|
29
29
|
describe '#disconnect' do
|
30
30
|
it "Connects using username and password" do
|
31
|
-
c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD)
|
31
|
+
c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::DEFAULT_PASSWORD, :verify_ssl => 0)
|
32
32
|
c.disconnect
|
33
33
|
end
|
34
34
|
end
|
@@ -7,19 +7,19 @@ require 'logger'
|
|
7
7
|
class TestLogger < Logger
|
8
8
|
attr_reader :last_message
|
9
9
|
def debug(*args)
|
10
|
-
@last_message = args[0]
|
10
|
+
@last_message = args[0] if level == Logger::DEBUG
|
11
11
|
super(*args)
|
12
12
|
end
|
13
13
|
def info(*args)
|
14
|
-
@last_message = args[0]
|
14
|
+
@last_message = args[0] if level == Logger::INFO
|
15
15
|
super(*args)
|
16
16
|
end
|
17
17
|
def warn(*args)
|
18
|
-
@last_message = args[0]
|
18
|
+
@last_message = args[0] if level == Logger::WARN
|
19
19
|
super(*args)
|
20
20
|
end
|
21
21
|
def error(*args)
|
22
|
-
@last_message = args[0]
|
22
|
+
@last_message = args[0] if level == Logger::ERROR
|
23
23
|
super(*args)
|
24
24
|
end
|
25
25
|
end
|
@@ -80,6 +80,14 @@ describe 'GoodData - logging' do
|
|
80
80
|
id = test_request_id_logging
|
81
81
|
expect(GoodData.logger.last_message).to include(id)
|
82
82
|
end
|
83
|
+
it 'client logs when given custom message' do
|
84
|
+
GoodData.logger = TestLogger.new(STDOUT)
|
85
|
+
GoodData.logger.level = Logger::INFO
|
86
|
+
c = ConnectionHelper.create_default_connection
|
87
|
+
message = "Getting all projects."
|
88
|
+
c.get('/gdc/md', :info_message => message)
|
89
|
+
expect(GoodData.logger.last_message).to include(message)
|
90
|
+
end
|
83
91
|
end
|
84
92
|
|
85
93
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata/helpers/data_helper'
|
4
|
+
|
5
|
+
describe GoodData::Helpers::DataSource do
|
6
|
+
before :each do
|
7
|
+
@s3_client = double('s3_client')
|
8
|
+
@buckets = double('buckets')
|
9
|
+
@bucket = double('bucket')
|
10
|
+
@objects = double('objects')
|
11
|
+
|
12
|
+
allow(@s3_client).to receive(:buckets) { @buckets }
|
13
|
+
allow(@buckets).to receive(:[]) { @bucket }
|
14
|
+
allow(@bucket).to receive(:objects) { @objects }
|
15
|
+
allow(@objects).to receive(:[]) { StringIO.new('aaa') }
|
16
|
+
|
17
|
+
@ds = GoodData::Helpers::DataSource.new({
|
18
|
+
type: :s3,
|
19
|
+
bucket: 'some_bucket',
|
20
|
+
key: 'some_key'
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be able to handle AWS' do
|
25
|
+
expect(@ds.realized?).to be_falsey
|
26
|
+
params = { 'aws_client' => { 's3_client' => @s3_client } }
|
27
|
+
expect(@ds.realize(params)).to eq '2bdc6c8a02b2bd1d7997cf17f0848ecfcbceba25ca184e2676f19c054db7139b'
|
28
|
+
expect(@ds.realized?).to be_truthy
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should gracefully handle missing aws client' do
|
32
|
+
expect do
|
33
|
+
@ds.realize({
|
34
|
+
'aws_client' => nil
|
35
|
+
})
|
36
|
+
end.to raise_exception "AWS client not present. Perhaps S3Middleware is missing in the brick definition?"
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should gracefully handle missing data source params - bucket' do
|
40
|
+
ds = GoodData::Helpers::DataSource.new({
|
41
|
+
type: :s3,
|
42
|
+
key: 'some_key'
|
43
|
+
})
|
44
|
+
params = { 'aws_client' => { 's3_client' => @s3_client } }
|
45
|
+
expect do
|
46
|
+
ds.realize(params)
|
47
|
+
end.to raise_exception 'Key "bucket" is missing in S3 datasource'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should gracefully handle missing data source params - key' do
|
51
|
+
ds = GoodData::Helpers::DataSource.new({
|
52
|
+
type: :s3,
|
53
|
+
bucket: 'some_bucket'
|
54
|
+
})
|
55
|
+
params = { 'aws_client' => { 's3_client' => @s3_client } }
|
56
|
+
expect do
|
57
|
+
ds.realize(params)
|
58
|
+
end.to raise_exception 'Key "key" is missing in S3 datasource'
|
59
|
+
end
|
60
|
+
end
|