gooddata 0.6.0 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +13 -5
  2. data/.rubocop.yml +23 -0
  3. data/.travis.yml +9 -4
  4. data/CLI.md +439 -0
  5. data/Gemfile +0 -1
  6. data/README.md +2 -2
  7. data/Rakefile +60 -8
  8. data/doc/templates/default/module/setup.rb +1 -1
  9. data/examples.rb +2 -0
  10. data/gooddata +2 -0
  11. data/gooddata.gemspec +12 -8
  12. data/lib/gooddata.rb +0 -2
  13. data/lib/gooddata/bricks/base_downloader.rb +52 -47
  14. data/lib/gooddata/bricks/brick.rb +20 -31
  15. data/lib/gooddata/bricks/bricks.rb +1 -1
  16. data/lib/gooddata/bricks/middleware/base_middleware.rb +9 -7
  17. data/lib/gooddata/bricks/middleware/bench_middleware.rb +12 -10
  18. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +28 -28
  19. data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +20 -16
  20. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +21 -19
  21. data/lib/gooddata/bricks/middleware/logger_middleware.rb +10 -8
  22. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +36 -34
  23. data/lib/gooddata/bricks/middleware/stdout_middleware.rb +11 -9
  24. data/lib/gooddata/bricks/middleware/twitter_middleware.rb +14 -12
  25. data/lib/gooddata/bricks/pipeline.rb +28 -0
  26. data/lib/gooddata/bricks/utils.rb +10 -8
  27. data/lib/gooddata/cli/cli.rb +1 -6
  28. data/lib/gooddata/cli/commands/auth_cmd.rb +1 -1
  29. data/lib/gooddata/cli/commands/console_cmd.rb +7 -5
  30. data/lib/gooddata/cli/commands/domain_cmd.rb +45 -0
  31. data/lib/gooddata/cli/commands/process_cmd.rb +42 -5
  32. data/lib/gooddata/cli/commands/project_cmd.rb +96 -36
  33. data/lib/gooddata/cli/commands/projects_cmd.rb +21 -0
  34. data/lib/gooddata/cli/commands/role_cmd.rb +28 -0
  35. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +5 -5
  36. data/lib/gooddata/cli/commands/scaffold_cmd.rb +1 -1
  37. data/lib/gooddata/cli/commands/{profile_cmd.rb → user_cmd.rb} +7 -9
  38. data/lib/gooddata/cli/shared.rb +3 -2
  39. data/lib/gooddata/client.rb +16 -304
  40. data/lib/gooddata/commands/api.rb +13 -5
  41. data/lib/gooddata/commands/auth.rb +47 -40
  42. data/lib/gooddata/commands/base.rb +4 -2
  43. data/lib/gooddata/commands/commands.rb +1 -1
  44. data/lib/gooddata/commands/datasets.rb +20 -7
  45. data/lib/gooddata/commands/domain.rb +23 -0
  46. data/lib/gooddata/commands/process.rb +23 -117
  47. data/lib/gooddata/commands/project.rb +147 -0
  48. data/lib/gooddata/commands/projects.rb +8 -102
  49. data/lib/gooddata/commands/role.rb +26 -0
  50. data/lib/gooddata/commands/runners.rb +41 -38
  51. data/lib/gooddata/commands/scaffold.rb +46 -43
  52. data/lib/gooddata/commands/user.rb +33 -0
  53. data/lib/gooddata/connection.rb +43 -353
  54. data/lib/gooddata/core/connection.rb +389 -0
  55. data/lib/gooddata/core/core.rb +5 -4
  56. data/lib/gooddata/core/logging.rb +48 -0
  57. data/lib/gooddata/core/nil_logger.rb +13 -0
  58. data/lib/gooddata/core/project.rb +70 -0
  59. data/lib/gooddata/core/rest.rb +120 -0
  60. data/lib/gooddata/core/threaded.rb +14 -0
  61. data/lib/gooddata/core/user.rb +19 -0
  62. data/lib/gooddata/data/data.rb +2 -1
  63. data/lib/gooddata/data/guesser.rb +16 -12
  64. data/lib/gooddata/exceptions/command_failed.rb +1 -1
  65. data/lib/gooddata/exceptions/exceptions.rb +2 -1
  66. data/lib/gooddata/exceptions/no_project_error.rb +11 -0
  67. data/lib/gooddata/exceptions/project_not_found.rb +1 -1
  68. data/lib/gooddata/extensions/big_decimal.rb +6 -2
  69. data/lib/gooddata/extract.rb +10 -8
  70. data/lib/gooddata/goodzilla/goodzilla.rb +61 -59
  71. data/lib/gooddata/helpers.rb +15 -9
  72. data/lib/gooddata/models/account_settings.rb +124 -0
  73. data/lib/gooddata/models/attributes/anchor.rb +37 -0
  74. data/lib/gooddata/models/attributes/attributes.rb +8 -0
  75. data/lib/gooddata/models/attributes/date_attribute.rb +25 -0
  76. data/lib/gooddata/models/attributes/time_attribute.rb +24 -0
  77. data/lib/gooddata/models/columns/attribute.rb +71 -0
  78. data/lib/gooddata/models/columns/columns.rb +8 -0
  79. data/lib/gooddata/models/columns/date_column.rb +63 -0
  80. data/lib/gooddata/models/columns/fact_model.rb +54 -0
  81. data/lib/gooddata/models/columns/label.rb +55 -0
  82. data/lib/gooddata/models/columns/reference.rb +57 -0
  83. data/lib/gooddata/models/dashboard_builder.rb +26 -0
  84. data/lib/gooddata/models/data_result.rb +10 -9
  85. data/lib/gooddata/models/domain.rb +131 -0
  86. data/lib/gooddata/models/empty_result.rb +5 -8
  87. data/lib/gooddata/models/facts/facts.rb +8 -0
  88. data/lib/gooddata/models/facts/time_fact.rb +20 -0
  89. data/lib/gooddata/models/folders/attribute_folder.rb +20 -0
  90. data/lib/gooddata/models/folders/fact_folder.rb +20 -0
  91. data/lib/gooddata/models/folders/folders.rb +8 -0
  92. data/lib/gooddata/models/invitation.rb +78 -0
  93. data/lib/gooddata/models/links.rb +6 -6
  94. data/lib/gooddata/models/md_object.rb +25 -0
  95. data/lib/gooddata/models/metadata.rb +160 -62
  96. data/lib/gooddata/models/metadata/attribute.rb +81 -0
  97. data/lib/gooddata/models/metadata/column.rb +61 -0
  98. data/lib/gooddata/models/{dashboard.rb → metadata/dashboard.rb} +12 -7
  99. data/lib/gooddata/models/{data_set.rb → metadata/data_set.rb} +5 -4
  100. data/lib/gooddata/models/metadata/date_dimension.rb +26 -0
  101. data/lib/gooddata/models/metadata/display_form.rb +61 -0
  102. data/lib/gooddata/models/metadata/fact.rb +36 -0
  103. data/lib/gooddata/models/metadata/folder.rb +24 -0
  104. data/lib/gooddata/models/metadata/metadata.rb +8 -0
  105. data/lib/gooddata/models/metadata/metric.rb +197 -0
  106. data/lib/gooddata/models/metadata/report.rb +115 -0
  107. data/lib/gooddata/models/{report_definition.rb → metadata/report_definition.rb} +16 -10
  108. data/lib/gooddata/models/metadata/schema.rb +227 -0
  109. data/lib/gooddata/models/model.rb +38 -1339
  110. data/lib/gooddata/models/models.rb +5 -2
  111. data/lib/gooddata/models/module_constants.rb +29 -0
  112. data/lib/gooddata/models/process.rb +142 -13
  113. data/lib/gooddata/models/profile.rb +4 -6
  114. data/lib/gooddata/models/project.rb +406 -136
  115. data/lib/gooddata/models/project_blueprint.rb +221 -0
  116. data/lib/gooddata/models/project_builder.rb +136 -0
  117. data/lib/gooddata/models/project_creator.rb +138 -0
  118. data/lib/gooddata/models/project_metadata.rb +11 -10
  119. data/lib/gooddata/models/project_role.rb +92 -0
  120. data/lib/gooddata/models/references/date_reference.rb +44 -0
  121. data/lib/gooddata/models/references/references.rb +8 -0
  122. data/lib/gooddata/models/references/time_reference.rb +13 -0
  123. data/lib/gooddata/models/report_data_result.rb +11 -11
  124. data/lib/gooddata/models/schedule.rb +284 -0
  125. data/lib/gooddata/models/schema_blueprint.rb +158 -0
  126. data/lib/gooddata/models/schema_builder.rb +81 -0
  127. data/lib/gooddata/models/tab_builder.rb +23 -0
  128. data/lib/gooddata/models/user.rb +165 -0
  129. data/lib/gooddata/version.rb +1 -1
  130. data/lib/templates/project/data/devs.csv +1 -1
  131. data/lib/templates/project/data/repos.csv +1 -1
  132. data/lib/templates/project/model/model.rb.erb +7 -11
  133. data/spec/bricks/bricks_spec.rb +2 -0
  134. data/spec/data/test-ci-data.csv +2 -0
  135. data/spec/data/test_project_model_spec.json +7 -27
  136. data/spec/helpers/blueprint_helper.rb +2 -0
  137. data/spec/helpers/cli_helper.rb +2 -0
  138. data/spec/helpers/connection_helper.rb +14 -1
  139. data/spec/helpers/project_helper.rb +16 -0
  140. data/spec/helpers/schema_helper.rb +16 -0
  141. data/spec/integration/command_projects_spec.rb +7 -7
  142. data/spec/integration/create_from_template_spec.rb +2 -2
  143. data/spec/integration/full_project_spec.rb +160 -7
  144. data/spec/integration/partial_md_export_import_spec.rb +3 -3
  145. data/spec/logging_in_logging_out_spec.rb +2 -1
  146. data/spec/spec_helper.rb +26 -4
  147. data/spec/unit/bricks/bricks_spec.rb +15 -7
  148. data/spec/unit/bricks/middleware/bench_middleware_spec.rb +2 -0
  149. data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +2 -0
  150. data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +2 -0
  151. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +2 -0
  152. data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +2 -0
  153. data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +2 -0
  154. data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +2 -0
  155. data/spec/unit/cli/cli_spec.rb +2 -0
  156. data/spec/unit/cli/commands/cmd_api_spec.rb +23 -15
  157. data/spec/unit/cli/commands/cmd_auth_spec.rb +8 -4
  158. data/spec/unit/cli/commands/cmd_domain_spec.rb +82 -0
  159. data/spec/unit/cli/commands/cmd_process_spec.rb +29 -13
  160. data/spec/unit/cli/commands/cmd_project_spec.rb +51 -30
  161. data/spec/unit/cli/commands/cmd_role_spec.rb +44 -0
  162. data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +8 -4
  163. data/spec/unit/cli/commands/cmd_scaffold_spec.rb +48 -11
  164. data/spec/unit/cli/commands/cmd_user_spec.rb +29 -0
  165. data/spec/unit/commands/command_api_spec.rb +1 -1
  166. data/spec/unit/commands/command_auth_spec.rb +100 -18
  167. data/spec/unit/commands/command_dataset_spec.rb +4 -0
  168. data/spec/unit/commands/command_process_spec.rb +9 -4
  169. data/spec/unit/commands/command_projects_spec.rb +10 -6
  170. data/spec/unit/commands/command_scaffold_spec.rb +5 -1
  171. data/spec/unit/commands/command_user_spec.rb +22 -0
  172. data/spec/unit/core/connection_spec.rb +35 -6
  173. data/spec/unit/core/logging_spec.rb +65 -0
  174. data/spec/unit/core/nil_logger_spec.rb +9 -0
  175. data/spec/unit/core/project_spec.rb +51 -0
  176. data/spec/unit/core/rest_spec.rb +33 -0
  177. data/spec/unit/data/guesser_spec.rb +5 -0
  178. data/spec/unit/godzilla/goodzilla_spec.rb +2 -0
  179. data/spec/unit/models/account_settings_spec.rb +28 -0
  180. data/spec/unit/models/anchor_spec.rb +32 -0
  181. data/spec/unit/models/attribute_column_spec.rb +7 -0
  182. data/spec/unit/models/domain_spec.rb +45 -0
  183. data/spec/unit/models/invitation_spec.rb +13 -0
  184. data/spec/unit/models/md_object_spec.rb +47 -0
  185. data/spec/unit/models/metric.rb +92 -0
  186. data/spec/unit/{model → models}/model_spec.rb +9 -7
  187. data/spec/unit/models/project_blueprint_spec.rb +202 -0
  188. data/spec/unit/models/project_creator.rb +73 -0
  189. data/spec/unit/models/project_role_spec.rb +90 -0
  190. data/spec/unit/models/project_spec.rb +143 -0
  191. data/spec/unit/models/schedule_spec.rb +491 -0
  192. data/spec/unit/{model → models}/schema_builder_spec.rb +2 -0
  193. data/spec/unit/{model → models}/tools_spec.rb +13 -7
  194. data/spec/unit/models/user_spec.rb +16 -0
  195. data/test/test_upload.rb +2 -0
  196. metadata +189 -86
  197. data/lib/gooddata/commands/profile.rb +0 -11
  198. data/lib/gooddata/models/attribute.rb +0 -29
  199. data/lib/gooddata/models/display_form.rb +0 -9
  200. data/lib/gooddata/models/fact.rb +0 -19
  201. data/lib/gooddata/models/metric.rb +0 -99
  202. data/lib/gooddata/models/report.rb +0 -89
  203. data/spec/data/blueprint_valid.json +0 -37
  204. data/spec/unit/cli/commands/cmd_profile_spec.rb +0 -16
  205. data/spec/unit/commands/command_profile_spec.rb +0 -18
  206. data/spec/unit/core/core_spec.rb +0 -7
  207. data/spec/unit/model/blueprint_spec.rb +0 -132
  208. data/spec/unit/model/project_blueprint_spec.rb +0 -44
