gooddata 0.6.7 → 0.6.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/README.md +10 -2
- data/TODO.md +32 -0
- data/gooddata.gemspec +5 -0
- data/lib/gooddata.rb +4 -0
- data/lib/gooddata/app/app.rb +12 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +4 -3
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +2 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +23 -5
- data/lib/gooddata/cli/commands/domain_cmd.rb +9 -10
- data/lib/gooddata/cli/commands/process_cmd.rb +11 -9
- data/lib/gooddata/cli/commands/project_cmd.rb +25 -27
- data/lib/gooddata/cli/commands/projects_cmd.rb +2 -2
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/user_cmd.rb +2 -2
- data/lib/gooddata/cli/hooks.rb +4 -2
- data/lib/gooddata/cli/shared.rb +1 -1
- data/lib/gooddata/cli/terminal.rb +1 -1
- data/lib/gooddata/commands/api.rb +1 -1
- data/lib/gooddata/commands/auth.rb +4 -28
- data/lib/gooddata/commands/domain.rb +9 -4
- data/lib/gooddata/commands/process.rb +26 -23
- data/lib/gooddata/commands/project.rb +74 -50
- data/lib/gooddata/commands/projects.rb +3 -2
- data/lib/gooddata/commands/role.rb +9 -3
- data/lib/gooddata/commands/user.rb +6 -4
- data/lib/gooddata/connection.rb +11 -45
- data/lib/gooddata/core/logging.rb +0 -1
- data/lib/gooddata/core/project.rb +22 -22
- data/lib/gooddata/core/rest.rb +9 -8
- data/lib/gooddata/core/user.rb +0 -11
- data/lib/gooddata/exceptions/project_not_found.rb +1 -0
- data/lib/gooddata/extensions/enumerable.rb +10 -0
- data/lib/gooddata/extensions/hash.rb +25 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +4 -4
- data/lib/gooddata/helper/class_helper.rb +1 -0
- data/lib/gooddata/helper/helpers.rb +8 -0
- data/lib/gooddata/helpers/auth_helpers.rb +41 -0
- data/lib/gooddata/mixins/author.rb +1 -1
- data/lib/gooddata/mixins/contributor.rb +1 -1
- data/lib/gooddata/mixins/data_property_reader.rb +2 -0
- data/lib/gooddata/mixins/data_property_writer.rb +2 -0
- data/lib/gooddata/mixins/inspector.rb +49 -0
- data/lib/gooddata/mixins/md_finders.rb +16 -8
- data/lib/gooddata/mixins/md_id_to_uri.rb +12 -4
- data/lib/gooddata/mixins/md_object_indexer.rb +15 -4
- data/lib/gooddata/mixins/md_object_query.rb +42 -20
- data/lib/gooddata/mixins/md_relations.rb +21 -12
- data/lib/gooddata/mixins/meta_getter.rb +2 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +2 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +2 -0
- data/lib/gooddata/mixins/rest_resource.rb +32 -10
- data/lib/gooddata/mixins/root_key_getter.rb +1 -1
- data/lib/gooddata/models/data_result.rb +3 -1
- data/lib/gooddata/models/domain.rb +31 -22
- data/lib/gooddata/models/empty_result.rb +22 -0
- data/lib/gooddata/models/invitation.rb +11 -9
- data/lib/gooddata/models/links.rb +5 -3
- data/lib/gooddata/models/membership.rb +23 -28
- data/lib/gooddata/models/metadata.rb +35 -35
- data/lib/gooddata/models/metadata/attribute.rb +10 -8
- data/lib/gooddata/models/metadata/dashboard.rb +1 -1
- data/lib/gooddata/models/metadata/fact.rb +3 -3
- data/lib/gooddata/models/metadata/label.rb +4 -4
- data/lib/gooddata/models/metadata/metric.rb +76 -38
- data/lib/gooddata/models/metadata/report.rb +52 -17
- data/lib/gooddata/models/metadata/report_definition.rb +178 -28
- data/lib/gooddata/models/model.rb +13 -6
- data/lib/gooddata/models/process.rb +93 -30
- data/lib/gooddata/models/profile.rb +18 -20
- data/lib/gooddata/models/project.rb +344 -127
- data/lib/gooddata/models/project_creator.rb +32 -22
- data/lib/gooddata/models/project_metadata.rb +26 -14
- data/lib/gooddata/models/project_role.rb +15 -17
- data/lib/gooddata/models/report_data_result.rb +4 -0
- data/lib/gooddata/models/schedule.rb +51 -20
- data/lib/gooddata/models/schema_blueprint.rb +9 -3
- data/lib/gooddata/rest/README.md +37 -0
- data/lib/gooddata/rest/client.rb +318 -0
- data/lib/gooddata/rest/connection.rb +235 -0
- data/lib/gooddata/rest/connections/connections.rb +8 -0
- data/lib/gooddata/rest/connections/dummy_connection.rb +52 -0
- data/lib/gooddata/rest/connections/rest_client_connection.rb +177 -0
- data/lib/gooddata/rest/object.rb +32 -0
- data/lib/gooddata/rest/object_factory.rb +67 -0
- data/lib/gooddata/rest/resource.rb +17 -0
- data/lib/gooddata/rest/rest.rb +20 -0
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/cc/data/source/commits.csv +4 -0
- data/spec/data/cc/data/source/devs.csv +4 -0
- data/spec/data/cc/data/source/repos.csv +3 -0
- data/spec/data/cc/devel.prm +0 -0
- data/spec/data/cc/graph/graph.grf +11 -0
- data/spec/data/cc/workspace.prm +19 -0
- data/spec/data/hello_world_process/hello_world.rb +1 -0
- data/spec/data/hello_world_process/hello_world.zip +0 -0
- data/spec/data/users.csv +12 -12
- data/spec/helpers/connection_helper.rb +6 -0
- data/spec/helpers/process_helper.rb +12 -0
- data/spec/helpers/project_helper.rb +2 -2
- data/spec/integration/command_projects_spec.rb +11 -9
- data/spec/integration/create_from_template_spec.rb +6 -2
- data/spec/integration/full_process_schedule_spec.rb +49 -36
- data/spec/integration/full_project_spec.rb +221 -256
- data/spec/integration/partial_md_export_import_spec.rb +18 -17
- data/spec/logging_in_logging_out_spec.rb +17 -8
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/cli/commands/cmd_api_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_auth_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_domain_spec.rb +29 -3
- data/spec/unit/cli/commands/cmd_process_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_project_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_role_spec.rb +13 -2
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_user_spec.rb +1 -1
- data/spec/unit/commands/command_api_spec.rb +0 -19
- data/spec/unit/commands/command_auth_spec.rb +20 -13
- data/spec/unit/commands/command_dataset_spec.rb +2 -2
- data/spec/unit/commands/command_process_spec.rb +24 -21
- data/spec/unit/commands/command_projects_spec.rb +2 -2
- data/spec/unit/commands/command_scaffold_spec.rb +2 -2
- data/spec/unit/commands/command_user_spec.rb +3 -3
- data/spec/unit/core/connection_spec.rb +9 -10
- data/spec/unit/core/project_spec.rb +8 -4
- data/spec/unit/core/rest_spec.rb +6 -6
- data/spec/unit/models/domain_spec.rb +14 -7
- data/spec/unit/models/invitation_spec.rb +2 -2
- data/spec/unit/models/membership_spec.rb +5 -5
- data/spec/unit/models/metric_spec.rb +92 -0
- data/spec/unit/models/profile_spec.rb +25 -21
- data/spec/unit/models/project_blueprint_spec.rb +6 -6
- data/spec/unit/models/project_role_spec.rb +3 -5
- data/spec/unit/models/project_spec.rb +43 -37
- data/spec/unit/models/schedule_spec.rb +58 -107
- data/spec/unit/rest/resource_spec.rb +6 -0
- metadata +87 -10
- data/lib/gooddata/cli/commands/role_cmd.rb +0 -28
- data/lib/gooddata/core/connection.rb +0 -392
- data/lib/gooddata/core/threaded.rb +0 -14
- data/lib/gooddata/models/md_object.rb +0 -25
- data/lib/gooddata/models/metadata/folder.rb +0 -24
- data/spec/unit/models/md_object_spec.rb +0 -55
- data/spec/unit/models/metric.rb +0 -92
data/spec/data/users.csv
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
First Name,Last Name,Email,Password,MUF,MUF ID,Role,Role ID,Project ID,Domain
|
|
2
|
-
Gem,Tester,svarovsky+gem_tester@gooddata.com,jindrisska,Edit,,adminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
3
|
-
Test,User0,test.user.110@example.com,password0,Full,,adminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
4
|
-
Test,User1,test.user.111@example.com,password1,Full,,connectorsSystemRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
5
|
-
Test,User2,test.user.112@example.com,password2,Full,,editorRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
6
|
-
Test,User3,test.user.113@example.com,password3,Full,,dashboardOnlyRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
7
|
-
Test,User4,test.user.114@example.com,password4,Full,,unverifiedAdminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
8
|
-
Test,User5,test.user.115@example.com,password5,Full,,readOnlyUserRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
9
|
-
Test,User6,test.user.116@example.com,password6,Full,,adminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
10
|
-
Test,User7,test.user.117@example.com,password7,Full,,connectorsSystemRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
11
|
-
Test,User8,test.user.118@example.com,password8,Full,,editorRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
12
|
-
Test,User9,test.user.119@example.com,password9,Full,,dashboardOnlyRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
1
|
+
First Name,Last Name,Email,Password,MUF,MUF ID,Role,Role ID,Project ID,Domain
|
|
2
|
+
Gem,Tester,svarovsky+gem_tester@gooddata.com,jindrisska,Edit,,adminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
3
|
+
Test,User0,test.user.110@example.com,password0,Full,,adminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
4
|
+
Test,User1,test.user.111@example.com,password1,Full,,connectorsSystemRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
5
|
+
Test,User2,test.user.112@example.com,password2,Full,,editorRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
6
|
+
Test,User3,test.user.113@example.com,password3,Full,,dashboardOnlyRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
7
|
+
Test,User4,test.user.114@example.com,password4,Full,,unverifiedAdminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
8
|
+
Test,User5,test.user.115@example.com,password5,Full,,readOnlyUserRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
9
|
+
Test,User6,test.user.116@example.com,password6,Full,,adminRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
10
|
+
Test,User7,test.user.117@example.com,password7,Full,,connectorsSystemRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
11
|
+
Test,User8,test.user.118@example.com,password8,Full,,editorRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
12
|
+
Test,User9,test.user.119@example.com,password9,Full,,dashboardOnlyRole,5,wgqhml3se0035s8n5byqdq0j0ob5jam4,gooddata-tomas-svarovsky
|
|
@@ -16,6 +16,12 @@ module ConnectionHelper
|
|
|
16
16
|
GoodData::connect(username, password)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def self.disconnect
|
|
20
|
+
conn = GoodData.connection.connection
|
|
21
|
+
GoodData.disconnect
|
|
22
|
+
puts conn.stats_table
|
|
23
|
+
end
|
|
24
|
+
|
|
19
25
|
# Creates connection using environment varibles GD_GEM_USER and GD_GEM_PASSWORD
|
|
20
26
|
def self.create_private_connection
|
|
21
27
|
username = ENV['GD_GEM_USER'] || DEFAULT_USERNAME
|
|
@@ -12,7 +12,7 @@ module ProjectHelper
|
|
|
12
12
|
PROJECT_TITLE = 'GoodTravis'
|
|
13
13
|
PROJECT_SUMMARY = 'No summary'
|
|
14
14
|
|
|
15
|
-
def self.get_default_project
|
|
16
|
-
GoodData::Project[PROJECT_ID]
|
|
15
|
+
def self.get_default_project(opts = { :client => GoodData.connection })
|
|
16
|
+
GoodData::Project[PROJECT_ID, opts]
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -3,25 +3,27 @@ require 'gooddata/commands/project'
|
|
|
3
3
|
|
|
4
4
|
describe GoodData::Command::Project, :constraint => 'slow' do
|
|
5
5
|
before(:all) do
|
|
6
|
+
@client = ConnectionHelper.create_default_connection
|
|
7
|
+
|
|
6
8
|
@blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/test_project_model_spec.json")
|
|
7
9
|
@module_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/additional_dataset_module.json")
|
|
8
10
|
|
|
9
|
-
ConnectionHelper::
|
|
10
|
-
@project = GoodData::Command::Project.build({:spec => @blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN})
|
|
11
|
+
@project = GoodData::Command::Project.build({:spec => @blueprint, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
after(:all) do
|
|
14
15
|
@project.delete unless @project.nil?
|
|
16
|
+
|
|
17
|
+
@client.disconnect
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
it "should update the project" do
|
|
18
21
|
@blueprint.merge!(@module_blueprint)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
22
|
+
@project.blueprint.datasets.count.should == 3
|
|
23
|
+
@project.blueprint.datasets(:include_date_dimensions => true).count.should == 4
|
|
24
|
+
GoodData::Command::Project.update({:spec => @blueprint, :client => @client, :project => @project})
|
|
25
|
+
@project.blueprint.datasets.count.should == 4
|
|
26
|
+
@project.blueprint.datasets(:include_date_dimensions => true).count.should == 5
|
|
27
|
+
|
|
26
28
|
end
|
|
27
29
|
end
|
|
@@ -2,11 +2,15 @@ require 'gooddata'
|
|
|
2
2
|
|
|
3
3
|
describe "Spin a project from template", :constraint => 'slow' do
|
|
4
4
|
before(:all) do
|
|
5
|
-
ConnectionHelper
|
|
5
|
+
@client = ConnectionHelper.create_default_connection
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
after(:all) do
|
|
9
|
+
@client.disconnect
|
|
6
10
|
end
|
|
7
11
|
|
|
8
12
|
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/template/uri", :auth_token => ConnectionHelper::GD_PROJECT_TOKEN)}.to raise_error
|
|
13
|
+
expect{GoodData::Project.create(:title => "Test project", :template => "/some/nonexisting/template/uri", :auth_token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client)}.to raise_error
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
end
|
|
@@ -2,68 +2,81 @@ require 'gooddata'
|
|
|
2
2
|
|
|
3
3
|
describe "Full process and schedule exercise", :constraint => 'slow' do
|
|
4
4
|
before(:all) do
|
|
5
|
-
ConnectionHelper::create_default_connection
|
|
6
|
-
@project = GoodData::Project.create(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
|
|
7
|
-
@process =
|
|
5
|
+
@client = ConnectionHelper::create_default_connection
|
|
6
|
+
@project = GoodData::Project.create(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN, :client => @client)
|
|
7
|
+
@process = @project.deploy_process('./spec/data/ruby_process',
|
|
8
8
|
type: 'RUBY',
|
|
9
|
-
project: @project,
|
|
10
9
|
name: 'Test ETL Process')
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
after(:all) do
|
|
14
13
|
@process.delete if @process
|
|
15
14
|
@project.delete if @project
|
|
15
|
+
@client.disconnect
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "should be able to execute a process" do
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(log.index('Hello Ruby executors')).not_to eq nil
|
|
24
|
-
expect(log.index('Hello Ruby from the deep')).not_to eq nil
|
|
25
|
-
end
|
|
19
|
+
result = @process.execute(@process.executables.first)
|
|
20
|
+
log = @client.get(result['executionDetail']['links']['log'])
|
|
21
|
+
expect(log.index('Hello Ruby executors')).not_to eq nil
|
|
22
|
+
expect(log.index('Hello Ruby from the deep')).not_to eq nil
|
|
26
23
|
end
|
|
27
24
|
|
|
28
25
|
it "should be able to grab executables" do
|
|
29
|
-
|
|
26
|
+
|
|
30
27
|
expect(@process.executables).to eq ['./process.rb']
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
it "should have empty schedules on deploy" do
|
|
34
|
-
|
|
35
|
-
GoodData.with_project(@project) do |project|
|
|
36
|
-
expect(@process.schedules).to eq []
|
|
37
|
-
end
|
|
31
|
+
expect(@process.schedules).to eq []
|
|
38
32
|
end
|
|
39
33
|
|
|
40
|
-
it "should be able to schedule" do
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
expect(@process.schedules).to eq [schedule]
|
|
46
|
-
schedule.delete
|
|
47
|
-
end
|
|
34
|
+
it "should be able to delete schedule" do
|
|
35
|
+
schedule = @process.create_schedule('0 15 27 7 *', @process.executables.first)
|
|
36
|
+
expect(@process.schedules.count).to eq 1
|
|
37
|
+
expect(@process.schedules).to eq [schedule]
|
|
38
|
+
schedule.delete
|
|
48
39
|
end
|
|
49
40
|
|
|
50
41
|
it "should be possible to read status of schedule" do
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
expect(schedule.state).to eq 'ENABLED'
|
|
55
|
-
schedule.delete
|
|
56
|
-
end
|
|
42
|
+
schedule = @process.create_schedule('0 15 27 7 *', @process.executables.first)
|
|
43
|
+
expect(schedule.state).to eq 'ENABLED'
|
|
44
|
+
schedule.delete
|
|
57
45
|
end
|
|
58
46
|
|
|
59
47
|
it "should be possible to execute schedule" do
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
schedule = @process.create_schedule('0 15 27 7 *', @process.executables.first)
|
|
49
|
+
result = schedule.execute
|
|
50
|
+
log = @client.get(result['execution']['log'])
|
|
51
|
+
expect(log.index('Hello Ruby executors')).not_to eq nil
|
|
52
|
+
expect(log.index('Hello Ruby from the deep')).not_to eq nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should be possible to deploy only a single file" do
|
|
56
|
+
process = @project.deploy_process('./spec/data/hello_world_process/hello_world.rb',
|
|
57
|
+
type: 'RUBY',
|
|
58
|
+
name: 'Test ETL one file Process')
|
|
59
|
+
begin
|
|
60
|
+
schedule = process.create_schedule('0 15 27 7 *', process.executables.first)
|
|
61
|
+
result = schedule.execute
|
|
62
|
+
log = @client.get(result['execution']['log'])
|
|
63
|
+
expect(log.index('HELLO WORLD')).not_to eq nil
|
|
64
|
+
ensure
|
|
65
|
+
process && process.delete
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should be possible to deploy already zipped file" do
|
|
70
|
+
process = @project.deploy_process('./spec/data/hello_world_process/hello_world.zip',
|
|
71
|
+
type: 'RUBY',
|
|
72
|
+
name: 'Test ETL zipped file Process')
|
|
73
|
+
begin
|
|
74
|
+
schedule = process.create_schedule('0 15 27 7 *', process.executables.first)
|
|
63
75
|
result = schedule.execute
|
|
64
|
-
log =
|
|
65
|
-
expect(log.index('
|
|
66
|
-
|
|
76
|
+
log = @client.get(result['execution']['log'])
|
|
77
|
+
expect(log.index('HELLO WORLD')).not_to eq nil
|
|
78
|
+
ensure
|
|
79
|
+
process && process.delete
|
|
67
80
|
end
|
|
68
81
|
end
|
|
69
82
|
end
|
|
@@ -2,55 +2,57 @@ require 'gooddata'
|
|
|
2
2
|
|
|
3
3
|
describe "Full project implementation", :constraint => 'slow' do
|
|
4
4
|
before(:all) do
|
|
5
|
-
@spec = JSON.parse(File.read(
|
|
6
|
-
@invalid_spec = JSON.parse(File.read(
|
|
7
|
-
ConnectionHelper::create_default_connection
|
|
8
|
-
@project = GoodData::Model::ProjectCreator.migrate(:spec => @spec, :token => ConnectionHelper::GD_PROJECT_TOKEN)
|
|
5
|
+
@spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
|
|
6
|
+
@invalid_spec = JSON.parse(File.read("./spec/data/blueprint_invalid.json"), :symbolize_names => true)
|
|
7
|
+
@client = ConnectionHelper::create_default_connection
|
|
8
|
+
@project = GoodData::Model::ProjectCreator.migrate({:spec => @spec, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
after(:all) do
|
|
12
12
|
@project.delete unless @project.nil?
|
|
13
|
+
|
|
14
|
+
@client.disconnect
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
it "should not build an invalid model" do
|
|
16
18
|
expect {
|
|
17
|
-
GoodData::Model::ProjectCreator.migrate({:spec => @invalid_spec, :token => ConnectionHelper::GD_PROJECT_TOKEN})
|
|
19
|
+
GoodData::Model::ProjectCreator.migrate({:spec => @invalid_spec, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
|
|
18
20
|
}.to raise_error(GoodData::ValidationError)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it "should contain datasets" do
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
expect(bp.datasets(:include_date_dimensions => true).count).to eq 4
|
|
26
|
-
end
|
|
24
|
+
@project.blueprint.tap do |bp|
|
|
25
|
+
expect(bp.datasets.count).to eq 3
|
|
26
|
+
expect(bp.datasets(:include_date_dimensions => true).count).to eq 4
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should be able to rename a project" do
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
p.save
|
|
39
|
-
end
|
|
31
|
+
former_title = @project.title
|
|
32
|
+
a_title = (0...8).map { (65 + rand(26)).chr }.join
|
|
33
|
+
@project.title = a_title
|
|
34
|
+
@project.save
|
|
35
|
+
expect(@project.title).to eq a_title
|
|
36
|
+
@project.title = former_title
|
|
37
|
+
@project.save
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
it "should be able to validate a project" do
|
|
43
|
-
|
|
44
|
-
p.validate
|
|
45
|
-
end
|
|
41
|
+
@project.validate
|
|
46
42
|
end
|
|
47
43
|
|
|
48
44
|
it "should compute an empty metric" do
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
f = @project.fact_by_title('Lines Changed')
|
|
46
|
+
metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
|
|
47
|
+
expect(metric.execute).to be_nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should compute an empty report def" do
|
|
51
|
+
@project.delete_all_data(force: true)
|
|
52
|
+
f = @project.fact_by_title('Lines Changed')
|
|
53
|
+
metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
|
|
54
|
+
res = GoodData::ReportDefinition.execute(:left => [metric], :client => @client, :project => @project);
|
|
55
|
+
expect(res).to be_empty
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
it "should load the data" do
|
|
@@ -61,7 +63,7 @@ describe "Full project implementation", :constraint => 'slow' do
|
|
|
61
63
|
[1,"01/01/2014",1,1],
|
|
62
64
|
[3,"01/02/2014",2,2],
|
|
63
65
|
[5,"05/02/2014",3,1]]
|
|
64
|
-
GoodData::Model.upload_data(commits_data, blueprint, 'commits')
|
|
66
|
+
GoodData::Model.upload_data(commits_data, blueprint, 'commits', :client => @client, :project => @project)
|
|
65
67
|
# blueprint.find_dataset('commits').upload(commits_data)
|
|
66
68
|
|
|
67
69
|
devs_data = [
|
|
@@ -69,329 +71,292 @@ describe "Full project implementation", :constraint => 'slow' do
|
|
|
69
71
|
[1, "tomas@gooddata.com"],
|
|
70
72
|
[2, "petr@gooddata.com"],
|
|
71
73
|
[3, "jirka@gooddata.com"]]
|
|
72
|
-
GoodData::Model.upload_data(devs_data, blueprint, 'devs')
|
|
74
|
+
GoodData::Model.upload_data(devs_data, blueprint, 'devs', :client => @client, :project => @project)
|
|
73
75
|
# blueprint.find_dataset('devs').upload(devs_data)
|
|
74
76
|
end
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
it "should compute a metric" do
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
metric.execute.should == 9
|
|
82
|
-
end
|
|
80
|
+
f = @project.fact_by_title('Lines Changed')
|
|
81
|
+
metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
|
|
82
|
+
expect(metric.execute).to eq 9
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "should execute an anonymous metric twice and not fail" do
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
f = @project.fact_by_title('Lines Changed')
|
|
87
|
+
metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
|
|
88
|
+
expect(metric.execute).to eq 9
|
|
89
|
+
# Since GD platform cannot execute inline specified metric the metric has to be saved
|
|
90
|
+
# The code tries to resolve this as transparently as possible
|
|
91
|
+
# Here we are testing that you can execute the metric twice. The first execution is on unsaved metric
|
|
92
|
+
# We wanna make sure that when we are cleaning up we are not messing things up
|
|
93
|
+
expect(metric.execute).to eq 9
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
it "should compute a report" do
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
end
|
|
96
|
+
it "should compute a report def" do
|
|
97
|
+
f = @project.fact_by_title('Lines Changed')
|
|
98
|
+
|
|
99
|
+
# TODO: Here we create metric which is not deleted and is used by another test - "should exercise the object relations and getting them in various ways"
|
|
100
|
+
metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")", :title => "My metric")
|
|
101
|
+
metric.save
|
|
102
|
+
result = GoodData::ReportDefinition.execute(:title => "My report", :top => [metric], :left => ['label.devs.dev_id.email'], :client => @client, :project => @project)
|
|
103
|
+
expect(result[1][1]).to eq 3
|
|
104
|
+
expect(result.include_row?(["jirka@gooddata.com", 5])).to be true
|
|
105
|
+
|
|
106
|
+
result2 = GoodData::ReportDefinition.create(:title => "My report", :top => [metric], :left => ['label.devs.dev_id.email'], :client => @client, :project => @project).execute
|
|
107
|
+
expect(result2[1][1]).to eq 3
|
|
108
|
+
expect(result2.include_row?(["jirka@gooddata.com", 5])).to eq true
|
|
109
|
+
expect(result2).to eq result
|
|
111
110
|
end
|
|
112
111
|
|
|
113
|
-
it "should
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
it "should be able to purge report from older revisions" do
|
|
113
|
+
m = @project.metrics.first
|
|
114
|
+
r = @project.create_report(top: [m], title: 'xy')
|
|
115
|
+
expect(r.definitions.count).to eq 1
|
|
116
|
+
|
|
117
|
+
rd = GoodData::ReportDefinition.create(:top => [m], :client => @client, :project => @project)
|
|
118
|
+
rd.save
|
|
119
|
+
r.add_definition(rd)
|
|
120
|
+
r.save
|
|
121
|
+
expect(r.definitions.count).to eq 2
|
|
117
122
|
end
|
|
118
123
|
|
|
119
124
|
it "should be possible to get all metrics" do
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
metrics2 = GoodData::Metric.all
|
|
123
|
-
metrics1.should == metrics2
|
|
124
|
-
end
|
|
125
|
+
metrics1 = @project.metrics
|
|
126
|
+
expect(metrics1.count).to be >= 0
|
|
125
127
|
end
|
|
126
128
|
|
|
127
129
|
it "should be possible to get all metrics with full objects" do
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
metrics2 = GoodData::Metric.all :full => true
|
|
131
|
-
metrics1.should == metrics2
|
|
132
|
-
end
|
|
130
|
+
metrics1 = @project.metrics(:all, full: false)
|
|
131
|
+
expect(metrics1.first.class).to be Hash
|
|
133
132
|
end
|
|
134
133
|
|
|
135
134
|
it "should be able to get a metric by identifier" do
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
metrics.first == metric
|
|
141
|
-
end
|
|
135
|
+
metrics = @project.metrics
|
|
136
|
+
metric = @project.metrics(metrics.first.identifier)
|
|
137
|
+
expect(metric.identifier).to eq metrics.first.identifier
|
|
138
|
+
expect(metrics.first).to eq metric
|
|
142
139
|
end
|
|
143
140
|
|
|
144
141
|
it "should be able to get a metric by uri" do
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
metrics.first == metric
|
|
150
|
-
end
|
|
142
|
+
metrics = @project.metrics
|
|
143
|
+
metric = @project.metrics(metrics.first.uri)
|
|
144
|
+
expect(metric.uri).to eq metrics.first.uri
|
|
145
|
+
expect(metrics.first).to eq metric
|
|
151
146
|
end
|
|
152
147
|
|
|
153
148
|
it "should be able to get a metric by object id" do
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
metrics.first == metric
|
|
159
|
-
end
|
|
149
|
+
metrics = @project.metrics
|
|
150
|
+
metric = @project.metrics(metrics.first.obj_id)
|
|
151
|
+
expect(metric.obj_id).to eq metrics.first.obj_id
|
|
152
|
+
expect(metrics.first).to eq metric
|
|
160
153
|
end
|
|
161
154
|
|
|
162
155
|
it "should exercise the object relations and getting them in various ways" do
|
|
163
|
-
|
|
156
|
+
# Find a metric by name
|
|
157
|
+
metric = @project.metric_by_title('My metric')
|
|
158
|
+
the_same_metric = @project.metrics(metric)
|
|
159
|
+
expect(metric).to eq the_same_metric
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
# grab fact in several different ways
|
|
162
|
+
fact1 = @project.fact_by_title('Lines Changed')
|
|
163
|
+
fact2 = @project.facts(fact1.identifier)
|
|
164
|
+
fact3 = @project.facts(fact2.obj_id)
|
|
165
|
+
fact4 = @project.facts(fact3.uri)
|
|
166
|
+
fact5 = @client.create(GoodData::Fact, fact4)
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
# All should be the same
|
|
169
|
+
expect(fact1).to eq fact2
|
|
170
|
+
expect(fact1).to eq fact2
|
|
171
|
+
expect(fact1).to eq fact3
|
|
172
|
+
expect(fact1).to eq fact4
|
|
173
|
+
expect(fact1).to eq fact5
|
|
176
174
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
fact1.should == fact2
|
|
180
|
-
fact1.should == fact3
|
|
181
|
-
fact1.should == fact4
|
|
182
|
-
fact1.should == fact5
|
|
175
|
+
fact3.title = "Somewhat changed title"
|
|
176
|
+
expect(fact1).not_to eq fact3
|
|
183
177
|
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
metric.using(nil)
|
|
179
|
+
expect(metric.using('fact', :client => @client, :project => @project).count).to eq 1
|
|
186
180
|
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
fact1.used_by(nil)
|
|
182
|
+
expect(fact1.used_by('metric', :client => @client, :project => @project).count).to eq 1
|
|
189
183
|
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
res = metric.using?(fact1)
|
|
185
|
+
expect(res).to be(true)
|
|
192
186
|
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
res = fact1.using?(metric)
|
|
188
|
+
expect(res).to be(false)
|
|
195
189
|
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
res = metric.used_by?(fact1)
|
|
191
|
+
expect(res).to be(false)
|
|
198
192
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
res = fact1.used_by?(metric)
|
|
203
|
-
expect(res).to be(true)
|
|
204
|
-
end
|
|
193
|
+
res = fact1.used_by?(metric)
|
|
194
|
+
expect(res).to be(true)
|
|
205
195
|
end
|
|
206
196
|
|
|
207
197
|
it "should try setting and getting by tags" do
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
fact.tags.should be_empty
|
|
198
|
+
fact = @project.fact_by_title('Lines Changed')
|
|
199
|
+
expect(fact.tags.empty?).to be_true
|
|
211
200
|
|
|
212
|
-
|
|
213
|
-
|
|
201
|
+
fact.tags = "tag1,tag2,tag3"
|
|
202
|
+
fact.save
|
|
214
203
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
end
|
|
204
|
+
tagged_facts = GoodData::Fact.find_by_tag('tag3', :client => @client, :project => @project)
|
|
205
|
+
expect(tagged_facts.count).to eq 1
|
|
218
206
|
end
|
|
219
207
|
|
|
220
208
|
it "should contain metadata for each dataset in project metadata" do
|
|
221
|
-
GoodData.
|
|
222
|
-
|
|
223
|
-
k.should include("manifest_devs")
|
|
224
|
-
end
|
|
209
|
+
k = GoodData::ProjectMetadata.keys(:client => @client, :project => @project)
|
|
210
|
+
expect(k).to include("manifest_devs")
|
|
225
211
|
end
|
|
226
212
|
|
|
227
213
|
it "should be able to interpolate metric based on" do
|
|
228
|
-
GoodData.
|
|
229
|
-
|
|
230
|
-
res.should == 9
|
|
214
|
+
res = GoodData::Metric.xexecute "SELECT SUM(![fact.commits.lines_changed])", :client => @client, :project => @project
|
|
215
|
+
expect(res).to eq 9
|
|
231
216
|
|
|
232
|
-
|
|
233
|
-
|
|
217
|
+
res = GoodData::Metric.xexecute( "SELECT SUM(![fact.commits.lines_changed])", :client => @client, :project => @project)
|
|
218
|
+
expect(res).to eq 9
|
|
234
219
|
|
|
235
|
-
|
|
236
|
-
|
|
220
|
+
res = GoodData::Metric.execute("SELECT SUM(![fact.commits.lines_changed])", :extended_notation => true, :client => @client, :project => @project)
|
|
221
|
+
expect(res).to eq 9
|
|
237
222
|
|
|
238
|
-
|
|
239
|
-
|
|
223
|
+
res = GoodData::Metric.execute("SELECT SUM(![fact.commits.lines_changed])", :extended_notation => true, :client => @client, :project => @project)
|
|
224
|
+
expect(res).to eq 9
|
|
240
225
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
end
|
|
226
|
+
fact = @project.fact_by_title('Lines Changed')
|
|
227
|
+
expect(fact.fact?).to be true
|
|
228
|
+
res = fact.create_metric(:type => :sum).execute
|
|
229
|
+
expect(res).to eq 9
|
|
246
230
|
end
|
|
247
231
|
|
|
248
232
|
it "should load the data" do
|
|
249
|
-
GoodData.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
# blueprint.find_dataset('devs').upload(devs_data, :load => 'INCREMENTAL')
|
|
256
|
-
end
|
|
233
|
+
blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
|
|
234
|
+
devs_data = [
|
|
235
|
+
["dev_id", "email"],
|
|
236
|
+
[4, "josh@gooddata.com"]]
|
|
237
|
+
GoodData::Model.upload_data(devs_data, blueprint, 'devs', mode: 'INCREMENTAL', :client => @client, :project => @project)
|
|
238
|
+
# blueprint.find_dataset('devs').upload(devs_data, :load => 'INCREMENTAL')
|
|
257
239
|
end
|
|
258
240
|
|
|
259
241
|
it "should have more users" do
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
attribute.create_metric.execute.should == 4
|
|
264
|
-
end
|
|
242
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
243
|
+
expect(attribute.attribute?).to be true
|
|
244
|
+
expect(attribute.create_metric.execute).to eq 4
|
|
265
245
|
end
|
|
266
246
|
|
|
267
247
|
it "should tell you whether metric contains a certain attribute" do
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
expect(l.value?("DEFINITELY NON EXISTENT VALUE HOPEFULLY")).to eq false
|
|
287
|
-
end
|
|
248
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
249
|
+
repo_attribute = @project.attributes('attr.repos.repo_id')
|
|
250
|
+
metric = attribute.create_metric(:title => "My test metric")
|
|
251
|
+
metric.save
|
|
252
|
+
expect(metric.execute).to eq 4
|
|
253
|
+
|
|
254
|
+
expect(metric.contain?(attribute)).to be true
|
|
255
|
+
expect(metric.contain?(repo_attribute)).to be false
|
|
256
|
+
|
|
257
|
+
metric.replace(attribute, repo_attribute)
|
|
258
|
+
metric.save
|
|
259
|
+
expect(metric.execute).not_to eq 4
|
|
260
|
+
|
|
261
|
+
l = attribute.primary_label
|
|
262
|
+
value = l.values.first[:value]
|
|
263
|
+
expect(l.find_element_value(l.find_value_uri(value))).to eq value
|
|
264
|
+
expect(l.value?(value)).to eq true
|
|
265
|
+
expect(l.value?("DEFINITELY NON EXISTENT VALUE HOPEFULLY")).to eq false
|
|
288
266
|
end
|
|
289
267
|
|
|
290
268
|
it "should be able to compute count of different datasets" do
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
attribute.create_metric(:attribute => dataset_attribute).execute.should == 3
|
|
295
|
-
end
|
|
269
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
270
|
+
dataset_attribute = @project.attributes('attr.commits.factsof')
|
|
271
|
+
expect(attribute.create_metric(:attribute => dataset_attribute).execute).to eq 3
|
|
296
272
|
end
|
|
297
273
|
|
|
298
274
|
it "should be able to tell you if a value is contained in a metric" do
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
metric.contain_value?(label, value[:value]).should == true
|
|
306
|
-
end
|
|
275
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
276
|
+
label = attribute.primary_label
|
|
277
|
+
value = label.values.first
|
|
278
|
+
fact = @project.facts('fact.commits.lines_changed')
|
|
279
|
+
metric = @project.create_metric("SELECT SUM([#{fact.uri}]) WHERE [#{attribute.uri}] = [#{value[:uri]}]")
|
|
280
|
+
expect(metric.contain_value?(label, value[:value])).to be true
|
|
307
281
|
end
|
|
308
282
|
|
|
309
283
|
it "should be able to replace the values in a metric" do
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
metric.pretty_expression.should == "SELECT SUM([Lines Changed]) WHERE [Dev] = [josh@gooddata.com]"
|
|
320
|
-
end
|
|
284
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
285
|
+
label = attribute.primary_label
|
|
286
|
+
value = label.values.first
|
|
287
|
+
different_value = label.values[1]
|
|
288
|
+
fact = @project.facts('fact.commits.lines_changed')
|
|
289
|
+
metric = @project.create_metric("SELECT SUM([#{fact.uri}]) WHERE [#{attribute.uri}] = [#{value[:uri]}]")
|
|
290
|
+
metric.replace_value(label, value[:value], different_value[:value])
|
|
291
|
+
expect(metric.contain_value?(label, value[:value])).to be false
|
|
292
|
+
expect(metric.pretty_expression).to eq "SELECT SUM([Lines Changed]) WHERE [Dev] = [josh@gooddata.com]"
|
|
321
293
|
end
|
|
322
294
|
|
|
323
295
|
it "should be able to lookup the attributes by regexp and return a collection" do
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
attrs.count.should == 1
|
|
327
|
-
end
|
|
296
|
+
attrs = @project.attributes_by_title(/Date/i)
|
|
297
|
+
expect(attrs.count).to eq 1
|
|
328
298
|
end
|
|
329
299
|
|
|
330
300
|
it "should be able to give you values of the label as an array of hashes" do
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
]
|
|
340
|
-
end
|
|
301
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
302
|
+
label = attribute.primary_label
|
|
303
|
+
expect(label.values.map { |v| v[:value] }).to eq [
|
|
304
|
+
'jirka@gooddata.com',
|
|
305
|
+
'josh@gooddata.com',
|
|
306
|
+
'petr@gooddata.com',
|
|
307
|
+
'tomas@gooddata.com'
|
|
308
|
+
]
|
|
341
309
|
end
|
|
342
310
|
|
|
343
311
|
it "should be able to give you values for" do
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
attribute.values_for(2).should == ["tomas@gooddata.com", "1"]
|
|
347
|
-
end
|
|
312
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
313
|
+
expect(attribute.values_for(2)).to eq ["tomas@gooddata.com", "1"]
|
|
348
314
|
end
|
|
349
315
|
|
|
350
316
|
it "should be able to find specific element and give you the primary label value" do
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
GoodData::Attribute.find_element_value("#{attribute.uri}/elements?id=2").should == 'tomas@gooddata.com'
|
|
354
|
-
end
|
|
317
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
318
|
+
expect(@project.find_attribute_element_value("#{attribute.uri}/elements?id=2")).to eq 'tomas@gooddata.com'
|
|
355
319
|
end
|
|
356
320
|
|
|
357
321
|
it "should be able to give you label by name" do
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
label.attribute.should == attribute
|
|
366
|
-
end
|
|
322
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
323
|
+
label = attribute.label_by_name('email')
|
|
324
|
+
expect(label.label?).to eq true
|
|
325
|
+
expect(label.title).to eq 'Email'
|
|
326
|
+
expect(label.identifier).to eq 'label.devs.dev_id.email'
|
|
327
|
+
expect(label.attribute_uri).to eq attribute.uri
|
|
328
|
+
expect(label.attribute).to eq attribute
|
|
367
329
|
end
|
|
368
330
|
|
|
369
331
|
it "should be able to return values of the attribute for inspection" do
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
vals.first.first[:value].should == "jirka@gooddata.com"
|
|
376
|
-
end
|
|
332
|
+
attribute = @project.attributes('attr.devs.dev_id')
|
|
333
|
+
vals = attribute.values
|
|
334
|
+
expect(vals.count).to eq 4
|
|
335
|
+
expect(vals.first.count).to eq 2
|
|
336
|
+
expect(vals.first.first[:value]).to eq "jirka@gooddata.com"
|
|
377
337
|
end
|
|
378
338
|
|
|
379
339
|
it "should be able to save_as a metric" do
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
m_cloned.execute.should == cloned.execute
|
|
386
|
-
end
|
|
340
|
+
m = @project.metric_by_title("My test metric")
|
|
341
|
+
cloned = m.save_as
|
|
342
|
+
m_cloned = @project.metric_by_title("Clone of My test metric")
|
|
343
|
+
expect(m_cloned).to eq cloned
|
|
344
|
+
expect(m_cloned.execute).to eq cloned.execute
|
|
387
345
|
end
|
|
388
346
|
|
|
389
347
|
it "should be able to clone a project" do
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
348
|
+
title = 'My new clone proejct'
|
|
349
|
+
cloned_project = @project.clone(title: title, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
|
|
350
|
+
expect(cloned_project.title).to eq title
|
|
351
|
+
expect(cloned_project.facts.first.create_metric.execute).to eq 9
|
|
352
|
+
cloned_project.delete
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
it "should be able to clone a project without data" do
|
|
356
|
+
title = 'My new clone project'
|
|
357
|
+
cloned_project = @project.clone(title: title, auth_token: ConnectionHelper::GD_PROJECT_TOKEN, data: false)
|
|
358
|
+
expect(cloned_project.title).to eq title
|
|
359
|
+
expect(cloned_project.facts.first.create_metric.execute).to eq nil
|
|
360
|
+
cloned_project.delete
|
|
396
361
|
end
|
|
397
362
|
end
|