gooddata 1.1.0-java → 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. checksums.yaml +4 -4
  2. data/.document +0 -0
  3. data/.flayignore +2 -0
  4. data/.travis.yml +24 -7
  5. data/.yardopts +0 -0
  6. data/CHANGELOG.md +144 -0
  7. data/CLI.md +0 -0
  8. data/Dockerfile.jruby +7 -2
  9. data/Dockerfile.ruby +1 -1
  10. data/Gemfile +0 -0
  11. data/Guardfile +0 -0
  12. data/Rakefile +23 -9
  13. data/TODO.md +0 -0
  14. data/bin/gitflow-init.sh +8 -0
  15. data/ci.rake +3 -3
  16. data/data/2008.crt +39 -0
  17. data/data/new_ca.cer +22 -0
  18. data/dependency_decisions.yml +0 -0
  19. data/docker-compose.lcm.yml +31 -0
  20. data/docker-compose.yml +4 -2
  21. data/gooddata.gemspec +3 -3
  22. data/lcm.rake +288 -0
  23. data/lib/gooddata.rb +1 -0
  24. data/lib/gooddata/bricks/base_downloader.rb +1 -1
  25. data/lib/gooddata/bricks/brick.rb +0 -1
  26. data/lib/gooddata/bricks/middleware/aws_middleware.rb +1 -1
  27. data/lib/gooddata/bricks/middleware/logger_middleware.rb +1 -1
  28. data/lib/gooddata/bricks/pipeline.rb +67 -0
  29. data/lib/gooddata/bricks/provisioning_brick.rb +18 -0
  30. data/lib/gooddata/bricks/release_brick.rb +18 -0
  31. data/lib/gooddata/bricks/rollout_brick.rb +14 -0
  32. data/lib/gooddata/bricks/user_filters_brick.rb +13 -0
  33. data/lib/gooddata/bricks/users_brick.rb +13 -0
  34. data/lib/gooddata/core/logging.rb +1 -1
  35. data/lib/gooddata/exceptions/maql_execution.rb +1 -1
  36. data/lib/gooddata/extensions/string.rb +0 -0
  37. data/lib/gooddata/lcm/actions/associate_clients.rb +34 -8
  38. data/lib/gooddata/lcm/actions/collect_data_product.rb +8 -1
  39. data/lib/gooddata/lcm/actions/collect_segment_clients.rb +13 -23
  40. data/lib/gooddata/lcm/actions/collect_segments.rb +10 -0
  41. data/lib/gooddata/lcm/actions/synchronize_clients.rb +3 -1
  42. data/lib/gooddata/lcm/actions/synchronize_ldm.rb +61 -34
  43. data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +6 -4
  44. data/lib/gooddata/lcm/actions/update_release_table.rb +4 -12
  45. data/lib/gooddata/lcm/dsl/params_dsl.rb +0 -4
  46. data/lib/gooddata/lcm/dsl/type_dsl.rb +0 -4
  47. data/lib/gooddata/lcm/helpers/check_helper.rb +1 -1
  48. data/lib/gooddata/lcm/lcm2.rb +0 -2
  49. data/lib/gooddata/lcm/types/special/enum.rb +6 -0
  50. data/lib/gooddata/lcm/types/special/enum/synchronize_ldm.rb +20 -0
  51. data/lib/gooddata/lcm/types/special/types.rb +1 -1
  52. data/lib/gooddata/mixins/is_folder.rb +0 -0
  53. data/lib/gooddata/mixins/to_json.rb +0 -0
  54. data/lib/gooddata/mixins/uri_getter.rb +0 -0
  55. data/lib/gooddata/models/project_creator.rb +38 -30
  56. data/lib/gooddata/models/user_filters/user_filter_builder.rb +1 -0
  57. data/lib/gooddata/rest/README.md +0 -0
  58. data/lib/gooddata/version.rb +1 -1
  59. data/lib/templates/bricks/brick.rb.erb +0 -0
  60. data/lib/templates/bricks/main.rb.erb +0 -0
  61. data/lib/templates/project/Goodfile.erb +0 -0
  62. data/lib/templates/project/data/commits.csv +0 -0
  63. data/lib/templates/project/data/devs.csv +0 -0
  64. data/lib/templates/project/data/repos.csv +0 -0
  65. data/lib/templates/project/model/model.rb.erb +0 -0
  66. metadata +23 -452
  67. data/lib/gooddata/lcm/actions/ensure_data_product.rb +0 -63
  68. data/spec/.rubocop.yml +0 -16
  69. data/spec/bricks/bricks_spec.rb +0 -110
  70. data/spec/bricks/default-config.json +0 -8
  71. data/spec/data/.gooddata +0 -4
  72. data/spec/data/blueprints/additional_dataset_module.json +0 -32
  73. data/spec/data/blueprints/attribute_sort_order_blueprint.json +0 -72
  74. data/spec/data/blueprints/big_blueprint_not_pruned.json +0 -2079
  75. data/spec/data/blueprints/invalid_blueprint.json +0 -103
  76. data/spec/data/blueprints/m_n_model.json +0 -104
  77. data/spec/data/blueprints/model_module.json +0 -25
  78. data/spec/data/blueprints/test_blueprint.json +0 -39
  79. data/spec/data/blueprints/test_project_model_spec.json +0 -106
  80. data/spec/data/cc/data/source/commits.csv +0 -4
  81. data/spec/data/cc/data/source/devs.csv +0 -4
  82. data/spec/data/cc/data/source/repos.csv +0 -3
  83. data/spec/data/cc/devel.prm +0 -0
  84. data/spec/data/cc/graph/graph.grf +0 -11
  85. data/spec/data/cc/workspace.prm +0 -19
  86. data/spec/data/column_based_permissions.csv +0 -7
  87. data/spec/data/column_based_permissions2.csv +0 -6
  88. data/spec/data/dynamic_schedule_params_table.csv +0 -7
  89. data/spec/data/gd_gse_data_blueprint.json +0 -1371
  90. data/spec/data/gd_gse_data_manifest.json +0 -1424
  91. data/spec/data/gd_gse_data_model.json +0 -1772
  92. data/spec/data/gooddata_version_process/gooddata_version.rb +0 -9
  93. data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
  94. data/spec/data/hello_world_process/hello_world.rb +0 -9
  95. data/spec/data/hello_world_process/hello_world.zip +0 -0
  96. data/spec/data/integration_model.json +0 -252
  97. data/spec/data/integration_policies.csv +0 -9134
  98. data/spec/data/line_based_permissions.csv +0 -3
  99. data/spec/data/manifests/test_blueprint.json +0 -32
  100. data/spec/data/manifests/test_project.json +0 -107
  101. data/spec/data/reports/left_attr_report.json +0 -108
  102. data/spec/data/reports/metric_only_one_line.json +0 -83
  103. data/spec/data/reports/report_1.json +0 -197
  104. data/spec/data/reports/top_attr_report.json +0 -108
  105. data/spec/data/ruby_params_process/ruby_params.rb +0 -9
  106. data/spec/data/ruby_process/deep_files/deep_stuff.txt +0 -1
  107. data/spec/data/ruby_process/process.rb +0 -8
  108. data/spec/data/ruby_process/stuff.txt +0 -1
  109. data/spec/data/superfluous_titles_view.json +0 -81
  110. data/spec/data/test-ci-data.csv +0 -2
  111. data/spec/data/user_filters.csv +0 -2
  112. data/spec/data/users.csv +0 -12
  113. data/spec/data/wire_models/attribute_sort_by_model.json +0 -73
  114. data/spec/data/wire_models/model_view.json +0 -1775
  115. data/spec/data/wire_models/nu_model.json +0 -3046
  116. data/spec/data/wire_models/test_blueprint.json +0 -66
  117. data/spec/data/wire_test_project.json +0 -150
  118. data/spec/data/workspace_table.csv +0 -3
  119. data/spec/environment/default.rb +0 -43
  120. data/spec/environment/development.rb +0 -32
  121. data/spec/environment/environment.rb +0 -38
  122. data/spec/environment/production.rb +0 -27
  123. data/spec/environment/staging.rb +0 -32
  124. data/spec/environment/testing.rb +0 -32
  125. data/spec/helpers/appstore_project_helper.rb +0 -221
  126. data/spec/helpers/blueprint_helper.rb +0 -27
  127. data/spec/helpers/cli_helper.rb +0 -38
  128. data/spec/helpers/connection_helper.rb +0 -43
  129. data/spec/helpers/constants.rb +0 -32
  130. data/spec/helpers/crypto_helper.rb +0 -19
  131. data/spec/helpers/csv_helper.rb +0 -20
  132. data/spec/helpers/process_helper.rb +0 -35
  133. data/spec/helpers/project_helper.rb +0 -74
  134. data/spec/helpers/schedule_helper.rb +0 -33
  135. data/spec/helpers/spec_helper.rb +0 -17
  136. data/spec/integration/ads_output_stage_spec.rb +0 -45
  137. data/spec/integration/blueprint_updates_spec.rb +0 -107
  138. data/spec/integration/blueprint_with_ca_spec.rb +0 -56
  139. data/spec/integration/blueprint_with_grain_spec.rb +0 -74
  140. data/spec/integration/channel_configuration_spec.rb +0 -67
  141. data/spec/integration/clients_spec.rb +0 -164
  142. data/spec/integration/command_datawarehouse_spec.rb +0 -45
  143. data/spec/integration/command_projects_spec.rb +0 -32
  144. data/spec/integration/commands/command_projects_spec.rb +0 -22
  145. data/spec/integration/connection_spec.rb +0 -37
  146. data/spec/integration/core/connection_spec.rb +0 -56
  147. data/spec/integration/core/logging_spec.rb +0 -132
  148. data/spec/integration/core/project_spec.rb +0 -54
  149. data/spec/integration/create_from_template_spec.rb +0 -29
  150. data/spec/integration/create_project_spec.rb +0 -27
  151. data/spec/integration/date_dim_switch_spec.rb +0 -154
  152. data/spec/integration/deprecated_load_spec.rb +0 -60
  153. data/spec/integration/full_process_schedule_spec.rb +0 -367
  154. data/spec/integration/full_project_spec.rb +0 -592
  155. data/spec/integration/helpers_spec.rb +0 -16
  156. data/spec/integration/lcm_spec.rb +0 -54
  157. data/spec/integration/mandatory_user_filter_spec.rb +0 -53
  158. data/spec/integration/mixins/id_to_uri_spec.rb +0 -56
  159. data/spec/integration/models/data_product_spec.rb +0 -71
  160. data/spec/integration/models/domain_spec.rb +0 -162
  161. data/spec/integration/models/invitation_spec.rb +0 -17
  162. data/spec/integration/models/label_spec.rb +0 -49
  163. data/spec/integration/models/membership_spec.rb +0 -127
  164. data/spec/integration/models/metadata/report_spec.rb +0 -54
  165. data/spec/integration/models/metric_spec.rb +0 -24
  166. data/spec/integration/models/params_spec.rb +0 -118
  167. data/spec/integration/models/process_spec.rb +0 -35
  168. data/spec/integration/models/profile_spec.rb +0 -210
  169. data/spec/integration/models/project_role_spec.rb +0 -94
  170. data/spec/integration/models/project_spec.rb +0 -225
  171. data/spec/integration/models/schedule_spec.rb +0 -477
  172. data/spec/integration/models/unit_project_spec.rb +0 -130
  173. data/spec/integration/over_to_user_filters_spec.rb +0 -98
  174. data/spec/integration/partial_md_export_import_spec.rb +0 -41
  175. data/spec/integration/project_spec.rb +0 -381
  176. data/spec/integration/rest_spec.rb +0 -214
  177. data/spec/integration/schedule_spec.rb +0 -611
  178. data/spec/integration/segments_spec.rb +0 -100
  179. data/spec/integration/subscription_spec.rb +0 -88
  180. data/spec/integration/urn_date_dim_spec.rb +0 -53
  181. data/spec/integration/user_filters_spec.rb +0 -310
  182. data/spec/integration/user_group_spec.rb +0 -147
  183. data/spec/integration/variables_spec.rb +0 -189
  184. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/can_assign_a_custom_logger.yml +0 -2287
  185. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/client_logs_when_given_custom_message.yml +0 -2287
  186. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/has_the_request_id_logged_when_I_passed_it.yml +0 -2287
  187. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_off/Disables_logging.yml +0 -2287
  188. data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_on/Enables_logging.yml +0 -2287
  189. data/spec/integration/vcr_cassettes/GoodData_-_project/_project/Returns_project_assigned.yml +0 -354
  190. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_nil.yml +0 -299
  191. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_directly.yml +0 -354
  192. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_ID.yml +0 -354
  193. data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_URL.yml +0 -354
  194. data/spec/integration/vcr_cassettes/GoodData_-_project/_with_project/Uses_project_specified.yml +0 -354
  195. data/spec/integration/vcr_cassettes/GoodData_Metric/all.yml +0 -2065
  196. data/spec/integration/vcr_cassettes/GoodData_Metric/should_be_able_to_update_folders.yml +0 -119
  197. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/all.yml +0 -9812
  198. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_get_json_containing_correct_id.yml +0 -174
  199. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_return_nil_for_unknown_id.yml +0 -58
  200. data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_throw_BadRequest_for_-1.yml +0 -63
  201. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_connect/Connects_using_username_and_password.yml +0 -299
  202. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_disconnect/Connects_using_username_and_password.yml +0 -299
  203. data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_generate_request_id/Generates_a_non-empty_string.yml +0 -2287
  204. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_/Should_list_user_groups_as_Array.yml +0 -56
  205. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_add_members/Should_add_member.yml +0 -315
  206. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_members/Should_return_members_as_array.yml +0 -54
  207. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_remove_members/Should_remove_existing_members.yml +0 -258
  208. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_save/updates_existing_group.yml +0 -159
  209. data/spec/integration/vcr_cassettes/GoodData_UserGroup/_set_members/Should_set_new_members.yml +0 -158
  210. data/spec/integration/vcr_cassettes/GoodData_UserGroup/all.yml +0 -809
  211. data/spec/logging_in_logging_out_spec.rb +0 -91
  212. data/spec/spec_helper.rb +0 -110
  213. data/spec/unit/actions/associate_clients_spec.rb +0 -48
  214. data/spec/unit/actions/collect_client_projects_spec.rb +0 -47
  215. data/spec/unit/actions/collect_clients_spec.rb +0 -65
  216. data/spec/unit/actions/collect_data_product_spec.rb +0 -58
  217. data/spec/unit/actions/collect_dynamic_schedule_params_spec.rb +0 -56
  218. data/spec/unit/actions/collect_meta_spec.rb +0 -88
  219. data/spec/unit/actions/collect_segment_clients_spec.rb +0 -82
  220. data/spec/unit/actions/collect_tagged_objects_spec.rb +0 -126
  221. data/spec/unit/actions/collect_users_brick_users_spec.rb +0 -36
  222. data/spec/unit/actions/create_segment_masters_spec.rb +0 -65
  223. data/spec/unit/actions/ensure_data_product_spec.rb +0 -39
  224. data/spec/unit/actions/ensure_technical_users_domain_spec.rb +0 -53
  225. data/spec/unit/actions/ensure_technical_users_project_spec.rb +0 -76
  226. data/spec/unit/actions/execute_schedules_spec.rb +0 -94
  227. data/spec/unit/actions/provision_clients_spec.rb +0 -46
  228. data/spec/unit/actions/purge_clients_spec.rb +0 -47
  229. data/spec/unit/actions/rename_existing_client_projects_spec.rb +0 -54
  230. data/spec/unit/actions/segments_filter_spec.rb +0 -46
  231. data/spec/unit/actions/shared_examples_for_user_actions.rb +0 -43
  232. data/spec/unit/actions/synchronize_cas_spec.rb +0 -58
  233. data/spec/unit/actions/synchronize_clients_spec.rb +0 -71
  234. data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +0 -206
  235. data/spec/unit/actions/synchronize_ldm_spec.rb +0 -70
  236. data/spec/unit/actions/synchronize_user_filters_spec.rb +0 -208
  237. data/spec/unit/actions/synchronize_user_groups_spec.rb +0 -49
  238. data/spec/unit/actions/synchronize_users_spec.rb +0 -180
  239. data/spec/unit/bricks/bricks_spec.rb +0 -34
  240. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +0 -98
  241. data/spec/unit/bricks/middleware/bench_middleware_spec.rb +0 -15
  242. data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +0 -15
  243. data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +0 -15
  244. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +0 -30
  245. data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +0 -15
  246. data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +0 -15
  247. data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +0 -15
  248. data/spec/unit/cli/cli_spec.rb +0 -17
  249. data/spec/unit/cli/commands/cmd_auth_spec.rb +0 -17
  250. data/spec/unit/core/nil_logger_spec.rb +0 -13
  251. data/spec/unit/extensions/hash_spec.rb +0 -22
  252. data/spec/unit/godzilla/goodzilla_spec.rb +0 -74
  253. data/spec/unit/helpers/check_helper_production_spec.rb +0 -34
  254. data/spec/unit/helpers/check_helper_spec.rb +0 -134
  255. data/spec/unit/helpers/csv_helper_spec.rb +0 -22
  256. data/spec/unit/helpers/data_helper_spec.rb +0 -67
  257. data/spec/unit/helpers/global_helpers_spec.rb +0 -264
  258. data/spec/unit/helpers_spec.rb +0 -254
  259. data/spec/unit/lcm/lcm2_spec.rb +0 -100
  260. data/spec/unit/lcm/user_bricks_helper_spec.rb +0 -58
  261. data/spec/unit/models/blueprint/attribute_sort_by_spec.rb +0 -20
  262. data/spec/unit/models/blueprint/attributes_spec.rb +0 -28
  263. data/spec/unit/models/blueprint/dataset_spec.rb +0 -120
  264. data/spec/unit/models/blueprint/label_blueprint_field_spec.rb +0 -43
  265. data/spec/unit/models/blueprint/project_blueprint_spec.rb +0 -642
  266. data/spec/unit/models/blueprint/reference_spec.rb +0 -28
  267. data/spec/unit/models/blueprint/schema_builder_spec.rb +0 -36
  268. data/spec/unit/models/blueprint/to_wire_spec.rb +0 -196
  269. data/spec/unit/models/dataset_blueprint.rb +0 -14
  270. data/spec/unit/models/execution_spec.rb +0 -109
  271. data/spec/unit/models/from_wire_spec.rb +0 -321
  272. data/spec/unit/models/metadata_spec.rb +0 -140
  273. data/spec/unit/models/metric_spec.rb +0 -129
  274. data/spec/unit/models/model_spec.rb +0 -87
  275. data/spec/unit/models/project_creator_spec.rb +0 -90
  276. data/spec/unit/models/project_spec.rb +0 -94
  277. data/spec/unit/models/report_result_data_spec.rb +0 -194
  278. data/spec/unit/models/to_manifest_spec.rb +0 -165
  279. data/spec/unit/models/user_filters/user_filter_builder_spec.rb +0 -149
  280. data/spec/unit/models/user_filters_spec.rb +0 -95
  281. data/spec/unit/models/variable_spec.rb +0 -280
  282. data/spec/unit/rest/phmap_spec.rb +0 -117
  283. data/spec/unit/rest/polling_spec.rb +0 -101
  284. data/spec/unit/rest/resource_spec.rb +0 -10
  285. data/spec/vcr_configurer.rb +0 -63