@@ -0,0 +1,65 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/core/logging'
4
+
5
+ describe 'GoodData - logging' do
6
+ TEST_MESSAGE = 'Hello World!'
7
+
8
+ def test_error
9
+ GoodData.logger.error TEST_MESSAGE
10
+ end
11
+
12
+ def test_info
13
+ GoodData.logger.info TEST_MESSAGE
14
+ end
15
+
16
+ def test_warn
17
+ GoodData.logger.warn TEST_MESSAGE
18
+ end
19
+
20
+ def test_all
21
+ test_error
22
+ test_info
23
+ test_info
24
+ end
25
+
26
+ before(:each) do
27
+ @is_logging_on = GoodData.logging_on?
28
+
29
+ # TODO: Use some kind of 'reset' instead
30
+ GoodData.logging_on if !@is_logging_on
31
+ end
32
+
33
+ after(:each) do
34
+ GoodData.logging_off if !@is_logging_on
35
+ end
36
+
37
+
38
+ describe '#logging_on' do
39
+ it 'Enables logging' do
40
+ GoodData.logging_on
41
+ test_all
42
+ end
43
+ end
44
+
45
+ describe '#logging_off' do
46
+ it 'Disables logging' do
47
+ GoodData.logging_off
48
+ test_all
49
+ end
50
+ end
51
+
52
+ describe '#logger' do
53
+ it '#error works' do
54
+ test_error
55
+ end
56
+
57
+ it '#info works' do
58
+ test_info
59
+ end
60
+
61
+ it '#warn works' do
62
+ test_warn
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/core/core'
4
+
5
+ describe GoodData::NilLogger do
6
+ it "Has GoodData::NilLogger class" do
7
+ GoodData::NilLogger.should_not be(nil)
8
+ end
9
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/connection'
4
+ require 'gooddata/core/connection'
5
+ require 'gooddata/core/project'
6
+ require 'gooddata/models/project'
7
+
8
+ describe 'GoodData - project' do
9
+ before(:each) do
10
+ ConnectionHelper.create_default_connection
11
+ end
12
+
13
+ after(:each) do
14
+ GoodData.disconnect
15
+ end
16
+
17
+ describe '#project=' do
18
+ it 'Assigns nil' do
19
+ GoodData.project = nil
20
+ end
21
+
22
+ it 'Assigns project using project ID' do
23
+ GoodData.project = ProjectHelper::PROJECT_ID
24
+ end
25
+
26
+ it 'Assigns project using project URL' do
27
+ GoodData.project = ProjectHelper::PROJECT_URL
28
+ end
29
+
30
+ it 'Assigns project directly' do
31
+ GoodData.project = GoodData::Project[ProjectHelper::PROJECT_ID]
32
+ end
33
+ end
34
+
35
+ describe '#project' do
36
+ it 'Returns project assigned' do
37
+ GoodData.project = nil
38
+ GoodData.project.should == nil
39
+
40
+ GoodData.project = ProjectHelper::PROJECT_ID
41
+ GoodData.project.should_not == nil
42
+ end
43
+ end
44
+
45
+ describe '#with_project' do
46
+ it 'Uses project specified' do
47
+ GoodData.with_project GoodData::Project[ProjectHelper::PROJECT_ID] do
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/core/connection'
4
+ require 'gooddata/core/rest'
5
+
6
+ describe GoodData do
7
+ before(:each) do
8
+ ConnectionHelper.create_default_connection
9
+ end
10
+
11
+ after(:each) do
12
+ GoodData.disconnect
13
+ end
14
+
15
+ describe '#get_project_webdav_path' do
16
+ it 'Returns path' do
17
+ GoodData.get_project_webdav_path('test-file.csv')
18
+ end
19
+ end
20
+
21
+ describe '#upload_to_project_webdav' do
22
+ it 'Uploads file' do
23
+ pending('Research how to properly upload file')
24
+ GoodData.upload_to_project_webdav('spec/data/test-ci-data.csv')
25
+ end
26
+ end
27
+
28
+ describe '#get_user_webdav_path' do
29
+ it 'Gets the path' do
30
+ GoodData.get_user_webdav_path('test.csv')
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,9 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'gooddata'
2
4
 
