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,25 +1,21 @@
|
|
1
|
-
GoodData::Model::ProjectBuilder.create("
|
1
|
+
GoodData::Model::ProjectBuilder.create("Test project") do |p|
|
2
2
|
p.add_date_dimension("committed_on")
|
3
3
|
|
4
4
|
p.add_dataset("repos") do |d|
|
5
|
-
d.add_anchor("
|
6
|
-
d.add_label("name", :reference => "
|
5
|
+
d.add_anchor("repo_id")
|
6
|
+
d.add_label("name", :reference => "repo_id")
|
7
7
|
end
|
8
8
|
|
9
9
|
p.add_dataset("devs") do |d|
|
10
|
-
d.add_anchor("
|
11
|
-
d.add_label("email", :reference => "
|
10
|
+
d.add_anchor("dev_id")
|
11
|
+
d.add_label("email", :reference => "dev_id")
|
12
12
|
end
|
13
13
|
|
14
14
|
p.add_dataset("commits") do |d|
|
15
15
|
d.add_fact("lines_changed")
|
16
16
|
d.add_date("committed_on", :dataset => "committed_on")
|
17
|
-
d.add_reference("dev_id", :dataset => 'devs', :reference => '
|
18
|
-
d.add_reference("repo_id", :dataset => 'repos', :reference => '
|
17
|
+
d.add_reference("dev_id", :dataset => 'devs', :reference => 'dev_id')
|
18
|
+
d.add_reference("repo_id", :dataset => 'repos', :reference => 'repo_id')
|
19
19
|
end
|
20
20
|
|
21
|
-
p.upload("data/devs.csv", :dataset => 'devs')
|
22
|
-
p.upload("data/repos.csv", :dataset => 'repos')
|
23
|
-
p.upload("data/commits.csv", :dataset => 'commits')
|
24
|
-
|
25
21
|
end
|
data/spec/bricks/bricks_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
{
|
2
|
-
"title": "Dev Week test",
|
2
|
+
"title": "RubyGem Dev Week test",
|
3
3
|
"datasets": [
|
4
4
|
{
|
5
5
|
"name": "repos",
|
6
6
|
"columns": [
|
7
7
|
{
|
8
8
|
"type": "anchor",
|
9
|
-
"name": "
|
9
|
+
"name": "repo_id"
|
10
10
|
},
|
11
11
|
{
|
12
12
|
"type": "label",
|
13
13
|
"name": "name",
|
14
|
-
"reference": "
|
14
|
+
"reference": "repo_id"
|
15
15
|
},
|
16
16
|
{
|
17
17
|
"type": "attribute",
|
@@ -24,12 +24,12 @@
|
|
24
24
|
"columns": [
|
25
25
|
{
|
26
26
|
"type": "anchor",
|
27
|
-
"name": "
|
27
|
+
"name": "dev_id"
|
28
28
|
},
|
29
29
|
{
|
30
30
|
"type": "label",
|
31
31
|
"name": "email",
|
32
|
-
"reference": "
|
32
|
+
"reference": "dev_id"
|
33
33
|
}
|
34
34
|
]
|
35
35
|
},
|
@@ -49,37 +49,17 @@
|
|
49
49
|
"type": "reference",
|
50
50
|
"name": "dev_id",
|
51
51
|
"dataset": "devs",
|
52
|
-
"reference": "
|
52
|
+
"reference": "dev_id"
|
53
53
|
},
|
54
54
|
{
|
55
55
|
"type": "reference",
|
56
56
|
"name": "repo_id",
|
57
57
|
"dataset": "repos",
|
58
|
-
"reference": "
|
58
|
+
"reference": "repo_id"
|
59
59
|
}
|
60
60
|
]
|
61
61
|
}
|
62
62
|
],
|
63
|
-
"uploads": [
|
64
|
-
{
|
65
|
-
"source":
|
66
|
-
[["lines_changed","committed_on","dev_id","repo_id"],
|
67
|
-
[1,"01/01/2014",1,1],
|
68
|
-
[3,"01/02/2014",2,2],
|
69
|
-
[5,"05/02/2014",3,1]],
|
70
|
-
"mode": "FULL",
|
71
|
-
"dataset": "commits"
|
72
|
-
},
|
73
|
-
{
|
74
|
-
"source":
|
75
|
-
[["id", "email"],
|
76
|
-
[1, "tomas@gooddata.com"],
|
77
|
-
[2, "petr@gooddata.com"],
|
78
|
-
[3, "jirka@gooddata.com"]],
|
79
|
-
"mode": "FULL",
|
80
|
-
"dataset": "devs"
|
81
|
-
}
|
82
|
-
],
|
83
63
|
"date_dimensions": [
|
84
64
|
{
|
85
65
|
"urn": null,
|
data/spec/helpers/cli_helper.rb
CHANGED
@@ -2,11 +2,24 @@ require 'gooddata/connection'
|
|
2
2
|
|
3
3
|
module ConnectionHelper
|
4
4
|
GD_PROJECT_TOKEN = ENV["GD_PROJECT_TOKEN"]
|
5
|
+
|
5
6
|
DEFAULT_USERNAME = "svarovsky+gem_tester@gooddata.com"
|
6
7
|
DEFAULT_PASSWORD = "jindrisska"
|
8
|
+
DEFAULT_DOMAIN = 'gooddata-tomas-svarovsky'
|
7
9
|
|
10
|
+
# Creates connection using default credentials or supplied one
|
11
|
+
#
|
12
|
+
# @param [String] username Optional username
|
13
|
+
# @param [String] password Optional password
|
8
14
|
def self.create_default_connection(username = DEFAULT_USERNAME, password = DEFAULT_PASSWORD)
|
9
15
|
GoodData::connect(username, password)
|
10
16
|
end
|
11
17
|
|
12
|
-
|
18
|
+
# Creates connection using environment varibles GD_GEM_USER and GD_GEM_PASSWORD
|
19
|
+
def self.create_private_connection
|
20
|
+
username = ENV['GD_GEM_USER'] || DEFAULT_USERNAME
|
21
|
+
password = ENV['GD_GEM_PASSWORD'] || DEFAULT_PASSWORD
|
22
|
+
|
23
|
+
GoodData::connect(username, password)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Global requires
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
# Local requires
|
7
|
+
require 'gooddata/models/models'
|
8
|
+
|
9
|
+
module ProjectHelper
|
10
|
+
PROJECT_ID = 'tk6192gsnav58crp6o1ahsmtuniq8khb'
|
11
|
+
PROJECT_URL = "/gdc/projects/#{PROJECT_ID}"
|
12
|
+
|
13
|
+
def self.get_default_project
|
14
|
+
GoodData::Project[PROJECT_ID]
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'gooddata/models/metadata/schema'
|
4
|
+
|
5
|
+
module SchemaHelper
|
6
|
+
COLUMNS = [
|
7
|
+
{:type => :anchor, :name => 'cp', 'title' => 'CP', 'folder' => 'test'},
|
8
|
+
{:type => :attribute, :name => 'a1', 'title' => 'A1', 'folder' => 'test'},
|
9
|
+
{:type => :attribute, :name => 'a2', 'title' => 'A2', 'folder' => 'test'},
|
10
|
+
{:type => :date, :name => 'event', 'title' => 'Event', 'folder' => 'test'},
|
11
|
+
{:type => :fact, :name => 'f1', 'title' => 'F1', 'folder' => 'test'},
|
12
|
+
{:type => :fact, :name => 'f2', 'title' => 'F2', 'folder' => 'test'},
|
13
|
+
]
|
14
|
+
|
15
|
+
SCHEMA = GoodData::Model::Schema.new :name => 'test', :title => 'test', :columns => COLUMNS
|
16
|
+
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'gooddata'
|
2
|
-
require 'gooddata/commands/
|
3
|
-
require 'pry'
|
2
|
+
require 'gooddata/commands/project'
|
4
3
|
|
5
|
-
describe GoodData::Command::
|
4
|
+
describe GoodData::Command::Project, :constraint => 'slow' do
|
6
5
|
before(:all) do
|
7
6
|
@blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/test_project_model_spec.json")
|
8
7
|
@module_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/additional_dataset_module.json")
|
9
8
|
|
10
9
|
ConnectionHelper::create_default_connection
|
11
|
-
@project = GoodData::Command::
|
10
|
+
@project = GoodData::Command::Project.build({:spec => @blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN})
|
12
11
|
end
|
13
12
|
|
14
13
|
after(:all) do
|
@@ -18,8 +17,9 @@ describe GoodData::Command::Projects, :constraint => 'slow' do
|
|
18
17
|
it "should update the project" do
|
19
18
|
@blueprint.merge!(@module_blueprint)
|
20
19
|
GoodData.with_project(@project) do |p|
|
21
|
-
|
20
|
+
p.datasets.count.should == 4
|
21
|
+
GoodData::Command::Project.update({:spec => @blueprint, :project => p})
|
22
|
+
p.datasets.count.should == 5
|
22
23
|
end
|
23
24
|
end
|
24
|
-
|
25
|
-
end
|
25
|
+
end
|
@@ -6,7 +6,7 @@ describe "Spin a project from template", :constraint => 'slow' do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should spin a project from a template that does not exist. It should throw an error" do
|
9
|
-
expect{GoodData::Project.create(:title => "Test project", :template => "/some/nonexisting/
|
9
|
+
expect{GoodData::Project.create(:title => "Test project", :template => "/some/nonexisting/template/uri", :auth_token => ConnectionHelper::GD_PROJECT_TOKEN)}.to raise_error
|
10
10
|
end
|
11
11
|
|
12
|
-
end
|
12
|
+
end
|
@@ -1,17 +1,49 @@
|
|
1
1
|
require 'gooddata'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "Ful project implementation", :constraint => 'slow' do
|
4
4
|
before(:all) do
|
5
|
-
spec =
|
5
|
+
@spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
|
6
6
|
ConnectionHelper::create_default_connection
|
7
|
-
|
8
|
-
@project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
7
|
+
@project = GoodData::Model::ProjectCreator.migrate({:spec => @spec, :token => ConnectionHelper::GD_PROJECT_TOKEN})
|
9
8
|
end
|
10
9
|
|
11
10
|
after(:all) do
|
12
11
|
@project.delete unless @project.nil?
|
13
12
|
end
|
14
13
|
|
14
|
+
it "should contain datasets" do
|
15
|
+
GoodData.with_project(@project) do |p|
|
16
|
+
p.datasets.count.should == 4
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should compute an empty metric" do
|
21
|
+
GoodData.with_project(@project) do |p|
|
22
|
+
f = GoodData::Fact.find_first_by_title('Lines changed')
|
23
|
+
metric = GoodData::Metric.xcreate("SELECT SUM(#\"#{f.title}\")")
|
24
|
+
metric.execute.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should load the data" do
|
29
|
+
GoodData.with_project(@project) do |p|
|
30
|
+
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
31
|
+
commits_data = [
|
32
|
+
["lines_changed","committed_on","dev_id","repo_id"],
|
33
|
+
[1,"01/01/2014",1,1],
|
34
|
+
[3,"01/02/2014",2,2],
|
35
|
+
[5,"05/02/2014",3,1]]
|
36
|
+
blueprint.find_dataset('commits').upload(commits_data)
|
37
|
+
|
38
|
+
devs_data = [
|
39
|
+
["dev_id", "email"],
|
40
|
+
[1, "tomas@gooddata.com"],
|
41
|
+
[2, "petr@gooddata.com"],
|
42
|
+
[3, "jirka@gooddata.com"]]
|
43
|
+
blueprint.find_dataset('devs').upload(devs_data)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
15
47
|
it "should compute a metric" do
|
16
48
|
GoodData.with_project(@project) do |p|
|
17
49
|
f = GoodData::Fact.find_first_by_title('Lines changed')
|
@@ -36,10 +68,63 @@ describe "Spin a project", :constraint => 'slow' do
|
|
36
68
|
f = GoodData::Fact.find_first_by_title('Lines changed')
|
37
69
|
metric = GoodData::Metric.xcreate(:title => "My metric", :expression => "SELECT SUM(#\"#{f.title}\")")
|
38
70
|
metric.save
|
39
|
-
|
40
|
-
result = GoodData::ReportDefinition.execute(:title => "My report", :top => [metric], :left => ['label.devs.email'])
|
71
|
+
result = GoodData::ReportDefinition.execute(:title => "My report", :top => [metric], :left => ['label.devs.dev_id.email'])
|
41
72
|
result[1][1].should == 3
|
42
73
|
result.include_row?(["jirka@gooddata.com", 5]).should == true
|
74
|
+
|
75
|
+
result2 = GoodData::ReportDefinition.create(:title => "My report", :top => [metric], :left => ['label.devs.dev_id.email']).execute
|
76
|
+
result2[1][1].should == 3
|
77
|
+
result2.include_row?(["jirka@gooddata.com", 5]).should == true
|
78
|
+
result2.should == result
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should exercise the object relations and getting them in various ways" do
|
83
|
+
GoodData.with_project(@project) do |p|
|
84
|
+
# Find a metric by name
|
85
|
+
metric = GoodData::Metric.find_first_by_title('My metric')
|
86
|
+
|
87
|
+
# grab fact in several different ways
|
88
|
+
fact1 = GoodData::Fact.find_first_by_title('Lines changed')
|
89
|
+
fact2 = GoodData::Fact[fact1.identifier]
|
90
|
+
fact3 = GoodData::Fact[fact2.obj_id]
|
91
|
+
fact4 = GoodData::Fact[fact3.uri]
|
92
|
+
fact5 = GoodData::Fact.new(fact4)
|
93
|
+
|
94
|
+
# All should be the same
|
95
|
+
fact1.should == fact2
|
96
|
+
fact1.should == fact2
|
97
|
+
fact1.should == fact3
|
98
|
+
fact1.should == fact4
|
99
|
+
fact1.should == fact5
|
100
|
+
|
101
|
+
fact3.title = "Somewhat changed title"
|
102
|
+
fact1.should_not == fact3
|
103
|
+
|
104
|
+
metric.using
|
105
|
+
metric.using('fact').count.should == 1
|
106
|
+
|
107
|
+
fact1.used_by
|
108
|
+
fact1.used_by('metric').count.should == 1
|
109
|
+
|
110
|
+
metric.using?(fact1).should == true
|
111
|
+
fact1.using?(metric).should == false
|
112
|
+
|
113
|
+
metric.used_by?(fact1).should == false
|
114
|
+
fact1.used_by?(metric).should == true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should try setting and getting by tags" do
|
119
|
+
GoodData.with_project(@project) do |p|
|
120
|
+
fact = GoodData::Fact.find_first_by_title('Lines changed')
|
121
|
+
fact.tags.should be_empty
|
122
|
+
|
123
|
+
fact.tags = "tag1,tag2,tag3"
|
124
|
+
fact.save
|
125
|
+
|
126
|
+
tagged_facts = GoodData::Fact.find_by_tag('tag3')
|
127
|
+
tagged_facts.count.should == 1
|
43
128
|
end
|
44
129
|
end
|
45
130
|
|
@@ -66,4 +151,72 @@ describe "Spin a project", :constraint => 'slow' do
|
|
66
151
|
end
|
67
152
|
end
|
68
153
|
|
69
|
-
|
154
|
+
it "should load the data" do
|
155
|
+
GoodData.with_project(@project) do |p|
|
156
|
+
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
157
|
+
devs_data = [
|
158
|
+
["dev_id", "email"],
|
159
|
+
[4, "josh@gooddata.com"]]
|
160
|
+
blueprint.find_dataset('devs').upload(devs_data, :load => 'INCREMENTAL')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should have more users" do
|
165
|
+
GoodData.with_project(@project) do |p|
|
166
|
+
GoodData::Attribute['attr.devs.dev_id'].create_metric.execute.should == 4
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should tell you whether metric contains a certain attribute" do
|
171
|
+
GoodData.with_project(@project) do |p|
|
172
|
+
attribute = GoodData::Attribute['attr.devs.dev_id']
|
173
|
+
repo_attribute = GoodData::Attribute['attr.repos.repo_id']
|
174
|
+
metric = attribute.create_metric(:title => "My test metric")
|
175
|
+
metric.save
|
176
|
+
metric.execute.should == 4
|
177
|
+
|
178
|
+
metric.contain?(attribute).should == true
|
179
|
+
metric.contain?(repo_attribute).should == false
|
180
|
+
|
181
|
+
metric.replace(attribute, repo_attribute)
|
182
|
+
metric.save
|
183
|
+
metric.execute.should_not == 4
|
184
|
+
|
185
|
+
l = attribute.primary_label
|
186
|
+
value = l.values.first[:value]
|
187
|
+
l.find_element_value(l.find_value_uri(value)).should == value
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should be able to tell you if a value is contained in a metric" do
|
192
|
+
GoodData.with_project(@project) do |p|
|
193
|
+
attribute = GoodData::Attribute['attr.devs.dev_id']
|
194
|
+
label = attribute.primary_label
|
195
|
+
value = label.values.first
|
196
|
+
fact = GoodData::Fact['fact.commits.lines_changed']
|
197
|
+
metric = GoodData::Metric.xcreate("SELECT SUM([#{fact.uri}]) WHERE [#{attribute.uri}] = [#{value[:uri]}]")
|
198
|
+
metric.contain_value?(label, value[:value]).should == true
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should be able to replace the values in a metric" do
|
203
|
+
GoodData.with_project(@project) do |p|
|
204
|
+
attribute = GoodData::Attribute['attr.devs.dev_id']
|
205
|
+
label = attribute.primary_label
|
206
|
+
value = label.values.first
|
207
|
+
different_value = label.values[1]
|
208
|
+
fact = GoodData::Fact['fact.commits.lines_changed']
|
209
|
+
metric = GoodData::Metric.xcreate("SELECT SUM([#{fact.uri}]) WHERE [#{attribute.uri}] = [#{value[:uri]}]")
|
210
|
+
metric.replace_value(label, value[:value], different_value[:value])
|
211
|
+
metric.contain_value?(label, value[:value]).should == false
|
212
|
+
metric.pretty_expression.should == "SELECT SUM([Lines changed]) WHERE [Dev] = [josh@gooddata.com]"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should be able to lookup the attributes by regexp and return a collectio" do
|
217
|
+
GoodData.with_project(@project) do |p|
|
218
|
+
attrs = GoodData::Attribute.find_by_title(/Date/i)
|
219
|
+
attrs.count.should == 1
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
@@ -5,8 +5,8 @@ describe "Spin a project", :constraint => 'slow' do
|
|
5
5
|
spec = MultiJson.load(File.read("./spec/data/test_project_model_spec.json"), :symbolize_keys => true)
|
6
6
|
ConnectionHelper::create_default_connection
|
7
7
|
|
8
|
-
@source_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
9
|
-
@target_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
8
|
+
@source_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => ConnectionHelper::GD_PROJECT_TOKEN})
|
9
|
+
@target_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => ConnectionHelper::GD_PROJECT_TOKEN})
|
10
10
|
end
|
11
11
|
|
12
12
|
after(:all) do
|
@@ -33,4 +33,4 @@ describe "Spin a project", :constraint => 'slow' do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
end
|
36
|
+
end
|