gooddata-edge 0.6.27.edge

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.
Files changed (364) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +36 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +89 -0
  6. data/.yardopts +22 -0
  7. data/CHANGELOG.md +196 -0
  8. data/CLI.md +439 -0
  9. data/DEPENDENCIES.md +817 -0
  10. data/Gemfile +4 -0
  11. data/Guardfile +5 -0
  12. data/LICENSE +22 -0
  13. data/LICENSE.rb +5 -0
  14. data/README.md +75 -0
  15. data/Rakefile +179 -0
  16. data/TODO.md +32 -0
  17. data/authors.sh +4 -0
  18. data/bin/gooddata +7 -0
  19. data/dependency_decisions.yml +104 -0
  20. data/gooddata +9 -0
  21. data/gooddata.gemspec +63 -0
  22. data/lib/gooddata.rb +31 -0
  23. data/lib/gooddata/app/app.rb +16 -0
  24. data/lib/gooddata/bricks/base_downloader.rb +86 -0
  25. data/lib/gooddata/bricks/brick.rb +38 -0
  26. data/lib/gooddata/bricks/bricks.rb +15 -0
  27. data/lib/gooddata/bricks/middleware/aws_middleware.rb +29 -0
  28. data/lib/gooddata/bricks/middleware/base_middleware.rb +56 -0
  29. data/lib/gooddata/bricks/middleware/bench_middleware.rb +24 -0
  30. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +37 -0
  31. data/lib/gooddata/bricks/middleware/decode_params_middleware.rb +20 -0
  32. data/lib/gooddata/bricks/middleware/fs_download_middleware.rb +48 -0
  33. data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +36 -0
  34. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +39 -0
  35. data/lib/gooddata/bricks/middleware/logger_middleware.rb +29 -0
  36. data/lib/gooddata/bricks/middleware/middleware.rb +12 -0
  37. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +61 -0
  38. data/lib/gooddata/bricks/middleware/stdout_middleware.rb +23 -0
  39. data/lib/gooddata/bricks/middleware/twitter_middleware.rb +29 -0
  40. data/lib/gooddata/bricks/middleware/undot_params_middleware.rb +37 -0
  41. data/lib/gooddata/bricks/pipeline.rb +32 -0
  42. data/lib/gooddata/bricks/utils.rb +18 -0
  43. data/lib/gooddata/cli/cli.rb +27 -0
  44. data/lib/gooddata/cli/commands/auth_cmd.rb +29 -0
  45. data/lib/gooddata/cli/commands/domain_cmd.rb +28 -0
  46. data/lib/gooddata/cli/commands/project_cmd.rb +45 -0
  47. data/lib/gooddata/cli/hooks.rb +57 -0
  48. data/lib/gooddata/cli/shared.rb +61 -0
  49. data/lib/gooddata/cli/terminal.rb +20 -0
  50. data/lib/gooddata/client.rb +67 -0
  51. data/lib/gooddata/commands/api.rb +64 -0
  52. data/lib/gooddata/commands/auth.rb +107 -0
  53. data/lib/gooddata/commands/base.rb +12 -0
  54. data/lib/gooddata/commands/commands.rb +12 -0
  55. data/lib/gooddata/commands/datasets.rb +148 -0
  56. data/lib/gooddata/commands/datawarehouse.rb +20 -0
  57. data/lib/gooddata/commands/domain.rb +40 -0
  58. data/lib/gooddata/commands/process.rb +67 -0
  59. data/lib/gooddata/commands/project.rb +175 -0
  60. data/lib/gooddata/commands/projects.rb +20 -0
  61. data/lib/gooddata/commands/role.rb +36 -0
  62. data/lib/gooddata/commands/runners.rb +47 -0
  63. data/lib/gooddata/commands/scaffold.rb +69 -0
  64. data/lib/gooddata/commands/user.rb +39 -0
  65. data/lib/gooddata/connection.rb +127 -0
  66. data/lib/gooddata/core/core.rb +12 -0
  67. data/lib/gooddata/core/logging.rb +105 -0
  68. data/lib/gooddata/core/nil_logger.rb +23 -0
  69. data/lib/gooddata/core/project.rb +74 -0
  70. data/lib/gooddata/core/rest.rb +149 -0
  71. data/lib/gooddata/core/user.rb +20 -0
  72. data/lib/gooddata/data/data.rb +12 -0
  73. data/lib/gooddata/data/guesser.rb +122 -0
  74. data/lib/gooddata/exceptions/attr_element_not_found.rb +16 -0
  75. data/lib/gooddata/exceptions/command_failed.rb +11 -0
  76. data/lib/gooddata/exceptions/exceptions.rb +12 -0
  77. data/lib/gooddata/exceptions/execution_limit_exceeded.rb +13 -0
  78. data/lib/gooddata/exceptions/filter_maqlization.rb +16 -0
  79. data/lib/gooddata/exceptions/malformed_user.rb +15 -0
  80. data/lib/gooddata/exceptions/no_project_error.rb +15 -0
  81. data/lib/gooddata/exceptions/object_migration.rb +32 -0
  82. data/lib/gooddata/exceptions/project_not_found.rb +13 -0
  83. data/lib/gooddata/exceptions/segment_not_empty.rb +18 -0
  84. data/lib/gooddata/exceptions/uncomputable_report.rb +13 -0
  85. data/lib/gooddata/exceptions/user_in_different_domain.rb +15 -0
  86. data/lib/gooddata/exceptions/validation_error.rb +16 -0
  87. data/lib/gooddata/extensions/big_decimal.rb +17 -0
  88. data/lib/gooddata/extensions/enumerable.rb +39 -0
  89. data/lib/gooddata/extensions/extensions.rb +10 -0
  90. data/lib/gooddata/extensions/false.rb +15 -0
  91. data/lib/gooddata/extensions/hash.rb +38 -0
  92. data/lib/gooddata/extensions/nil.rb +15 -0
  93. data/lib/gooddata/extensions/numeric.rb +15 -0
  94. data/lib/gooddata/extensions/object.rb +27 -0
  95. data/lib/gooddata/extensions/symbol.rb +15 -0
  96. data/lib/gooddata/extensions/true.rb +15 -0
  97. data/lib/gooddata/extract.rb +21 -0
  98. data/lib/gooddata/goodzilla/goodzilla.rb +159 -0
  99. data/lib/gooddata/helpers/auth_helpers.rb +75 -0
  100. data/lib/gooddata/helpers/csv_helper.rb +61 -0
  101. data/lib/gooddata/helpers/data_helper.rb +116 -0
  102. data/lib/gooddata/helpers/global_helpers.rb +331 -0
  103. data/lib/gooddata/helpers/global_helpers_params.rb +172 -0
  104. data/lib/gooddata/helpers/helpers.rb +10 -0
  105. data/lib/gooddata/mixins/author.rb +26 -0
  106. data/lib/gooddata/mixins/content_getter.rb +15 -0
  107. data/lib/gooddata/mixins/content_property_reader.rb +17 -0
  108. data/lib/gooddata/mixins/content_property_writer.rb +17 -0
  109. data/lib/gooddata/mixins/contributor.rb +20 -0
  110. data/lib/gooddata/mixins/data_getter.rb +15 -0
  111. data/lib/gooddata/mixins/data_property_reader.rb +19 -0
  112. data/lib/gooddata/mixins/data_property_writer.rb +19 -0
  113. data/lib/gooddata/mixins/inspector.rb +53 -0
  114. data/lib/gooddata/mixins/is_attribute.rb +17 -0
  115. data/lib/gooddata/mixins/is_dimension.rb +17 -0
  116. data/lib/gooddata/mixins/is_fact.rb +17 -0
  117. data/lib/gooddata/mixins/is_label.rb +19 -0
  118. data/lib/gooddata/mixins/links.rb +15 -0
  119. data/lib/gooddata/mixins/md_finders.rb +77 -0
  120. data/lib/gooddata/mixins/md_grantees.rb +42 -0
  121. data/lib/gooddata/mixins/md_id_to_uri.rb +34 -0
  122. data/lib/gooddata/mixins/md_json.rb +15 -0
  123. data/lib/gooddata/mixins/md_lock.rb +87 -0
  124. data/lib/gooddata/mixins/md_object_id.rb +15 -0
  125. data/lib/gooddata/mixins/md_object_indexer.rb +64 -0
  126. data/lib/gooddata/mixins/md_object_query.rb +128 -0
  127. data/lib/gooddata/mixins/md_relations.rb +43 -0
  128. data/lib/gooddata/mixins/meta_getter.rb +17 -0
  129. data/lib/gooddata/mixins/meta_property_reader.rb +19 -0
  130. data/lib/gooddata/mixins/meta_property_writer.rb +19 -0
  131. data/lib/gooddata/mixins/mixins.rb +19 -0
  132. data/lib/gooddata/mixins/not_attribute.rb +17 -0
  133. data/lib/gooddata/mixins/not_exportable.rb +15 -0
  134. data/lib/gooddata/mixins/not_fact.rb +17 -0
  135. data/lib/gooddata/mixins/not_group.rb +17 -0
  136. data/lib/gooddata/mixins/not_label.rb +19 -0
  137. data/lib/gooddata/mixins/not_metric.rb +19 -0
  138. data/lib/gooddata/mixins/obj_id.rb +15 -0
  139. data/lib/gooddata/mixins/rest_getters.rb +17 -0
  140. data/lib/gooddata/mixins/rest_resource.rb +47 -0
  141. data/lib/gooddata/mixins/root_key_getter.rb +15 -0
  142. data/lib/gooddata/mixins/root_key_setter.rb +15 -0
  143. data/lib/gooddata/mixins/timestamps.rb +19 -0
  144. data/lib/gooddata/mixins/to_json.rb +11 -0
  145. data/lib/gooddata/mixins/uri_getter.rb +9 -0
  146. data/lib/gooddata/models/blueprint/anchor_field.rb +64 -0
  147. data/lib/gooddata/models/blueprint/attribute_field.rb +29 -0
  148. data/lib/gooddata/models/blueprint/blueprint.rb +11 -0
  149. data/lib/gooddata/models/blueprint/blueprint_field.rb +70 -0
  150. data/lib/gooddata/models/blueprint/dashboard_builder.rb +30 -0
  151. data/lib/gooddata/models/blueprint/dataset_blueprint.rb +449 -0
  152. data/lib/gooddata/models/blueprint/date_dimension.rb +14 -0
  153. data/lib/gooddata/models/blueprint/fact_field.rb +20 -0
  154. data/lib/gooddata/models/blueprint/label_field.rb +43 -0
  155. data/lib/gooddata/models/blueprint/project_blueprint.rb +746 -0
  156. data/lib/gooddata/models/blueprint/project_builder.rb +83 -0
  157. data/lib/gooddata/models/blueprint/reference_field.rb +43 -0
  158. data/lib/gooddata/models/blueprint/schema_blueprint.rb +160 -0
  159. data/lib/gooddata/models/blueprint/schema_builder.rb +89 -0
  160. data/lib/gooddata/models/blueprint/to_manifest.rb +181 -0
  161. data/lib/gooddata/models/blueprint/to_wire.rb +154 -0
  162. data/lib/gooddata/models/client.rb +182 -0
  163. data/lib/gooddata/models/client_synchronization_result.rb +31 -0
  164. data/lib/gooddata/models/client_synchronization_result_details.rb +41 -0
  165. data/lib/gooddata/models/datawarehouse.rb +92 -0
  166. data/lib/gooddata/models/domain.rb +479 -0
  167. data/lib/gooddata/models/execution.rb +115 -0
  168. data/lib/gooddata/models/execution_detail.rb +81 -0
  169. data/lib/gooddata/models/from_wire.rb +160 -0
  170. data/lib/gooddata/models/invitation.rb +75 -0
  171. data/lib/gooddata/models/links.rb +50 -0
  172. data/lib/gooddata/models/membership.rb +441 -0
  173. data/lib/gooddata/models/metadata.rb +272 -0
  174. data/lib/gooddata/models/metadata/attribute.rb +134 -0
  175. data/lib/gooddata/models/metadata/dashboard.rb +108 -0
  176. data/lib/gooddata/models/metadata/dashboard/dashboard_item.rb +76 -0
  177. data/lib/gooddata/models/metadata/dashboard/filter_apply_item.rb +37 -0
  178. data/lib/gooddata/models/metadata/dashboard/filter_item.rb +64 -0
  179. data/lib/gooddata/models/metadata/dashboard/geo_chart_item.rb +56 -0
  180. data/lib/gooddata/models/metadata/dashboard/headline_item.rb +56 -0
  181. data/lib/gooddata/models/metadata/dashboard/iframe_item.rb +46 -0
  182. data/lib/gooddata/models/metadata/dashboard/report_item.rb +92 -0
  183. data/lib/gooddata/models/metadata/dashboard/text_item.rb +55 -0
  184. data/lib/gooddata/models/metadata/dashboard_tab.rb +141 -0
  185. data/lib/gooddata/models/metadata/dataset.rb +64 -0
  186. data/lib/gooddata/models/metadata/dimension.rb +54 -0
  187. data/lib/gooddata/models/metadata/fact.rb +44 -0
  188. data/lib/gooddata/models/metadata/label.rb +128 -0
  189. data/lib/gooddata/models/metadata/metadata.rb +12 -0
  190. data/lib/gooddata/models/metadata/metric.rb +198 -0
  191. data/lib/gooddata/models/metadata/report.rb +247 -0
  192. data/lib/gooddata/models/metadata/report_definition.rb +264 -0
  193. data/lib/gooddata/models/metadata/scheduled_mail.rb +274 -0
  194. data/lib/gooddata/models/metadata/scheduled_mail/dashboard_attachment.rb +62 -0
  195. data/lib/gooddata/models/metadata/scheduled_mail/report_attachment.rb +64 -0
  196. data/lib/gooddata/models/metadata/variable.rb +91 -0
  197. data/lib/gooddata/models/model.rb +282 -0
  198. data/lib/gooddata/models/models.rb +12 -0
  199. data/lib/gooddata/models/module_constants.rb +31 -0
  200. data/lib/gooddata/models/process.rb +316 -0
  201. data/lib/gooddata/models/profile.rb +426 -0
  202. data/lib/gooddata/models/project.rb +1514 -0
  203. data/lib/gooddata/models/project_creator.rb +126 -0
  204. data/lib/gooddata/models/project_metadata.rb +67 -0
  205. data/lib/gooddata/models/project_role.rb +79 -0
  206. data/lib/gooddata/models/report_data_result.rb +266 -0
  207. data/lib/gooddata/models/schedule.rb +518 -0
  208. data/lib/gooddata/models/segment.rb +201 -0
  209. data/lib/gooddata/models/tab_builder.rb +27 -0
  210. data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +76 -0
  211. data/lib/gooddata/models/user_filters/user_filter.rb +100 -0
  212. data/lib/gooddata/models/user_filters/user_filter_builder.rb +512 -0
  213. data/lib/gooddata/models/user_filters/user_filters.rb +13 -0
  214. data/lib/gooddata/models/user_filters/variable_user_filter.rb +31 -0
  215. data/lib/gooddata/models/user_group.rb +241 -0
  216. data/lib/gooddata/rest/README.md +37 -0
  217. data/lib/gooddata/rest/client.rb +389 -0
  218. data/lib/gooddata/rest/connection.rb +765 -0
  219. data/lib/gooddata/rest/object.rb +69 -0
  220. data/lib/gooddata/rest/object_factory.rb +76 -0
  221. data/lib/gooddata/rest/resource.rb +27 -0
  222. data/lib/gooddata/rest/rest.rb +24 -0
  223. data/lib/gooddata/version.rb +23 -0
  224. data/lib/templates/bricks/brick.rb.erb +7 -0
  225. data/lib/templates/bricks/main.rb.erb +5 -0
  226. data/lib/templates/project/Goodfile.erb +4 -0
  227. data/lib/templates/project/data/commits.csv +4 -0
  228. data/lib/templates/project/data/devs.csv +4 -0
  229. data/lib/templates/project/data/repos.csv +3 -0
  230. data/lib/templates/project/model/model.rb.erb +20 -0
  231. data/spec/bricks/bricks_spec.rb +112 -0
  232. data/spec/bricks/default-config.json +8 -0
  233. data/spec/data/.gooddata +4 -0
  234. data/spec/data/blueprints/additional_dataset_module.json +32 -0
  235. data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
  236. data/spec/data/blueprints/invalid_blueprint.json +103 -0
  237. data/spec/data/blueprints/m_n_model.json +104 -0
  238. data/spec/data/blueprints/model_module.json +25 -0
  239. data/spec/data/blueprints/test_blueprint.json +38 -0
  240. data/spec/data/blueprints/test_project_model_spec.json +106 -0
  241. data/spec/data/cc/data/source/commits.csv +4 -0
  242. data/spec/data/cc/data/source/devs.csv +4 -0
  243. data/spec/data/cc/data/source/repos.csv +3 -0
  244. data/spec/data/cc/devel.prm +0 -0
  245. data/spec/data/cc/graph/graph.grf +11 -0
  246. data/spec/data/cc/workspace.prm +19 -0
  247. data/spec/data/column_based_permissions.csv +7 -0
  248. data/spec/data/column_based_permissions2.csv +6 -0
  249. data/spec/data/gd_gse_data_blueprint.json +1371 -0
  250. data/spec/data/gd_gse_data_manifest.json +1424 -0
  251. data/spec/data/gd_gse_data_model.json +1772 -0
  252. data/spec/data/gooddata_version_process/gooddata_version.rb +9 -0
  253. data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
  254. data/spec/data/hello_world_process/hello_world.rb +9 -0
  255. data/spec/data/hello_world_process/hello_world.zip +0 -0
  256. data/spec/data/line_based_permissions.csv +3 -0
  257. data/spec/data/manifests/test_blueprint.json +32 -0
  258. data/spec/data/manifests/test_project.json +107 -0
  259. data/spec/data/reports/left_attr_report.json +108 -0
  260. data/spec/data/reports/metric_only_one_line.json +83 -0
  261. data/spec/data/reports/report_1.json +197 -0
  262. data/spec/data/reports/top_attr_report.json +108 -0
  263. data/spec/data/ruby_params_process/ruby_params.rb +9 -0
  264. data/spec/data/ruby_process/deep_files/deep_stuff.txt +1 -0
  265. data/spec/data/ruby_process/process.rb +8 -0
  266. data/spec/data/ruby_process/stuff.txt +1 -0
  267. data/spec/data/superfluous_titles_view.json +81 -0
  268. data/spec/data/test-ci-data.csv +2 -0
  269. data/spec/data/users.csv +12 -0
  270. data/spec/data/wire_models/model_view.json +1775 -0
  271. data/spec/data/wire_models/nu_model.json +3046 -0
  272. data/spec/data/wire_models/test_blueprint.json +63 -0
  273. data/spec/data/wire_test_project.json +150 -0
  274. data/spec/environment/default.rb +41 -0
  275. data/spec/environment/develop.rb +31 -0
  276. data/spec/environment/environment.rb +18 -0
  277. data/spec/environment/hotfix.rb +21 -0
  278. data/spec/environment/production.rb +35 -0
  279. data/spec/environment/release.rb +21 -0
  280. data/spec/environment/staging.rb +30 -0
  281. data/spec/environment/staging_3.rb +36 -0
  282. data/spec/helpers/blueprint_helper.rb +26 -0
  283. data/spec/helpers/cli_helper.rb +36 -0
  284. data/spec/helpers/connection_helper.rb +41 -0
  285. data/spec/helpers/crypto_helper.rb +17 -0
  286. data/spec/helpers/csv_helper.rb +18 -0
  287. data/spec/helpers/process_helper.rb +33 -0
  288. data/spec/helpers/project_helper.rb +59 -0
  289. data/spec/helpers/schedule_helper.rb +31 -0
  290. data/spec/helpers/spec_helper.rb +15 -0
  291. data/spec/integration/blueprint_updates_spec.rb +101 -0
  292. data/spec/integration/blueprint_with_grain_spec.rb +72 -0
  293. data/spec/integration/clients_spec.rb +134 -0
  294. data/spec/integration/command_datawarehouse_spec.rb +39 -0
  295. data/spec/integration/command_projects_spec.rb +32 -0
  296. data/spec/integration/create_from_template_spec.rb +22 -0
  297. data/spec/integration/create_project_spec.rb +24 -0
  298. data/spec/integration/date_dim_switch_spec.rb +142 -0
  299. data/spec/integration/deprecated_load_spec.rb +58 -0
  300. data/spec/integration/full_process_schedule_spec.rb +298 -0
  301. data/spec/integration/full_project_spec.rb +569 -0
  302. data/spec/integration/over_to_user_filters_spec.rb +94 -0
  303. data/spec/integration/partial_md_export_import_spec.rb +42 -0
  304. data/spec/integration/project_spec.rb +264 -0
  305. data/spec/integration/rest_spec.rb +213 -0
  306. data/spec/integration/schedule_spec.rb +626 -0
  307. data/spec/integration/segments_spec.rb +141 -0
  308. data/spec/integration/user_filters_spec.rb +290 -0
  309. data/spec/integration/user_group_spec.rb +127 -0
  310. data/spec/integration/variables_spec.rb +188 -0
  311. data/spec/logging_in_logging_out_spec.rb +93 -0
  312. data/spec/spec_helper.rb +95 -0
  313. data/spec/unit/bricks/bricks_spec.rb +35 -0
  314. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +51 -0
  315. data/spec/unit/bricks/middleware/bench_middleware_spec.rb +15 -0
  316. data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +15 -0
  317. data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +15 -0
  318. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +15 -0
  319. data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +15 -0
  320. data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +15 -0
  321. data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +15 -0
  322. data/spec/unit/cli/cli_spec.rb +17 -0
  323. data/spec/unit/cli/commands/cmd_auth_spec.rb +17 -0
  324. data/spec/unit/commands/command_projects_spec.rb +22 -0
  325. data/spec/unit/core/connection_spec.rb +57 -0
  326. data/spec/unit/core/logging_spec.rb +133 -0
  327. data/spec/unit/core/nil_logger_spec.rb +13 -0
  328. data/spec/unit/core/project_spec.rb +54 -0
  329. data/spec/unit/extensions/hash_spec.rb +23 -0
  330. data/spec/unit/godzilla/goodzilla_spec.rb +78 -0
  331. data/spec/unit/helpers/csv_helper_spec.rb +22 -0
  332. data/spec/unit/helpers/data_helper_spec.rb +61 -0
  333. data/spec/unit/helpers/global_helpers_spec.rb +111 -0
  334. data/spec/unit/helpers_spec.rb +86 -0
  335. data/spec/unit/models/blueprint/attributes_spec.rb +29 -0
  336. data/spec/unit/models/blueprint/dataset_spec.rb +121 -0
  337. data/spec/unit/models/blueprint/labels_spec.rb +44 -0
  338. data/spec/unit/models/blueprint/project_blueprint_spec.rb +648 -0
  339. data/spec/unit/models/blueprint/reference_spec.rb +29 -0
  340. data/spec/unit/models/blueprint/schema_builder_spec.rb +38 -0
  341. data/spec/unit/models/blueprint/to_wire_spec.rb +174 -0
  342. data/spec/unit/models/domain_spec.rb +144 -0
  343. data/spec/unit/models/execution_spec.rb +108 -0
  344. data/spec/unit/models/from_wire_spec.rb +296 -0
  345. data/spec/unit/models/invitation_spec.rb +17 -0
  346. data/spec/unit/models/membership_spec.rb +132 -0
  347. data/spec/unit/models/metadata_spec.rb +104 -0
  348. data/spec/unit/models/metric_spec.rb +117 -0
  349. data/spec/unit/models/model_spec.rb +82 -0
  350. data/spec/unit/models/params_spec.rb +118 -0
  351. data/spec/unit/models/profile_spec.rb +215 -0
  352. data/spec/unit/models/project_creator_spec.rb +127 -0
  353. data/spec/unit/models/project_role_spec.rb +94 -0
  354. data/spec/unit/models/project_spec.rb +162 -0
  355. data/spec/unit/models/report_result_data_spec.rb +199 -0
  356. data/spec/unit/models/schedule_spec.rb +418 -0
  357. data/spec/unit/models/to_manifest_spec.rb +63 -0
  358. data/spec/unit/models/unit_project_spec.rb +125 -0
  359. data/spec/unit/models/user_filters_spec.rb +95 -0
  360. data/spec/unit/models/variable_spec.rb +265 -0
  361. data/spec/unit/rest/polling_spec.rb +89 -0
  362. data/spec/unit/rest/resource_spec.rb +10 -0
  363. data/yard-server.sh +3 -0
  364. metadata +1125 -0