3
5
  describe GoodData::Data::Guesser do
6
+ pending('Guesser needs to be redone. Failing due to rubocop fixes.')
4
7
  it "order LDM types as follows: cp, fact, date, attribute" do
5
8
  expect = [:connection_point, :fact, :date, :attribute]
6
9
  result = GoodData::Data::Guesser::sort_types([:fact, :attribute, :connection_point, :date])
@@ -16,6 +19,8 @@ describe GoodData::Data::Guesser do
16
19
  end
17
20
 
18
21
  it "guess facts, dates and connection points from a simple CSV" do
22
+ pending('Guesser is disabled for now')
23
+
19
24
  csv = [
20
25
  ['cp', 'a1', 'a2', 'd1', 'd2', 'f'],
21
26
  ['1', 'one', 'huh', '2001-01-02', nil, '-1'],
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'gooddata'
2
4
 
3
5
  describe GoodData::SmallGoodZilla do
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+
4
+ require 'gooddata/models/account_settings'
5
+ require 'gooddata/models/domain'
6
+ require 'gooddata/models/project'
7
+
8
+ describe GoodData::AccountSettings do
9
+ before(:all) do
10
+ ConnectionHelper.create_default_connection
11
+ @user = GoodData::Domain.find_user_by_login(ConnectionHelper::DEFAULT_DOMAIN, ConnectionHelper::DEFAULT_USERNAME)
12
+ end
13
+
14
+ after(:all) do
15
+ GoodData.disconnect
16
+ end
17
+
18
+ describe '#projects' do
19
+ it 'Returns user projects as array of GoodData::Project' do
20
+ projects = @user.projects
21
+ expect(projects).to be_an_instance_of(Array)
22
+
23
+ projects.each do |project|
24
+ expect(project).to be_an_instance_of(GoodData::Project)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/attributes/anchor'
4
+
5
+ describe GoodData::Model::Anchor do
6
+ SCHEMA = []
7
+
8
+ describe '#initialize' do
9
+ it 'Creates new instance' do
10
+ instance = GoodData::Model::Anchor.new(nil, SchemaHelper::SCHEMA)
11
+ instance.should_not == nil
12
+ end
13
+ end
14
+
15
+ describe '#table' do
16
+ it 'Returns Table ' do
17
+ instance = GoodData::Model::Anchor.new(nil, SchemaHelper::SCHEMA)
18
+ result = instance.table
19
+ result.should_not == nil
20
+ end
21
+ end
22
+
23
+ describe '#to_maql_create' do
24
+ it 'Returns MAQL string for schema' do
25
+ pending('Not working, investigate')
26
+ instance = GoodData::Model::Anchor.new(nil, SchemaHelper::SCHEMA)
27
+ result = instance.to_maql_create
28
+ result.should_not == nil
29
+ result.should be_an_instance_of(String)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/columns/attribute'
4
+
5
+ describe GoodData::Model::Attribute do
6
+
7
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/domain'
4
+
5
+ describe GoodData::Domain do
6
+ before(:each) do
7
+ ConnectionHelper.create_default_connection
8
+ end
9
+
10
+ after(:each) do
11
+ GoodData.disconnect
12
+ end
13
+
14
+ describe '#add_user' do
15
+ it 'Should add user' do
16
+ GoodData::Domain.add_user(ConnectionHelper::DEFAULT_DOMAIN, "gemtest#{rand(1e6)}@gooddata.com", 'password')
17
+ end
18
+ end
19
+
20
+ describe '#users' do
21
+ it 'Should list users' do
22
+ users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN)
23
+ expect(users).to be_instance_of(Array)
24
+ users.each do |user|
25
+ expect(user).to be_an_instance_of(GoodData::AccountSettings)
26
+ end
27
+ end
28
+
29
+ it 'Accepts pagination options - limit' do
30
+ users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, {:limit =>1})
31
+ expect(users).to be_instance_of(Array)
32
+ users.each do |user|
33
+ expect(user).to be_an_instance_of(GoodData::AccountSettings)
34
+ end
35
+ end
36
+
37
+ it 'Accepts pagination options - offset' do
38
+ users = GoodData::Domain.users(ConnectionHelper::DEFAULT_DOMAIN, {:offset => 1})
39
+ expect(users).to be_instance_of(Array)
40
+ users.each do |user|
41
+ expect(user).to be_an_instance_of(GoodData::AccountSettings)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/invitation'
4
+
5
+ describe GoodData::Invitation do
6
+ before(:each) do
7
+ ConnectionHelper.create_default_connection
8
+ end
9
+
10
+ after(:each) do
11
+ GoodData.disconnect
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/md_object'
4
+
5
+ describe GoodData::Model::MdObject do
6
+ TEST_TITLE = 'Test Title'
7
+ TEST_NAME = 'Test Name'
8
+
9
+ before(:each) do
10
+ @instance = GoodData::Model::MdObject.new()
11
+ @instance.title = TEST_TITLE
12
+ @instance.name = TEST_NAME
13
+ end
14
+
15
+ describe '#initialize' do
16
+ it 'Creates new instance' do
17
+ @instance.should_not == nil
18
+ @instance.should be_an_instance_of(GoodData::Model::MdObject)
19
+ end
20
+ end
21
+
22
+ describe '#visual' do
23
+ it 'Returns visual representation' do
24
+ result = @instance.visual
25
+ result.should_not == nil
26
+ result.should be_an_instance_of(String)
27
+ end
28
+ end
29
+
30
+ describe '#title_esc' do
31
+ it 'Returns escaped title' do
32
+ result = @instance.title_esc
33
+ result.should_not == nil
34
+ result.should be_an_instance_of(String)
35
+ end
36
+ end
37
+
38
+ describe '#identifier' do
39
+ it 'Returns identifier' do
40
+ pending('GoodData::Model::MdObject::type_prefix is not defined')
41
+
42
+ result = @instance.identifier
43
+ result.should_not == nil
44
+ result.should == be_an_instance_of(String)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gooddata/models/metadata/metric'
4
+
5
+ describe GoodData::Metric do
6
+
7
+ RAW_DATA2 = {'metric'=>
8
+ {'content'=>
9
+ {'format'=>'#,##0',
10
+ 'expression'=> 'SELECT SUM([/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/700])'},
11
+ 'meta' =>
12
+ {'author'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
13
+ 'uri'=>'/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/70',
14
+ 'tags'=>'a b cg r t',
15
+ 'created'=>'2014-04-30 22:47:57',
16
+ 'identifier'=>'afo7bx1VakCz',
17
+ 'deprecated'=>'0',
18
+ 'summary'=>'',
19
+ 'title'=>'sum of Lines changed',
20
+ 'category'=>'metric',
21
+ 'updated'=>'2014-05-05 20:00:42',
22
+ 'contributor'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}}
23
+
24
+ RAW_DATA3 = {'metric'=>
25
+ {'content'=>
26
+ {'format'=>'#,##0',
27
+ 'expression'=> 'SELECT SUM([/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/710])'},
28
+ 'meta' =>
29
+ {'author'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
30
+ 'uri'=>'/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/71',
31
+ 'tags'=>'a b cg r t',
32
+ 'created'=>'2014-04-30 22:47:57',
33
+ 'identifier'=>'afo7bx1VakCz',
34
+ 'deprecated'=>'0',
35
+ 'summary'=>'',
36
+ 'title'=>'sum of Lines changed',
37
+ 'category'=>'metric',
38
+ 'updated'=>'2014-05-05 20:00:42',
39
+ 'contributor'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}}
40
+
41
+ USED_METRIC = GoodData::Metric.new(RAW_DATA2)
42
+ UNUSED_METRIC = GoodData::Metric.new(RAW_DATA3)
43
+
44
+ RAW_DATA = {'metric'=>
45
+ {'content'=>
46
+ {'format'=>'#,##0',
47
+ 'expression'=>
48
+ "SELECT SUM([#{USED_METRIC.uri})"},
49
+ 'meta'=>
50
+ {'author'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248',
51
+ 'uri'=>'/gdc/md/ksjy0nr3goz6k8yrpklz97l0mych7nez/obj/252',
52
+ 'tags'=>'a b cg r t',
53
+ 'created'=>'2014-04-30 22:47:57',
54
+ 'identifier'=>'afo7bx1VakCz',
55
+ 'deprecated'=>'0',
56
+ 'summary'=>'',
57
+ 'title'=>'sum of Lines changed',
58
+ 'category'=>'metric',
59
+ 'updated'=>'2014-05-05 20:00:42',
60
+ 'contributor'=>'/gdc/account/profile/4e1e8cacc4989228e0ae531b30853248'}}}
61
+
62
+ before(:each) do
63
+ @instance = GoodData::Metric.new(RAW_DATA)
64
+ end
65
+
66
+ describe '#contain?' do
67
+ it 'should say it contains a depending metric if it does' do
68
+ @instance.contain?(USED_METRIC).should == true
69
+ end
70
+
71
+ it 'should say it contains a depending object which is given as a string if it does' do
72
+ @instance.contain?(USED_METRIC).should == true
73
+ end
74
+
75
+ it 'should be able to replace an object if the object is used in the expression' do
76
+ pending('resolve mutating constant if I init from it')
77
+ end
78
+
79
+ it 'should be able to return an expression of the metric' do
80
+ @instance.expression.should == "SELECT SUM([#{USED_METRIC.uri})"
81
+ end
82
+
83
+ it 'should be able to replace an object if the object is used in the expression' do
84
+ @instance.contain?(USED_METRIC).should == true
85
+ @instance.contain?(UNUSED_METRIC).should == false
86
+ @instance.replace(USED_METRIC, UNUSED_METRIC)
87
+ @instance.contain?(USED_METRIC).should == false
88
+ @instance.contain?(UNUSED_METRIC).should == true
89
+ end
90
+
91
+ end
92
+ end