@@ -1,60 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'gooddata'
8
-
9
- describe "Full project implementation", :constraint => 'slow' do
10
- before(:all) do
11
- @client = ConnectionHelper.create_default_connection
12
- @blueprint = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
13
- p.add_dataset("dataset.repos") do |d|
14
- d.add_anchor("attr.repository")
15
- d.add_label('label.repository.name', reference: 'attr.repository')
16
- d.add_attribute("attr.attribute1", title: 'Some attribute')
17
- d.add_label('label.attribute1.name', reference: 'attr.attribute1')
18
- d.add_fact('some_numbers', gd_data_type: 'INT')
19
- end
20
- end
21
-
22
- @project = @client.create_project_from_blueprint(@blueprint, token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
23
- end
24
-
25
- after(:all) do
26
- @project.delete unless @project.nil?
27
- @client.disconnect
28
- end
29
-
30
- it 'should upload data using local blueprint' do
31
- devs_data = [
32
- ["label.repository.name", "label.attribute1.name", "some_numbers"],
33
- [1, "tomas@gooddata.com", 10],
34
- [2, "petr@gooddata.com", 20],
35
- [3, "jirka@gooddata.com", 30]
36
- ]
37
- @project.upload(devs_data, @blueprint, 'dataset.repos')
38
- vals = @project.labels('label.repository.name').values.to_a.map { |label| label[:value] }
39
- expect(vals).to eq %w(1 2 3)
40
- end
41
-
42
- it 'should upload the data when you deprecate attribute with remote blueprint' do
43
- l = @project.labels('label.repository.name')
44
- l.deprecated = true
45
- l.save
46
- b = @project.labels(l.identifier)
47
- expect(b.deprecated?).to be_truthy
48
-
49
- devs_data = [
50
- ["label.repository.name", "label.attribute1.name", "some_numbers"],
51
- [1, "tomas@gooddata.com", 10],
52
- [2, "petr@gooddata.com", 20],
53
- [3, "jirka@gooddata.com", 30],
54
- [4, "jindrich@gooddata.com", 40]
55
- ]
56
- @project.upload(devs_data, @project.blueprint, 'dataset.repos')
57
- vals = @project.labels('label.repository.name').values.to_a.map { |label| label[:value] }
58
- expect(vals).to eq %w(1 2 3 4)
59
- end
60
- end
@@ -1,367 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'gooddata'
8
-
9
- describe "Full process and schedule exercise", :constraint => 'slow' do
10
- COMPLEX_PARAMS ||= {
11
- type: 'Person',
12
- model_version: 1,
13
- data_version: 1.5,
14
- some_true_flag: true,
15
- some_false_flag: false,
16
- empty_value: nil,
17
- user: {
18
- firstname: 'Joe',
19
- lastname: 'Doe',
20
- age: 42
21
- },
22
- address: {
23
- street: '#111 Sutter St.',
24
- city: 'San Francisco',
25
- zip: '94133'
26
- }
27
- }
28
-
29
- before(:all) do
30
- @client = ConnectionHelper.create_default_connection
31
- @project = @client.create_project(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
32
- @process = @project.deploy_process('./spec/data/ruby_process',
33
- type: 'RUBY',
34
- name: 'Test ETL Process (Ruby)')
35
-
36
- @process_cc = @project.deploy_process('./spec/data/cc',
37
- type: 'graph',
38
- name: 'Test ETL Process (CC)')
39
- end
40
-
41
- after(:all) do
42
- ScheduleHelper.remove_old_schedules(@project)
43
- ProcessHelper.remove_old_processes(@project)
44
-
45
- # @process.delete if @process
46
- @project.delete if @project
47
- GoodData::ChannelConfiguration.all.map(&:delete)
48
-
49
- @client.disconnect
50
- end
51
-
52
- it "should be able to execute a process" do
53
- result = @process.execute(@process.executables.first)
54
- log = result.log
55
- expect(log.index('Hello Ruby executors')).not_to eq nil
56
- expect(log.index('Hello Ruby from the deep')).not_to eq nil
57
- end
58
-
59
- it "should be able to start executing a process" do
60
- result = @process.start_execution(@process.executables.first)
61
- expect(result["executionTask"]).not_to be_nil
62
- expect(result["executionTask"]['links']['detail']).not_to be_nil
63
- end
64
-
65
- it "should be able to grab executables" do
66
- expect(@process.executables).to eq ['process.rb']
67
- end
68
-
69
- it "should have empty schedules on deploy" do
70
- expect(@process.schedules).to eq []
71
- end
72
-
73
- it "should be able to create schedule triggered by another schedule" do
74
- begin
75
- schedule_first = @process.create_schedule('0 15 27 7 *', @process.executables.first)
76
- schedule = @process.create_schedule(schedule_first, @process.executables.first)
77
- res = @process.schedules
78
- expect(res.count).to eq 2
79
- expect(@process.schedules.map(&:uri)).to include(schedule_first.uri, schedule.uri)
80
- ensure
81
- schedule && schedule.delete
82
- schedule_first && schedule_first.delete
83
- end
84
- end
85
-
86
- it "should be able to create schedule triggered by another schedule specified by ID" do
87
- begin
88
- schedule_first = @process.create_schedule('0 15 27 7 *', @process.executables.first)
89
- schedule = @process.create_schedule(schedule_first.obj_id, @process.executables.first)
90
- res = @process.schedules
91
- expect(res.count).to eq 2
92
- expect(schedule.after).to eq schedule_first
93
- expect(@process.schedules.map(&:uri)).to include(schedule_first.uri, schedule.uri)
94
- ensure
95
- schedule && schedule.delete
96
- schedule_first && schedule_first.delete
97
- end
98
- end
99
-
100
- it "should be able to delete schedule" do
101
- begin
102
- schedule = @process.create_schedule('0 15 27 7 *', @process.executables.first)
103
- res = @process.schedules
104
- expect(res.count).to eq 1
105
- expect(@process.schedules).to eq [schedule]
106
- ensure
107
- schedule && schedule.delete
108
- end
109
- end
110
-
111
- it "should be possible to read status of schedule" do
112
- begin
113
- schedule = @process.create_schedule('0 15 27 7 *', @process.executables.first)
114
- expect(schedule.state).to eq 'ENABLED'
115
- ensure
116
- schedule && schedule.delete
117
- end
118
- end
119
-
120
- it "should be possible to execute schedule" do
121
- begin
122
- schedule = @process.create_schedule('0 15 27 7 *', @process.executables.first)
123
- executions_count = schedule.executions.count
124
- result = schedule.execute
125
- expect(result.status).to eq :ok
126
- log = result.log
127
- expect(log.index('Hello Ruby executors')).not_to eq nil
128
- expect(log.index('Hello Ruby from the deep')).not_to eq nil
129
- expect(executions_count + 1).to eq schedule.executions.count
130
- ensure
131
- schedule && schedule.delete
132
- end
133
- end
134
-
135
- it "should be possible to deploy only a single file" do
136
- process = @project.deploy_process('./spec/data/hello_world_process/hello_world.rb',
137
- type: 'RUBY',
138
- name: 'Test ETL one file Process')
139
- begin
140
- schedule = process.create_schedule('0 15 27 7 *', process.executables.first)
141
- result = schedule.execute
142
- expect(result.status).to eq :ok
143
- log = result.log
144
- expect(log.index('HELLO WORLD')).not_to eq nil
145
- expect(schedule.enabled?).to be_truthy
146
- schedule.disable
147
- schedule.save
148
- expect(schedule.enabled?).to be_falsey
149
- expect(schedule.disabled?).to be_truthy
150
- schedule.enable
151
- schedule.save
152
- expect(schedule.enabled?).to be_truthy
153
- ensure
154
- schedule && schedule.delete
155
- process && process.delete
156
- end
157
- end
158
-
159
- it "should be possible to deploy already zipped file" do
160
- process = @project.deploy_process('./spec/data/hello_world_process/hello_world.zip',
161
- type: 'RUBY',
162
- name: 'Test ETL zipped file Process')
163
- begin
164
- expect(process.schedules.count).to eq 0
165
- schedule = process.create_schedule('0 15 27 7 *', process.executables.first)
166
- result = schedule.execute
167
- expect(result.status).to eq :ok
168
- log = result.log
169
- expect(log.index('HELLO WORLD')).not_to eq nil
170
- expect(process.schedules.count).to eq 1
171
- ensure
172
- schedule && schedule.delete
173
- process && process.delete
174
- end
175
- end
176
-
177
- it 'should be possible to deploy and run zipped file and print GoodData::VERSION' do
178
- process = @project.deploy_process('./spec/data/gooddata_version_process/gooddata_version.zip',
179
- type: 'RUBY',
180
- name: 'Test ETL zipped file GoodData Process')
181
- begin
182
- expect(process.schedules.count).to eq 0
183
- schedule = process.create_schedule('0 15 27 7 *', process.executables.first)
184
- result = schedule.execute
185
- expect(result.status).to eq :ok
186
- log = result.log
187
- expect(log.index('GoodData::VERSION - 0.6.')).not_to eq nil
188
- expect(process.schedules.count).to eq 1
189
- ensure
190
- schedule && schedule.delete
191
- process && process.delete
192
- end
193
- end
194
-
195
- it 'should be possible to deploy and run directory and use nested parameters' do
196
- process = @project.deploy_process('./spec/data/ruby_params_process',
197
- type: 'RUBY',
198
- name: 'Test ETL dir GoodData Process')
199
- begin
200
- expect(process.schedules.count).to eq 0
201
- schedule = process.create_schedule('0 15 27 7 *', process.executables.first, params: COMPLEX_PARAMS)
202
- result = schedule.execute
203
- expect(result.status).to eq :ok
204
- log = result.log
205
- expect(log.index('Joe')).not_to eq nil
206
- expect(log.index('San Francisco')).not_to eq nil
207
- expect(process.schedules.count).to eq 1
208
- ensure
209
- schedule && schedule.delete
210
- process && process.delete
211
- end
212
- end
213
-
214
- it 'should be possible to deploy and run directory and use nested hidden parameters' do
215
- process = @project.deploy_process('./spec/data/ruby_params_process',
216
- type: 'RUBY',
217
- name: 'Test ETL dir GoodData Process')
218
- begin
219
- expect(process.schedules.count).to eq 0
220
- schedule = process.create_schedule('0 15 27 7 *', process.executables.first, hidden_params: COMPLEX_PARAMS)
221
- result = schedule.execute
222
- # expect(result.status).to eq :ok
223
- result.log
224
- expect(process.schedules.count).to eq 1
225
- ensure
226
- schedule && schedule.delete
227
- process && process.delete
228
- end
229
- end
230
-
231
- it "should be possible to download deployed process" do
232
- size = File.size('./spec/data/hello_world_process/hello_world.zip')
233
- process = @project.deploy_process('./spec/data/hello_world_process/hello_world.zip',
234
- type: 'RUBY',
235
- name: 'Test ETL zipped file Process')
236
- begin
237
- Tempfile.open('downloaded-process') do |temp|
238
- temp << process.download
239
- temp.flush
240
- expect(File.size(temp.path)).to eq size
241
- end
242
- ensure
243
- process && process.delete
244
- end
245
- end
246
-
247
- it "should be able to redeploy via project" do
248
- begin
249
- process = @project.deploy_process('./spec/data/hello_world_process/hello_world.zip',
250
- type: 'RUBY',
251
- name: 'Test ETL zipped file Process',
252
- process_id: @process.obj_id)
253
- ensure
254
- process && process.delete
255
- end
256
- end
257
-
258
- it "should be able to redeploy directly" do
259
- begin
260
- process1 = @project.deploy_process(
261
- './spec/data/hello_world_process/hello_world.zip',
262
- type: 'RUBY',
263
- name: 'Test ETL zipped file Process'
264
- )
265
-
266
- process2 = process1.deploy('./spec/data/ruby_process/process.rb')
267
- expect(process1.executables).not_to eq process2.executables
268
- ensure
269
- process1 && process1.delete
270
- end
271
- end
272
-
273
- it 'should be able to deploy from app_store' do
274
- begin
275
- process = @project.deploy_process('${PRODUCTION_APPSTORE}:branch/master:/apps/hello_world_brick', name: 'hello_world_brick')
276
- expect(process.class).to eq GoodData::Process
277
- ensure
278
- process.delete if process
279
- end
280
- end
281
-
282
- it 'should be able to clone with etl' do
283
- begin
284
- # Deploy two schedules
285
- process = @project.processes.first
286
- schedule_first = process.create_schedule('0 15 27 7 *', process.executables.first)
287
- schedule_second = process.create_schedule('0 15 27 8 *', process.executables.first)
288
- cloned_project = GoodData::Project.clone_with_etl(@project, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
289
- a = @project.processes.flat_map { |p| p.schedules.map { |s| [p.name, s.name] } }
290
- b = cloned_project.processes.flat_map { |p| p.schedules.map { |s| [p.name, s.name] } }
291
- expect(a).to eq b
292
- ensure
293
- cloned_project && cloned_project.delete
294
- schedule_first && schedule_first.delete
295
- schedule_second && schedule_second.delete
296
- end
297
- end
298
-
299
- it 'should have no notification when creating a new process' do
300
- begin
301
- process = @project.deploy_process('./spec/data/ruby_params_process', type: 'RUBY', name: 'Ruby params process')
302
- expect(process.notification_rules).to eq []
303
- ensure
304
- process && process.delete
305
- end
306
- end
307
-
308
- it 'should be able to add a notification rule' do
309
- begin
310
- process = @project.deploy_process('./spec/data/ruby_params_process', type: 'RUBY', name: 'Ruby params process')
311
- old_notification_rules = process.notification_rules
312
- notification_rule = process.create_notification_rule(email: ConnectionHelper::DEFAULT_USERNAME, events: GoodData::Subscription::PROCESS_SUCCESS_EVENT)
313
- expect(notification_rule.class).to be GoodData::NotificationRule
314
- expect(old_notification_rules).not_to include(notification_rule)
315
- new_notification_rules = process.notification_rules
316
- expect(new_notification_rules).to include(notification_rule)
317
- expect(old_notification_rules.length + 1).to eq new_notification_rules.length
318
- ensure
319
- notification_rule && notification_rule.delete
320
- process && process.delete
321
- end
322
- end
323
-
324
- it 'should be able to remove a notification rule' do
325
- begin
326
- process = @project.deploy_process('./spec/data/ruby_params_process', type: 'RUBY', name: 'Ruby params process')
327
- old_notification_rules = process.notification_rules
328
- notification_rule = process.create_notification_rule(email: ConnectionHelper::DEFAULT_USERNAME, events: GoodData::Subscription::PROCESS_SUCCESS_EVENT)
329
- notification_rule.delete
330
- new_notification_rules = process.notification_rules
331
- expect(new_notification_rules).to eq old_notification_rules
332
- ensure
333
- process && process.delete
334
- end
335
- end
336
-
337
- it 'should be able to edit a notification rule' do
338
- begin
339
- process = @project.deploy_process('./spec/data/ruby_params_process', type: 'RUBY', name: 'Ruby params process')
340
- notification_rule = process.create_notification_rule(email: ConnectionHelper::DEFAULT_USERNAME, events: GoodData::Subscription::PROCESS_SUCCESS_EVENT)
341
- expect(notification_rule.email).to eq ConnectionHelper::DEFAULT_USERNAME
342
- expect(notification_rule.subject).to eq 'Email subject'
343
- expect(notification_rule.body).to eq 'Email body'
344
- expect(notification_rule.events).to eq [GoodData::Subscription::PROCESS_SUCCESS_EVENT]
345
-
346
- notification_rule = GoodData::NotificationRule[notification_rule.notification_rule_id, project: @project, process: process, client: @client]
347
- notification_rule.events = [GoodData::Subscription::PROCESS_SUCCESS_EVENT, GoodData::Subscription::PROCESS_STARTED_EVENT]
348
- notification_rule.save
349
-
350
- expect(process.notification_rules.first.events).to eq [GoodData::Subscription::PROCESS_SUCCESS_EVENT, GoodData::Subscription::PROCESS_STARTED_EVENT]
351
- ensure
352
- notification_rule && notification_rule.delete
353
- process && process.delete
354
- end
355
- end
356
-
357
- it 'should be able to get all notification rules' do
358
- begin
359
- process = @project.deploy_process('./spec/data/ruby_params_process', type: 'RUBY', name: 'Ruby params process')
360
- notification_rule = process.create_notification_rule(email: ConnectionHelper::DEFAULT_USERNAME, events: GoodData::Subscription::PROCESS_SUCCESS_EVENT)
361
- expect(process.notification_rules).to eq [notification_rule]
362
- ensure
363
- notification_rule && notification_rule.delete
364
- process && process.delete
365
- end
366
- end
367
- end
@@ -1,592 +0,0 @@
1
- # encoding: UTF-8
2
- #
3
- # Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
4
- # This source code is licensed under the BSD-style license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- require 'gooddata'
8
- require 'tempfile'
9
-
10
- describe "Full project implementation", :constraint => 'slow' do
11
- before(:all) do
12
- @invalid_spec = JSON.parse(File.read("./spec/data/blueprints/invalid_blueprint.json"), :symbolize_names => true)
13
- @invalid_blueprint = GoodData::Model::ProjectBlueprint.new(@invalid_spec)
14
- @client = ConnectionHelper.create_default_connection
15
- @project, @blueprint, @spec = ProjectHelper.load_full_project_implementation(@client)
16
- end
17
-
18
- after(:all) do
19
- @project.delete unless @project.nil?
20
-
21
- @client.disconnect
22
- end
23
-
24
- it "should not build an invalid model" do
25
- expect do
26
- @client.create_project_from_blueprint(@invalid_spec, auth_token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
27
- end.to raise_error(GoodData::ValidationError)
28
- end
29
-
30
- it "should do nothing if the project is updated with the same blueprint" do
31
- results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client, dry_run: true)
32
- expect(results).to eq []
33
- end
34
-
35
- it 'should try to rename a dataset back' do
36
- dataset = @project.datasets('dataset.repos')
37
- dataset.title = "Some title"
38
- dataset.save
39
-
40
- # Now the update of project using the original blueprint should offer update of the title. Nothing else.
41
- results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client, dry_run: true)
42
- expect(results.first['updateScript']['maqlDdlChunks']).to eq ["ALTER DATASET {dataset.repos} VISUAL(TITLE \"Repositories\", DESCRIPTION \"\");\n"]
43
-
44
- # Update using a freshly gained blueprint should offer no changes.
45
- new_blueprint = @project.blueprint
46
- results = GoodData::Model::ProjectCreator.migrate_datasets(new_blueprint, project: @project, client: @client, dry_run: true)
47
- expect(results).to eq []
48
-
49
- # When we change the model using the original blueprint. Basically change the title back.
50
- @project.update_from_blueprint(@spec)
51
- # It should offer no changes using the original blueprint
52
- results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client, dry_run: true)
53
- expect(results).to eq []
54
- end
55
-
56
- it "should contain datasets" do
57
- bp = @project.blueprint
58
- expect(bp.datasets.count).to eq 3
59
- expect(bp.datasets(:all, :include_date_dimensions => true).count).to eq 4
60
- end
61
-
62
- it "should contain metadata datasets" do
63
- expect(@project.datasets.count).to eq 4
64
- expect(@project.datasets.select(&:date_dimension?).count).to eq 1
65
- end
66
-
67
- it "should be able to rename a project" do
68
- former_title = @project.title
69
- a_title = (0...8).map { (65 + rand(26)).chr }.join
70
- @project.title = a_title
71
- @project.save
72
- expect(@project.title).to eq a_title
73
- @project.title = former_title
74
- @project.save
75
- end
76
-
77
- it "should be able to validate a project" do
78
- @project.validate
79
- end
80
-
81
- it "should compute an empty metric" do
82
- f = @project.fact_by_title('Lines Changed')
83
- metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
84
- expect(metric.execute).to be_nil
85
- end
86
-
87
- it "should compute an empty report def" do
88
- @project.delete_all_data(force: true)
89
- f = @project.fact_by_title('Lines Changed')
90
- metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
91
- res = @project.compute_report(:left => [metric])
92
- expect(res).to be_empty
93
- end
94
-
95
- it "should load the data" do
96
- GoodData.with_project(@project) do
97
- # blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
98
- commits_data = [
99
- %w(lines_changed committed_on dev_id repo_id),
100
- [1, "01/01/2014", 1, 1],
101
- [3, "01/02/2014", 2, 2],
102
- [5, "05/02/2014", 3, 1]
103
- ]
104
- @project.upload(commits_data, @blueprint, 'dataset.commits')
105
-
106
- devs_data = [
107
- %w(dev_id email),
108
- [1, "tomas@gooddata.com"],
109
- [2, "petr@gooddata.com"],
110
- [3, "jirka@gooddata.com"]
111
- ]
112
- @project.upload(devs_data, @blueprint, 'dataset.devs')
113
- end
114
- end
115
-
116
- it "it silently ignores extra columns" do
117
- GoodData.with_project(@project) do
118
- blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
119
- commits_data = [
120
- %w(lines_changed committed_on dev_id repo_id extra_column),
121
- [1, "01/01/2014", 1, 1, "something"],
122
- [3, "01/02/2014", 2, 2, "something"],
123
- [5, "05/02/2014", 3, 1, "something else"]
124
- ]
125
- @project.upload(commits_data, blueprint, 'dataset.commits')
126
- end
127
- end
128
-
129
- context "it should give you a reasonable error message" do
130
- it "if you omit a column" do
131
- GoodData.with_project(@project) do
132
- blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
133
- commits_data = [
134
- %w(lines_changed committed_on dev_id),
135
- [1, "01/01/2014", 1],
136
- [3, "01/02/2014", 2],
137
- [5, "05/02/2014", 3]
138
- ]
139
- expect do
140
- @project.upload(commits_data, blueprint, 'dataset.commits')
141
- end.to raise_error(/repo_id/)
142
- end
143
- end
144
- it "if you give it a malformed CSV" do
145
- GoodData.with_project(@project) do
146
- blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
147
- # 4 cols in header but not in the data
148
- commits_data = [
149
- %w(lines_changed committed_on dev_id repo_id),
150
- [1, "01/01/2014", 1],
151
- [3, "01/02/2014", 2],
152
- [5, "05/02/2014", 3]
153
- ]
154
- expect do
155
- @project.upload(commits_data, blueprint, 'dataset.commits')
156
- end.to raise_error(/Number of columns/)
157
- end
158
- end
159
- it "if you give it wrong date format" do
160
- GoodData.with_project(@project) do
161
- blueprint = GoodData::Model::ProjectBlueprint.new(@spec)
162
- commits_data = [
163
- %w(lines_changed committed_on dev_id repo_id),
164
- [1, "01/01/2014", 1, 1],
165
- [3, "45/50/2014", 2, 2],
166
- [5, "05/02/2014", 3, 1]
167
- ]
168
- expect do
169
- @project.upload(commits_data, blueprint, 'dataset.commits')
170
- end.to raise_error(%r{45/50/2014})
171
- end
172
- end
173
- end
174
-
175
- it "should compute a metric" do
176
- f = @project.fact_by_title('Lines Changed')
177
- metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
178
- expect(metric.execute).to eq 9
179
- end
180
-
181
- it "should compute a count metric from dataset" do
182
- # works on anchor without label
183
- expect(@blueprint.datasets('dataset.commits').count(@project)).to eq 3
184
-
185
- # works on anchor with label
186
- expect(@blueprint.datasets('dataset.devs').count(@project)).to eq 3
187
- end
188
-
189
- it "should execute an anonymous metric twice and not fail" do
190
- f = @project.fact_by_title('Lines Changed')
191
- metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
192
- expect(metric.execute).to eq 9
193
- # Since GD platform cannot execute inline specified metric the metric has to be saved
194
- # The code tries to resolve this as transparently as possible
195
- # Here we are testing that you can execute the metric twice. The first execution is on unsaved metric
196
- # We wanna make sure that when we are cleaning up we are not messing things up
197
- expect(metric.execute).to eq 9
198
- end
199
-
200
- it "should compute a report def" do
201
- f = @project.fact_by_title('Lines Changed')
202
-
203
- # 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"
204
- metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")", :title => "My metric")
205
- metric.save
206
- result = @project.compute_report(:top => [metric], :left => ['label.devs.dev_id.email'])
207
- expect(result[2][1]).to eq 3
208
- expect(result.include_row?(["jirka@gooddata.com", 5])).to be true
209
-
210
- result2 = @project.compute_report(:top => [metric], :left => ['label.devs.dev_id.email'])
211
- expect(result2[2][1]).to eq 3
212
- expect(result2.include_row?(["jirka@gooddata.com", 5])).to eq true
213
- expect(result2).to eq result
214
- end
215
-
216
- it "should be able to lock reports and everything underneath" do
217
- m = @project.metrics.first
218
- r = @project.create_report(top: [m], title: 'xy')
219
- r.save
220
- expect(m.locked?).to eq false
221
- expect(r.locked?).to eq false
222
- r.lock_with_dependencies!
223
- expect(r.locked?).to eq true
224
- m.reload!
225
- expect(m.locked?).to eq true
226
- r.unlock_with_dependencies!
227
- expect(r.locked?).to eq false
228
- m.reload!
229
- expect(m.locked?).to eq false
230
- r.lock!
231
- expect(r.locked?).to eq true
232
- r.unlock!
233
- expect(r.locked?).to eq false
234
- r.delete
235
- end
236
-
237
- it "should be able to purge report from older revisions" do
238
- m = @project.metrics.first
239
- r = @project.create_report(top: [m], title: 'xy')
240
- expect(r.definitions.count).to eq 1
241
-
242
- rd = GoodData::ReportDefinition.create(:top => [m], :client => @client, :project => @project)
243
- rd.save
244
- r.add_definition(rd)
245
- r.save
246
- expect(r.definitions.count).to eq 2
247
- end
248
-
249
- it "should be able to clean colors from a chart report def" do
250
- f = @project.fact_by_title('Lines Changed')
251
- m = @project.create_metric("SELECT SUM(#\"#{f.title}\")", title: 'test metric').save
252
- r = @project.create_report(top: [m], title: 'xy')
253
- rd = r.latest_report_definition
254
- rd.content['chart'] = { 'styles' => { 'global' => { 'colorMapping' => 1 } } }
255
-
256
- expect(GoodData::Helpers.get_path(rd.content, %w(chart styles global))).to eq('colorMapping' => 1)
257
- rd.reset_color_mapping!
258
- expect(GoodData::Helpers.get_path(rd.content, %w(chart styles global))).to eq('colorMapping' => [])
259
- r.delete
260
- res = m.used_by
261
- res.each do |dependency|
262
- @client.delete dependency['link']
263
- end
264
- res = m.used_by
265
- expect(res.length).to eq 0
266
- m.delete
267
- end
268
-
269
- it "should be able to update report definition (update existing)" do
270
- m = @project.metrics.first
271
- r = @project.create_report(top: [m], title: 'xy')
272
-
273
- latest_uri = r.definition_uri
274
- new_def = r.update_definition do |definition|
275
- definition.title = "Test TITLE: #{DateTime.now.strftime}"
276
- end
277
-
278
- expect(r.definition_uri).to eq new_def.uri
279
- expect(r.definition_uri).to_not eq latest_uri
280
- end
281
-
282
- it "should be able to update report definition (create new)" do
283
- m = @project.metrics.first
284
- r = @project.create_report(top: [m], title: 'xy')
285
-
286
- latest_uri = r.definition_uri
287
- new_def = r.update_definition(:new_definition => false) do |definition|
288
- definition.title = "Test TITLE: #{DateTime.now.strftime}"
289
- end
290
-
291
- expect(r.definition_uri).to eq new_def.uri
292
- expect(r.definition_uri).to eq latest_uri
293
- end
294
-
295
- it "should be possible to get all metrics" do
296
- metrics1 = @project.metrics
297
- expect(metrics1.count).to be >= 0
298
- end
299
-
300
- it "should be possible to get all metrics with full objects" do
301
- metrics = @project.metrics(:all)
302
- expect(metrics.first.class).to be GoodData::Metric
303
- end
304
-
305
- it "should be able to get a metric by identifier" do
306
- metrics = @project.metrics
307
- metric = @project.metrics(metrics.first.identifier)
308
- expect(metric.identifier).to eq metrics.first.identifier
309
- expect(metrics.first).to eq metric
310
- end
311
-
312
- it "should be able to get a metric by uri" do
313
- metrics = @project.metrics
314
- metric = @project.metrics(metrics.first.uri)
315
- expect(metric.uri).to eq metrics.first.uri
316
- expect(metrics.first).to eq metric
317
- end
318
-
319
- it "should be able to get a metric by object id" do
320
- metrics = @project.metrics
321
- metric = @project.metrics(metrics.first.obj_id)
322
- expect(metric.obj_id).to eq metrics.first.obj_id
323
- expect(metrics.first).to eq metric
324
- end
325
-
326
- it "should exercise the object relations and getting them in various ways" do
327
- # Find a metric by name
328
- metric = @project.metric_by_title('My metric')
329
- the_same_metric = @project.metrics(metric)
330
- expect(metric).to eq the_same_metric
331
-
332
- # grab fact in several different ways
333
- fact1 = @project.fact_by_title('Lines Changed')
334
- fact2 = @project.facts(fact1.identifier)
335
- fact3 = @project.facts(fact2.obj_id)
336
- fact4 = @project.facts(fact3.uri)
337
- fact5 = @client.create(GoodData::Fact, fact4)
338
-
339
- # All should be the same
340
- expect(fact1).to eq fact2
341
- expect(fact1).to eq fact2
342
- expect(fact1).to eq fact3
343
- expect(fact1).to eq fact4
344
- expect(fact1).to eq fact5
345
-
346
- fact3.title = "Somewhat changed title"
347
- expect(fact1).not_to eq fact3
348
-
349
- metric.using(nil)
350
- res = metric.using('fact')
351
- expect(res.count).to eq 1
352
-
353
- fact1.used_by(nil)
354
- res = fact1.used_by('metric')
355
- expect(res.count).to eq 1
356
-
357
- res = metric.using?(fact1)
358
- expect(res).to be(true)
359
-
360
- res = fact1.using?(metric)
361
- expect(res).to be(false)
362
-
363
- res = metric.used_by?(fact1)
364
- expect(res).to be(false)
365
-
366
- res = fact1.used_by?(metric)
367
- expect(res).to be(true)
368
- end
369
-
370
- it "should try setting and getting by tags" do
371
- fact = @project.fact_by_title('Lines Changed')
372
- expect(fact.tags.empty?).to be_truthy
373
-
374
- fact.tags = "tag1 tag2 tag3"
375
- fact.save
376
-
377
- tagged_facts = GoodData::Fact.find_by_tag('tag3', :client => @client, :project => @project)
378
- expect(tagged_facts.count).to eq 1
379
- end
380
-
381
- it "should be able to interpolate metric based on" do
382
- res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
383
- expect(res).to eq 9
384
-
385
- res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
386
- expect(res).to eq 9
387
-
388
- res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
389
- expect(res).to eq 9
390
-
391
- res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
392
- expect(res).to eq 9
393
-
394
- fact = @project.fact_by_title('Lines Changed')
395
- expect(fact.fact?).to be true
396
- res = fact.create_metric(:type => :sum).execute
397
- expect(res).to eq 9
398
- end
399
-
400
- it "should load the data" do
401
- devs_data = [
402
- %w(dev_id email),
403
- [4, "josh@gooddata.com"]
404
- ]
405
- @project.upload(devs_data, @blueprint, 'dataset.devs', mode: 'INCREMENTAL')
406
- end
407
-
408
- it "should have more users" do
409
- attribute = @project.attributes('attr.devs.dev_id')
410
- expect(attribute.attribute?).to be true
411
- expect(attribute.create_metric.execute).to eq 4
412
- end
413
-
414
- it "should tell you whether metric contains a certain attribute" do
415
- attribute = @project.attributes('attr.devs.dev_id')
416
- repo_attribute = @project.attributes('attr.repos.repo_id')
417
- metric = attribute.create_metric(:title => "My test metric")
418
- metric.save
419
- expect(metric.execute).to eq 4
420
-
421
- expect(metric.contain?(attribute)).to be true
422
- expect(metric.contain?(repo_attribute)).to be false
423
- metric.replace!(attribute => repo_attribute)
424
- metric.save
425
- expect(metric.execute).not_to eq 4
426
-
427
- l = attribute.primary_label
428
- value = l.values.first[:value]
429
- expect(l.find_element_value(l.find_value_uri(value))).to eq value
430
- expect(l.value?(value)).to eq true
431
- expect(l.value?("DEFINITELY NON EXISTENT VALUE HOPEFULLY")).to eq false
432
- end
433
-
434
- it "should be able to compute count of different datasets" do
435
- attribute = @project.attributes('attr.devs.dev_id')
436
- dataset_attribute = @project.attributes('attr.commits.factsof')
437
- expect(attribute.create_metric(:attribute => dataset_attribute).execute).to eq 3
438
- end
439
-
440
- it "should be able to tell you if a value is contained in a metric" do
441
- attribute = @project.attributes('attr.devs.dev_id')
442
- label = attribute.primary_label
443
- value = label.values.first
444
- fact = @project.facts('fact.commits.lines_changed')
445
- metric = @project.create_metric("SELECT SUM([#{fact.uri}]) WHERE [#{attribute.uri}] = [#{value[:uri]}]")
446
- expect(metric.contain_value?(label, value[:value])).to be true
447
- end
448
-
449
- it "should be able to replace the values in a metric" do
450
- attribute = @project.attributes('attr.devs.dev_id')
451
- label = attribute.primary_label
452
- value = label.values.first
453
- different_value = label.values.drop(1).first
454
- fact = @project.facts('fact.commits.lines_changed')
455
- metric = @project.create_metric("SELECT SUM([#{fact.uri}]) WHERE [#{attribute.uri}] = [#{value[:uri]}]")
456
- metric.replace_value(label, value[:value], different_value[:value])
457
- expect(metric.contain_value?(label, value[:value])).to be false
458
- expect(metric.pretty_expression).to eq "SELECT SUM([Lines Changed]) WHERE [Dev] = [josh@gooddata.com]"
459
- end
460
-
461
- it "should be able to lookup the attributes by regexp and return a collection" do
462
- attrs = @project.attributes_by_title(/Date/i)
463
- expect(attrs.count).to eq 1
464
- end
465
-
466
- it "should be able to give you values of the label as an array of hashes" do
467
- attribute = @project.attributes('attr.devs.dev_id')
468
- label = attribute.primary_label
469
- expect(label.values.map { |v| v[:value] }).to eq [
470
- 'jirka@gooddata.com',
471
- 'josh@gooddata.com',
472
- 'petr@gooddata.com',
473
- 'tomas@gooddata.com'
474
- ]
475
- end
476
-
477
- it "should be able to give you values for" do
478
- attribute = @project.attributes('attr.devs.dev_id')
479
- values = attribute.labels.find { |l| l.identifier == 'label.devs.dev_id.email' }.values.to_a
480
- id = values.find { |v| v[:value] == 'tomas@gooddata.com' }[:uri][-1].to_i
481
- expect(attribute.values_for(id)).to eq ['tomas@gooddata.com', '1']
482
- end
483
-
484
- it "should be able to find specific element and give you the primary label value" do
485
- attribute = @project.attributes('attr.devs.dev_id')
486
- values = attribute.labels.find { |l| l.identifier == 'label.devs.dev_id.email' }.values.to_a
487
- uri = values.find { |v| v[:value] == 'tomas@gooddata.com' }[:uri]
488
- expect(@project.find_attribute_element_value(uri)).to eq 'tomas@gooddata.com'
489
- end
490
-
491
- it "should be able to give you label by name" do
492
- attribute = @project.attributes('attr.devs.dev_id')
493
- label = attribute.label_by_name('Id')
494
- expect(label.label?).to eq true
495
- expect(label.title).to eq 'Id'
496
- expect(label.identifier).to eq 'label.devs.dev_id.id'
497
- expect(label.attribute_uri).to eq attribute.uri
498
- expect(label.attribute).to eq attribute
499
- end
500
-
501
- it "should be able to return values of the attribute for inspection" do
502
- attribute = @project.attributes('attr.devs.dev_id')
503
- vals = attribute.values
504
- expect(vals.count).to eq 4
505
- expect(vals.first.count).to eq 2
506
- expect(vals.first.first[:value]).to eq "jirka@gooddata.com"
507
- end
508
-
509
- it "should be able to save_as a metric" do
510
- m = @project.metric_by_title("My test metric")
511
- cloned = m.save_as
512
- m_cloned = @project.metric_by_title("Clone of My test metric")
513
- expect(m_cloned).to eq cloned
514
- expect(m_cloned.execute).to eq cloned.execute
515
- end
516
-
517
- it "should be able to clone a project and transfer the data" do
518
- title = 'My new clone project'
519
- begin
520
- cloned_project = @project.clone(title: title, auth_token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
521
- expect(cloned_project.title).to eq title
522
- expect(cloned_project.facts.first.create_metric.execute).to eq 9
523
- m = @project.facts.first.create_metric
524
- m.identifier = 'metric.cloned_metric'
525
- m.save
526
-
527
- result = @project.transfer_objects(m, project: cloned_project)
528
- expect(result).to be_truthy
529
- cloned_metric = cloned_project.metrics('metric.cloned_metric')
530
- expect(cloned_metric).not_to be_nil
531
-
532
- cloned_metric.delete
533
- cloned_metric = cloned_project.metrics('metric.cloned_metric')
534
- expect(cloned_metric).to be_nil
535
-
536
- result = @project.transfer_objects(m, project: [cloned_project], batch_size: 1)
537
- expect(result).to eq [{ project: cloned_project, result: true }]
538
-
539
- # should work with pids
540
- result = @project.transfer_objects(m, project: [cloned_project.pid], batch_size: 1)
541
- expect(result.first[:result]).to be_truthy
542
- ensure
543
- cloned_project.delete
544
- end
545
- end
546
-
547
- it "should be able to clone a project without data" do
548
- title = 'My new clone project'
549
- cloned_project = @project.clone(title: title, auth_token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT, data: false)
550
- expect(cloned_project.title).to eq title
551
- expect(cloned_project.facts.first.create_metric.execute).to eq nil
552
- cloned_project.delete
553
- end
554
-
555
- it "should be able to export report" do
556
- m = @project.metrics.first
557
- r = @project.create_report(top: [m], title: 'Report to export')
558
- r.save
559
- r.export(:csv)
560
- r.export(:pdf)
561
- r.delete
562
- end
563
-
564
- it "should be able to delete report along with its definitions" do
565
- m = @project.metrics.first
566
- r = @project.create_report(top: [m], title: 'Report to delete')
567
- r.save
568
- def_uris = r.definition_uris
569
- r.delete
570
- expect { def_uris.each { |uri| @client.get(uri) } }.to raise_error(RestClient::ResourceNotFound)
571
- end
572
-
573
- it 'should be possible to delete data from a dataset' do
574
- dataset = @project.datasets('dataset.devs')
575
- expect(dataset.attributes.first.create_metric.execute).to be > 0
576
- dataset.delete_data
577
- expect(dataset.attributes.first.create_metric.execute).to be_nil
578
- end
579
-
580
- it 'shoule be able to create project from blueprint support attribute sort order' do
581
- begin
582
- attr_sort_order_spec = JSON.parse(File.read("./spec/data/blueprints/attribute_sort_order_blueprint.json"), :symbolize_names => true)
583
- attr_sort_order_blueprint = GoodData::Model::ProjectBlueprint.new(attr_sort_order_spec)
584
-
585
- project = @client.create_project_from_blueprint(attr_sort_order_blueprint, token: ConnectionHelper::GD_PROJECT_TOKEN, environment: ProjectHelper::ENVIRONMENT)
586
- attribute = project.blueprint.datasets('dataset.id').attributes('attr.id.name')
587
- expect(attribute.order_by).to eq 'label.id.name.name_label_2 - DESC'
588
- ensure
589
- project && project.delete
590
- end
591
- end
592
- end