@@ -0,0 +1,44 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2010-2015 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 GoodData::Model::LabelBlueprintField do
10
+
11
+ before(:each) do
12
+ @model_view = MultiJson.load(File.read('./spec/data/wire_models/model_view.json'))
13
+ @blueprint = GoodData::Model::FromWire.from_wire(@model_view)
14
+ @dataset = @blueprint.datasets('dataset.opportunityanalysis')
15
+ @attribute = @dataset.attributes('attr.opportunityanalysis.month')
16
+ end
17
+
18
+ describe '#attribute' do
19
+ it 'should return attribute on label' do
20
+ labels = @attribute.labels
21
+ expect(labels.count).to eq 2
22
+
23
+ expect(labels[0].attribute).to eq @attribute
24
+ expect(labels[1].attribute).to eq @attribute
25
+
26
+ expect(labels[0].dataset_blueprint).to eq @dataset
27
+ expect(labels[1].dataset_blueprint).to eq @dataset
28
+ end
29
+ end
30
+
31
+ describe '#gd_type' do
32
+ it 'should return attribute on label' do
33
+ label = @blueprint.datasets('dataset.opportunityanalysis').labels('label.opportunityanalysis.techoppanalysis')
34
+ expect(label.gd_type).to eq 'GDC.text'
35
+ end
36
+ end
37
+
38
+ describe '#gd_datatype' do
39
+ it 'should return attribute on label' do
40
+ label = @blueprint.datasets('dataset.opportunityanalysis').labels('label.opportunityanalysis.techoppanalysis')
41
+ expect(label.gd_data_type).to eq 'VARCHAR(128)'
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,648 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2010-2015 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 GoodData::Model::ProjectBlueprint do
10
+
11
+ before(:each) do
12
+ @blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprints/test_project_model_spec.json')
13
+ @invalid_blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprints/invalid_blueprint.json')
14
+ @spec_blueprint = GoodData::Model::FromWire.from_wire(MultiJson.load(File.read('./spec/data/wire_models/model_view.json')))
15
+ @repos = @blueprint.find_dataset('dataset.repos')
16
+ @commits = @blueprint.find_dataset('dataset.commits')
17
+ end
18
+
19
+ describe '#title' do
20
+ it "should return the title" do
21
+ expect(@blueprint.title).to eq "RubyGem Dev Week test"
22
+ end
23
+ end
24
+
25
+ describe '#valid?' do
26
+ it 'valid blueprint should be marked as valid' do
27
+ expect(@blueprint.valid?).to eq true
28
+ end
29
+
30
+ it 'model should be invalid if it contains more than one anchor' do
31
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
32
+ p.add_dataset("dataset.repos") do |d|
33
+ d.add_anchor("repo_id")
34
+ d.add_anchor("repo_id2")
35
+ d.add_fact("numbers")
36
+ d.add_attribute("name")
37
+ end
38
+ end
39
+ expect(bp.valid?).to be_falsey
40
+ errors = bp.validate
41
+ expect(errors.map {|x| x[:type]}.to_set).to eq [:attribute_without_label, :more_than_on_anchor].to_set
42
+ expect(errors.count).to eq 2
43
+ end
44
+
45
+ it 'model should be invalid if it contains no anchor' do
46
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
47
+ p.add_dataset("dataset.repos") do |d|
48
+ d.add_fact("numbers")
49
+ d.add_attribute("name")
50
+ d.add_label('some_label', reference: 'name')
51
+ end
52
+ end
53
+ expect(bp.valid?).to be_falsey
54
+ errors = bp.validate
55
+ expect(errors.first[:type]).to eq :no_anchor
56
+ expect(errors.count).to eq 1
57
+ end
58
+
59
+ it 'model should be invalid if it has invalid gd data type' do
60
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
61
+ p.add_dataset("dataset.repos") do |d|
62
+ d.add_anchor("attr.repository", label_id: 'label.repo.name', label_gd_data_type: "INTEGERX")
63
+ d.add_attribute("attr.attribute1", title: 'Some attribute')
64
+ d.add_label('label.attribute1.name', gd_data_type: "SOMEOTHER", reference: "attr.attribute1")
65
+ end
66
+ end
67
+ expect(bp.valid?).to be_falsey
68
+ errors = bp.validate
69
+ expect(errors.count).to eq 2
70
+ end
71
+
72
+ it 'model should be valid if it has int specified as integer and default should be decimal' do
73
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
74
+ p.add_dataset("dataset.repos") do |d|
75
+ d.add_anchor("attr.repository")
76
+ d.add_label('label.repository.name', reference: 'attr.repository')
77
+ d.add_attribute("attr.attribute1", title: 'Some attribute')
78
+ d.add_label('label.attribute1.name', reference: 'attr.attribute1')
79
+ d.add_fact('some_numbers', gd_data_type: 'INT')
80
+ d.add_fact('more_numbers')
81
+ end
82
+ end
83
+ bp.valid?.should == true
84
+ errors = bp.validate
85
+ expect(errors.count).to eq 0
86
+ facts = bp.to_wire[:diffRequest][:targetModel][:projectModel][:datasets].first[:dataset][:facts]
87
+ expect(facts[0][:fact][:dataType]).to eq 'INT'
88
+ expect(facts[1][:fact][:dataType]).to eq 'DECIMAL(12,2)'
89
+ end
90
+
91
+ it 'invalid blueprint should be marked as invalid' do
92
+ expect(@invalid_blueprint.valid?).to eq false
93
+ end
94
+ end
95
+
96
+ describe '#validate' do
97
+ it 'valid blueprint should give you empty array of errors' do
98
+ expect(@blueprint.validate).to be_empty
99
+ end
100
+
101
+ it 'invalid blueprint should give you list of violating references' do
102
+ errors = @invalid_blueprint.validate
103
+ expect(errors.size).to eq 1
104
+ expect(errors).to eq([{
105
+ :type=>:wrong_label_reference,
106
+ :label=>"some_label_id",
107
+ :wrong_reference=>"attr.repos.repo_id ERROR"
108
+ }])
109
+ end
110
+
111
+ it 'invalid label is caught correctly' do
112
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
113
+ p.add_dataset("dataset.repos") do |d|
114
+ d.add_anchor("attr.repository", label_id: 'label.repo.name')
115
+ d.add_attribute("attr.attribute1", title: 'Some attribute')
116
+ d.add_label('label.attribute1.name', reference: 'attr.attribute23123')
117
+ d.add_label('label.attribute1.ssn', reference: 'attr.attribute23123')
118
+ d.add_fact('some_numbers', gd_data_type: 'INT')
119
+ d.add_fact('more_numbers')
120
+ end
121
+ end
122
+ expect(bp.valid?).to be_falsey
123
+ errors = bp.validate
124
+ expect(errors.count).to eq 3
125
+ expect(errors).to eq [
126
+ {
127
+ :type=>:wrong_label_reference,
128
+ :label=>"label.attribute1.name",
129
+ :wrong_reference=>"attr.attribute23123"
130
+ },
131
+ {
132
+ :type=>:wrong_label_reference,
133
+ :label=>"label.attribute1.ssn",
134
+ :wrong_reference=>"attr.attribute23123"
135
+ },
136
+ {
137
+ :type=>:attribute_without_label,
138
+ :attribute=>"attr.attribute1"
139
+ }
140
+ ]
141
+ end
142
+ end
143
+
144
+ describe '#remove_dataset!' do
145
+ it "should be able to remove dataset by name" do
146
+ expect(@blueprint.datasets.count).to eq 3
147
+ bp = @blueprint.remove_dataset!('dataset.repos')
148
+ expect(bp).to be_kind_of(GoodData::Model::ProjectBlueprint)
149
+ expect(@blueprint.datasets.count).to eq 2
150
+ end
151
+
152
+ it "should be able to remove dataset by reference" do
153
+ expect(@blueprint.datasets.count).to eq 3
154
+ dataset = @blueprint.find_dataset('dataset.repos')
155
+ bp = @blueprint.remove_dataset!(dataset)
156
+ expect(bp).to be_kind_of(GoodData::Model::ProjectBlueprint)
157
+ expect(@blueprint.datasets.count).to eq 2
158
+ end
159
+
160
+ it "should be able to remove dataset by name" do
161
+ expect(@blueprint.datasets.count).to eq 3
162
+ bp = GoodData::Model::ProjectBlueprint.remove_dataset!(@blueprint, 'dataset.repos')
163
+ expect(bp).to be_kind_of(Hash)
164
+ expect(@blueprint.datasets.count).to eq 2
165
+ end
166
+
167
+ it "should be able to remove dataset by reference" do
168
+ expect(@blueprint.datasets.count).to eq 3
169
+ dataset = @blueprint.find_dataset('dataset.repos')
170
+ bp = GoodData::Model::ProjectBlueprint.remove_dataset!(@blueprint, dataset)
171
+ expect(bp).to be_kind_of(Hash)
172
+ expect(@blueprint.datasets.count).to eq 2
173
+ end
174
+ end
175
+
176
+ describe '#references' do
177
+ it 'references return empty array if there is no reference' do
178
+ refs = @blueprint.find_dataset('dataset.devs').references
179
+ expect(refs).to be_empty
180
+ end
181
+ end
182
+
183
+ describe '#find_dataset' do
184
+ it 'should be able to get dataset by identifier' do
185
+ ds = @blueprint.find_dataset('dataset.devs')
186
+ expect(ds.id).to eq 'dataset.devs'
187
+ expect(ds).to be_kind_of(GoodData::Model::DatasetBlueprint)
188
+ end
189
+
190
+ it 'should throw an error if the dataset with a given name could not be found' do
191
+ expect { @blueprint.find_dataset('nonexisting_dataset') }.to raise_error
192
+ end
193
+
194
+ it "should be pssible to find a dataset using dataset" do
195
+ ds = @blueprint.find_dataset('dataset.devs')
196
+ sds = @blueprint.find_dataset(ds)
197
+ expect(ds).to eq sds
198
+ end
199
+ end
200
+
201
+ describe '#to_blueprint' do
202
+ it "should be possible to create ProjectBlueprint from SchemaBuilder" do
203
+ builder = GoodData::Model::SchemaBuilder.create("stuff") do |d|
204
+ d.add_anchor("anchor_id")
205
+ d.add_attribute("id", title: "My Id")
206
+ d.add_label("label", reference: "id")
207
+ d.add_fact("amount", title: "Amount")
208
+ end
209
+ bp2 = builder.to_blueprint
210
+ expect(bp2.valid?).to eq true
211
+ end
212
+
213
+ it "should be possible to create ProjectBlueprint from SchemaBuilder" do
214
+ builder = GoodData::Model::SchemaBuilder.create("stuff") do |d|
215
+ d.add_anchor("anchor_id")
216
+ d.add_attribute("id", title: "My Id")
217
+ d.add_label("label", reference: "id")
218
+ d.add_fact("amount", title: "Amount")
219
+ end
220
+
221
+ bp1 = GoodData::Model::ProjectBlueprint.new(builder)
222
+ expect(bp1.valid?).to eq true
223
+ end
224
+ end
225
+
226
+ describe '#dataset?' do
227
+ it 'should be able to tell me if ceratain dataset by name is in the blueprint' do
228
+ expect(@blueprint.dataset?('dataset.devs')).to be_truthy
229
+ end
230
+ end
231
+
232
+ describe '#anchor?' do
233
+ it 'should tell you it has anchor when it does' do
234
+ expect(@repos.anchor?).to eq true
235
+ end
236
+ end
237
+
238
+ describe '#anchor' do
239
+ it 'should tell you anchor does have labels' do
240
+ expect(@commits.anchor.labels.count).to eq 0
241
+ end
242
+
243
+ it 'anchor should have labels' do
244
+ expect(@repos.anchor.labels.first.id).to eq 'some_label_id'
245
+ end
246
+ end
247
+
248
+ describe '#attributes' do
249
+ it 'attribute should have labels' do
250
+ expect(@repos.attributes.first.labels.first.id).to eq 'some_attr_label_id'
251
+ end
252
+
253
+ it "should return attributes form all datasets" do
254
+ expect(@blueprint.attributes.count).to eq 1
255
+ end
256
+
257
+ it 'should be able to grab attribute' do
258
+ expect(@repos.labels.size).to eq 2
259
+ expect(@repos.labels('some_attr_label_id').attribute).to eq @repos.attributes('some_attr_id')
260
+ expect(@repos.labels('some_label_id').attribute.id).to eq 'attr.repos.repo_id'
261
+ end
262
+ end
263
+
264
+ describe '#facts' do
265
+ it 'commits should have one fact' do
266
+ expect(@commits.facts.size).to eq 1
267
+ end
268
+
269
+ it 'commits should have one fact' do
270
+ expect(@repos.facts.size).to eq 0
271
+ end
272
+
273
+ it "should return facts form all datasets" do
274
+ expect(@blueprint.facts.count).to eq 1
275
+ end
276
+ end
277
+
278
+ describe '#labels' do
279
+ it 'Anchor on repos should have a label' do
280
+ expect(@repos.anchor.labels.size).to eq 1
281
+ end
282
+
283
+ it 'should not have a label for a dataset without anchor with label' do
284
+ expect(@commits.anchor.labels).to eq []
285
+ end
286
+
287
+ it "should return labels form all datasets" do
288
+ expect(@blueprint.labels.count).to eq 4
289
+ end
290
+ end
291
+
292
+ describe '#attributes_and_anchors' do
293
+ it "should return labels form all datasets" do
294
+ expect(@blueprint.attributes_and_anchors.count).to eq 4
295
+ end
296
+ end
297
+
298
+ describe '#merge' do
299
+ it "should be able to merge models without mutating the original" do
300
+ additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/blueprints/additional_dataset_module.json")
301
+ expect(@blueprint.datasets.count).to eq 3
302
+ new_bp = @blueprint.merge(additional_blueprint)
303
+ expect(@blueprint.datasets.count).to eq 3
304
+ expect(new_bp.datasets.count).to eq 4
305
+ end
306
+
307
+ it "should perform merge in associative matter. Order should not matter." do
308
+ a = GoodData::Model::ProjectBlueprint.build("p") do |p|
309
+ p.add_date_dimension("updated_on")
310
+ p.add_dataset('stuff') do |d|
311
+ d.add_anchor('stuff_id')
312
+ d.add_label('name', reference: 'stuff_id')
313
+ d.add_date('updated_on')
314
+ end
315
+ end
316
+ b = GoodData::Model::ProjectBlueprint.build("p") do |p|
317
+ p.add_date_dimension("created_on")
318
+ p.add_dataset('stuff') do |d|
319
+ d.add_attribute('attr_id')
320
+ d.add_label('attr_name', reference: 'attr_id')
321
+ d.add_date('created_on')
322
+ end
323
+ end
324
+ # those two are the same. Notice that we have made the titles the same
325
+ # Merging titles is not associative
326
+ a_b = a.merge(b)
327
+ b_a = b.merge(a)
328
+ expect(a_b.valid?).to eq true
329
+ expect(b_a.valid?).to eq true
330
+ expect(b_a).to eq a_b
331
+ end
332
+
333
+ it "should perform merge in associative matter. Order should not matter." do
334
+ a = GoodData::Model::ProjectBlueprint.build("p") do |p|
335
+ p.add_date_dimension("updated_on")
336
+ p.add_dataset('stuff') do |d|
337
+ d.add_anchor('stuff_id')
338
+ d.add_label('name', reference: 'stuff_id')
339
+ d.add_date('updated_on')
340
+ end
341
+ end
342
+ b = GoodData::Model::ProjectBlueprint.build("p") do |p|
343
+ p.add_date_dimension("created_on")
344
+ p.add_dataset('stuff') do |d|
345
+ d.add_attribute('attr_id')
346
+ d.add_label('attr_name', reference: 'attr_id')
347
+ d.add_date('created_on')
348
+ end
349
+ end
350
+ # those two are the same. Notice that we have made the titles the same
351
+ # Merging titles is not associative
352
+ a_b = a.merge(b)
353
+ b_a = b.merge(a)
354
+ expect(a_b.valid?).to eq true
355
+ expect(b_a.valid?).to eq true
356
+ expect(b_a).to eq a_b
357
+ end
358
+
359
+ it "should fail if unable to merge date dimensions (they are different)." do
360
+ a = GoodData::Model::ProjectBlueprint.build("p") do |p|
361
+ p.add_date_dimension("created_on", title: 'title A')
362
+ p.add_dataset('stuff') do |d|
363
+ d.add_anchor('stuff_id')
364
+ d.add_label('name', reference: 'stuff_id')
365
+ d.add_date('created_on')
366
+ end
367
+ end
368
+ b = GoodData::Model::ProjectBlueprint.build("p") do |p|
369
+ p.add_date_dimension("created_on", title: 'title B')
370
+ p.add_dataset('stuff') do |d|
371
+ d.add_attribute('attr_id')
372
+ d.add_label('attr_name', reference: 'attr_id')
373
+ d.add_date('created_on')
374
+ end
375
+ end
376
+ expect {
377
+ c = a.merge(b)
378
+ }.to raise_exception 'Unable to merge date dimensions created_on with defintion {:type=>:date_dimension, :urn=>nil, :id=>"created_on", :title=>"title B"} with {:type=>:date_dimension, :urn=>nil, :id=>"created_on", :title=>"title A"}'
379
+ end
380
+ end
381
+
382
+ describe '#merge!' do
383
+ it "should be able to merge models" do
384
+ additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/blueprints/additional_dataset_module.json")
385
+ expect(@blueprint.datasets.count).to eq 3
386
+ @blueprint.merge!(additional_blueprint)
387
+ expect(@blueprint.datasets.count).to eq 4
388
+ end
389
+ end
390
+
391
+ it "should be able to add datasets on the fly" do
392
+ builder = GoodData::Model::SchemaBuilder.new("stuff") do |d|
393
+ d.add_attribute("id", title: "My Id")
394
+ d.add_fact("amount", title: "Amount")
395
+ end
396
+ dataset = builder.to_blueprint
397
+ expect(@blueprint.datasets.count).to eq 3
398
+ @blueprint.add_dataset!(dataset)
399
+ expect(@blueprint.datasets.count).to eq 4
400
+ end
401
+
402
+
403
+
404
+ it "should be able to serialize itself to a hash" do
405
+ ser = @blueprint.to_hash
406
+ ser.is_a?(Hash)
407
+ expect(ser.keys).to eq [:title, :datasets, :date_dimensions]
408
+ end
409
+
410
+ it "should be able to tell you whether a dataset is referencing any others including date dimensions" do
411
+ d = @blueprint.datasets('dataset.commits')
412
+ referenced_datasets = @blueprint.referenced_by(d)
413
+ expect(referenced_datasets.count).to eq 3
414
+ end
415
+
416
+ it "should be able to find star centers - datasets that are not referenced by any other - these are typical fact tables" do
417
+ centers = @blueprint.find_star_centers
418
+ expect(centers.count).to eq 1
419
+ expect(centers.first.id).to eq 'dataset.commits'
420
+ end
421
+
422
+ it "should be able to return all attributes or anchors that can break metrics computed in the context of given dataset" do
423
+ commits = @blueprint.datasets('dataset.commits')
424
+ expect(commits.broken_by.count).to eq 3
425
+ expect(commits.broken_by.map(&:id)).to eq ["attr.devs.dev_id", "some_attr_id", "attr.repos.repo_id"]
426
+ end
427
+
428
+ it 'blueprint can be set without date reference and default format is set' do
429
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
430
+ p.add_date_dimension("committed_on")
431
+
432
+ p.add_dataset("dataset.repos") do |d|
433
+ d.add_anchor("attr.repository")
434
+ d.add_label('label.repo.name')
435
+ d.add_attribute("attr.attribute1", title: 'Some attribute')
436
+ d.add_label('label.attribute1.name', reference: 'attr.attribute1')
437
+ d.add_label('label.attribute1.ssn', reference: 'attr.attribute1')
438
+ d.add_fact('some_numbers', gd_data_type: 'INT')
439
+ d.add_fact('more_numbers')
440
+ d.add_date('opportunity_comitted', dataset: 'committed_on')
441
+ end
442
+ end
443
+ expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map { |a| a.format }).to eq [GoodData::Model::DEFAULT_DATE_FORMAT]
444
+ end
445
+
446
+ it 'blueprint can be set with explicit date' do
447
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
448
+ p.add_date_dimension("committed_on")
449
+
450
+ p.add_dataset("dataset.repos") do |d|
451
+ d.add_anchor("attr.repository", label_id: 'label.repo.name')
452
+ d.add_attribute("attr.attribute1")
453
+ d.add_label('label.attribute1.name', title: 'Some attribute', reference: 'attr.attribute1')
454
+ d.add_label('label.attribute1.ssn', reference: 'attr.attribute1')
455
+ d.add_fact('some_numbers', gd_data_type: 'INT')
456
+ d.add_fact('more_numbers')
457
+ d.add_date('opportunity_comitted', dataset: 'committed_on', format: 'yyyy/MM/dd')
458
+ end
459
+ end
460
+ expect(bp.valid?).to be_truthy
461
+ expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map { |a| a.format }).to eq ['yyyy/MM/dd']
462
+ end
463
+
464
+ describe '#remove' do
465
+ it 'can remove the anchor' do
466
+ bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
467
+ p.add_dataset("dataset.repos") do |d|
468
+ d.add_anchor("attr.repository", label_id: 'label.repo.name')
469
+ d.add_label('label.repository.name', title: 'Some attribute', reference: 'attr.repository')
470
+ end
471
+ end
472
+ expect(bp.datasets('dataset.repos').anchor.labels.count).to eq 1
473
+ bp.datasets('dataset.repos').anchor.remove!
474
+ expect(bp.datasets('dataset.repos').anchor.labels.count).to eq 0
475
+ end
476
+ end
477
+
478
+ describe '#move!' do
479
+ it 'can move attribute around' do
480
+ expect(@blueprint.datasets('dataset.repos').fields.count).to eq 4
481
+ expect(@blueprint.datasets('dataset.commits').fields.count).to eq 5
482
+ attr_before = @blueprint.datasets('dataset.repos').attributes('some_attr_id')
483
+ expect(attr_before).to_not be_nil
484
+ expect(@blueprint.datasets('dataset.commits').attributes('some_attr_id')).to be_nil
485
+ expect(attr_before.labels.first.dataset_blueprint.id).to eq 'dataset.repos'
486
+ @blueprint.move!('some_attr_id', 'dataset.repos', 'dataset.commits')
487
+
488
+ attr_after = @blueprint.datasets('dataset.commits').attributes('some_attr_id')
489
+
490
+ expect(@blueprint.datasets('dataset.repos').fields.count).to eq 2
491
+ expect(@blueprint.datasets('dataset.commits').fields.count).to eq 7
492
+ expect(@blueprint.datasets('dataset.repos').attributes('some_attr_id')).to be_nil
493
+ expect(attr_after).to_not be_nil
494
+ expect(attr_after.labels.first.dataset_blueprint.id).to eq 'dataset.commits'
495
+ end
496
+
497
+ it 'can move fact around' do
498
+ @blueprint.move!('fact.commits.lines_changed', 'dataset.commits', 'dataset.repos')
499
+ expect(@blueprint.datasets('dataset.commits').facts.count).to eq 0
500
+ expect(@blueprint.datasets('dataset.repos').facts.count).to eq 1
501
+ end
502
+
503
+ it 'crashes gracefully when nonexistent field is being moved' do
504
+ expect {
505
+ @blueprint.move!('nonexistent_field', 'dataset.commits', 'dataset.repos')
506
+ }.to raise_exception 'Column nonexistent_field cannot be found in dataset dataset.commits'
507
+ end
508
+
509
+ it 'crashes gracefully when datasets does not exist' do
510
+ expect {
511
+ @blueprint.move!('nonexistent_field', 'dataset.A', 'dataset.repos')
512
+ }.to raise_exception 'Dataset "dataset.A" could not be found'
513
+ end
514
+
515
+ it 'crashes gracefully when datasets does not exist' do
516
+ expect {
517
+ @blueprint.move!('nonexistent_field', 'dataset.commits', 'dataset.B')
518
+ }.to raise_exception 'Dataset "dataset.B" could not be found'
519
+ end
520
+ end
521
+
522
+ it 'should be able to refactor facts from attributes' do
523
+ blueprint = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
524
+ p.add_dataset('opportunities') do |d|
525
+ d.add_anchor('opportunities.id')
526
+ d.add_fact('opportunities.age')
527
+ d.add_fact('opportunities.amount')
528
+ d.add_attribute('opportunities.name')
529
+ d.add_label('label.opportunities.name', reference: 'opportunities.name')
530
+ d.add_attribute('opportunities.region')
531
+ d.add_label('label.opportunities.region', reference: 'opportunities.region')
532
+ d.add_reference('user_id', dataset: 'users')
533
+ d.add_reference('account_id', dataset: 'accounts')
534
+ end
535
+
536
+ p.add_dataset('users') do |d|
537
+ d.add_anchor('users.id')
538
+ d.add_attribute('users.name')
539
+ d.add_label('label.users.name', reference: 'users.name')
540
+ end
541
+
542
+ p.add_dataset('accounts') do |d|
543
+ d.add_anchor('accounts.id')
544
+ d.add_attribute('accounts.name')
545
+ d.add_label('label.accounts.region', reference: 'accounts.name')
546
+ end
547
+ end
548
+
549
+ refactored = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
550
+ p.add_dataset('opportunities') do |d|
551
+ d.add_anchor('opportunities.id')
552
+ d.add_fact('opportunities.age')
553
+ d.add_fact('opportunities.amount')
554
+ d.add_reference('user_id', dataset: 'users')
555
+ d.add_reference('accounts')
556
+ d.add_reference('accounts')
557
+ d.add_reference('opportunities_dim')
558
+ end
559
+
560
+ p.add_dataset('opportunities_dim') do |d|
561
+ d.add_anchor('vymysli_id')
562
+ d.add_label('label.vymysli_id', reference: 'vymysli_id')
563
+
564
+ d.add_attribute('opportunities.name')
565
+ d.add_label('label.opportunities.name', reference: 'opportunities.name')
566
+ d.add_attribute('opportunities.region')
567
+ d.add_label('label.opportunities.region', reference: 'opportunities.region')
568
+ end
569
+
570
+ p.add_dataset('users') do |d|
571
+ d.add_anchor('users.id')
572
+ d.add_attribute('users.name')
573
+ d.add_label('label.users.name', reference: 'users.name')
574
+ end
575
+
576
+ p.add_dataset('accounts') do |d|
577
+ d.add_anchor('accounts.id')
578
+ d.add_attribute('accounts.name')
579
+ d.add_label('label.accounts.region', reference: 'accounts.name')
580
+ end
581
+ end
582
+ expect(blueprint.refactor_split_df('opportunities')).to eq refactored
583
+ end
584
+
585
+ it 'should be able to refactor facts as a split into 2 datasets' do
586
+ blueprint = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
587
+ p.add_dataset('opportunities') do |d|
588
+ d.add_anchor('opportunities.id')
589
+ d.add_fact('opportunities.age')
590
+ d.add_fact('opportunities.amount')
591
+ d.add_attribute('opportunities.name')
592
+ d.add_label('label.opportunities.name', reference: 'opportunities.name')
593
+ d.add_attribute('opportunities.region')
594
+ d.add_label('label.opportunities.region', reference: 'opportunities.region')
595
+ d.add_reference('user_id', dataset: 'users')
596
+ d.add_reference('account_id', dataset: 'accounts')
597
+ end
598
+
599
+ p.add_dataset('users') do |d|
600
+ d.add_anchor('users.id')
601
+ d.add_attribute('users.name')
602
+ d.add_label('label.users.name', reference: 'users.name')
603
+ end
604
+
605
+ p.add_dataset('accounts') do |d|
606
+ d.add_anchor('accounts.id')
607
+ d.add_attribute('accounts.name')
608
+ d.add_label('label.accounts.region', reference: 'accounts.name')
609
+ end
610
+ end
611
+
612
+ refactored = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
613
+ p.add_dataset('opportunities') do |d|
614
+ d.add_anchor('opportunities.id')
615
+ d.add_fact('opportunities.amount')
616
+ d.add_attribute('opportunities.name')
617
+ d.add_label('label.opportunities.name', reference: 'opportunities.name')
618
+ d.add_attribute('opportunities.region')
619
+ d.add_label('label.opportunities.region', reference: 'opportunities.region')
620
+ d.add_reference('user_id', dataset: 'users')
621
+ d.add_reference('account_id', dataset: 'accounts')
622
+ end
623
+
624
+ p.add_dataset('users') do |d|
625
+ d.add_anchor('users.id')
626
+ d.add_attribute('users.name')
627
+ d.add_label('label.users.name', reference: 'users.name')
628
+ end
629
+
630
+ p.add_dataset('accounts') do |d|
631
+ d.add_anchor('accounts.id')
632
+ d.add_attribute('accounts.name')
633
+ d.add_label('label.accounts.region', reference: 'accounts.name')
634
+ end
635
+
636
+ p.add_dataset('opportunities_age_fact') do |d|
637
+ d.add_anchor('opportunities_age_fact.id')
638
+ d.add_fact('opportunities.age')
639
+ d.add_reference('user_id', dataset: 'users')
640
+ d.add_reference('account_id', dataset: 'accounts')
641
+ end
642
+ end
643
+
644
+ col_names = ['opportunities.age']
645
+ # that should be possible to express with #refactor_split_facts
646
+ expect(blueprint.refactor_split_facts('opportunities', col_names, 'opportunities_age_fact')).to eq refactored
647
+ end
648
+ end