gooddata 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +0 -0
- data/.flayignore +2 -0
- data/.travis.yml +24 -7
- data/.yardopts +0 -0
- data/CHANGELOG.md +125 -1
- data/CLI.md +0 -0
- data/Dockerfile.jruby +7 -2
- data/Dockerfile.ruby +1 -1
- data/Gemfile +0 -0
- data/Guardfile +0 -0
- data/Rakefile +23 -9
- data/TODO.md +0 -0
- data/bin/gitflow-init.sh +8 -0
- data/ci.rake +3 -3
- data/data/2008.crt +39 -0
- data/data/new_ca.cer +22 -0
- data/dependency_decisions.yml +0 -0
- data/docker-compose.lcm.yml +31 -0
- data/docker-compose.yml +4 -2
- data/gooddata.gemspec +3 -3
- data/lcm.rake +288 -0
- data/lib/gooddata.rb +1 -0
- data/lib/gooddata/bricks/base_downloader.rb +1 -1
- data/lib/gooddata/bricks/brick.rb +0 -1
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +1 -1
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +1 -1
- data/lib/gooddata/bricks/pipeline.rb +67 -0
- data/lib/gooddata/bricks/provisioning_brick.rb +18 -0
- data/lib/gooddata/bricks/release_brick.rb +18 -0
- data/lib/gooddata/bricks/rollout_brick.rb +14 -0
- data/lib/gooddata/bricks/user_filters_brick.rb +13 -0
- data/lib/gooddata/bricks/users_brick.rb +13 -0
- data/lib/gooddata/core/logging.rb +1 -1
- data/lib/gooddata/exceptions/maql_execution.rb +1 -1
- data/lib/gooddata/extensions/string.rb +0 -0
- data/lib/gooddata/lcm/actions/associate_clients.rb +34 -8
- data/lib/gooddata/lcm/actions/collect_data_product.rb +8 -1
- data/lib/gooddata/lcm/actions/collect_segment_clients.rb +13 -23
- data/lib/gooddata/lcm/actions/collect_segments.rb +10 -0
- data/lib/gooddata/lcm/actions/synchronize_clients.rb +3 -1
- data/lib/gooddata/lcm/actions/synchronize_ldm.rb +61 -34
- data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +6 -4
- data/lib/gooddata/lcm/actions/update_release_table.rb +4 -12
- data/lib/gooddata/lcm/dsl/params_dsl.rb +0 -4
- data/lib/gooddata/lcm/dsl/type_dsl.rb +0 -4
- data/lib/gooddata/lcm/helpers/check_helper.rb +1 -1
- data/lib/gooddata/lcm/lcm2.rb +0 -2
- data/lib/gooddata/lcm/types/special/enum.rb +6 -0
- data/lib/gooddata/lcm/types/special/enum/synchronize_ldm.rb +20 -0
- data/lib/gooddata/lcm/types/special/types.rb +1 -1
- data/lib/gooddata/mixins/is_folder.rb +0 -0
- data/lib/gooddata/mixins/to_json.rb +0 -0
- data/lib/gooddata/mixins/uri_getter.rb +0 -0
- data/lib/gooddata/models/project_creator.rb +38 -30
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +1 -0
- data/lib/gooddata/rest/README.md +0 -0
- data/lib/gooddata/version.rb +1 -1
- data/lib/templates/bricks/brick.rb.erb +0 -0
- data/lib/templates/bricks/main.rb.erb +0 -0
- data/lib/templates/project/Goodfile.erb +0 -0
- data/lib/templates/project/data/commits.csv +0 -0
- data/lib/templates/project/data/devs.csv +0 -0
- data/lib/templates/project/data/repos.csv +0 -0
- data/lib/templates/project/model/model.rb.erb +0 -0
- metadata +21 -451
- data/lib/gooddata/lcm/actions/ensure_data_product.rb +0 -63
- data/spec/.rubocop.yml +0 -16
- data/spec/bricks/bricks_spec.rb +0 -110
- data/spec/bricks/default-config.json +0 -8
- data/spec/data/.gooddata +0 -4
- data/spec/data/blueprints/additional_dataset_module.json +0 -32
- data/spec/data/blueprints/attribute_sort_order_blueprint.json +0 -72
- data/spec/data/blueprints/big_blueprint_not_pruned.json +0 -2079
- data/spec/data/blueprints/invalid_blueprint.json +0 -103
- data/spec/data/blueprints/m_n_model.json +0 -104
- data/spec/data/blueprints/model_module.json +0 -25
- data/spec/data/blueprints/test_blueprint.json +0 -39
- data/spec/data/blueprints/test_project_model_spec.json +0 -106
- data/spec/data/cc/data/source/commits.csv +0 -4
- data/spec/data/cc/data/source/devs.csv +0 -4
- data/spec/data/cc/data/source/repos.csv +0 -3
- data/spec/data/cc/devel.prm +0 -0
- data/spec/data/cc/graph/graph.grf +0 -11
- data/spec/data/cc/workspace.prm +0 -19
- data/spec/data/column_based_permissions.csv +0 -7
- data/spec/data/column_based_permissions2.csv +0 -6
- data/spec/data/dynamic_schedule_params_table.csv +0 -7
- data/spec/data/gd_gse_data_blueprint.json +0 -1371
- data/spec/data/gd_gse_data_manifest.json +0 -1424
- data/spec/data/gd_gse_data_model.json +0 -1772
- data/spec/data/gooddata_version_process/gooddata_version.rb +0 -9
- data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
- data/spec/data/hello_world_process/hello_world.rb +0 -9
- data/spec/data/hello_world_process/hello_world.zip +0 -0
- data/spec/data/integration_model.json +0 -252
- data/spec/data/integration_policies.csv +0 -9134
- data/spec/data/line_based_permissions.csv +0 -3
- data/spec/data/manifests/test_blueprint.json +0 -32
- data/spec/data/manifests/test_project.json +0 -107
- data/spec/data/reports/left_attr_report.json +0 -108
- data/spec/data/reports/metric_only_one_line.json +0 -83
- data/spec/data/reports/report_1.json +0 -197
- data/spec/data/reports/top_attr_report.json +0 -108
- data/spec/data/ruby_params_process/ruby_params.rb +0 -9
- data/spec/data/ruby_process/deep_files/deep_stuff.txt +0 -1
- data/spec/data/ruby_process/process.rb +0 -8
- data/spec/data/ruby_process/stuff.txt +0 -1
- data/spec/data/superfluous_titles_view.json +0 -81
- data/spec/data/test-ci-data.csv +0 -2
- data/spec/data/user_filters.csv +0 -2
- data/spec/data/users.csv +0 -12
- data/spec/data/wire_models/attribute_sort_by_model.json +0 -73
- data/spec/data/wire_models/model_view.json +0 -1775
- data/spec/data/wire_models/nu_model.json +0 -3046
- data/spec/data/wire_models/test_blueprint.json +0 -66
- data/spec/data/wire_test_project.json +0 -150
- data/spec/data/workspace_table.csv +0 -3
- data/spec/environment/default.rb +0 -43
- data/spec/environment/development.rb +0 -32
- data/spec/environment/environment.rb +0 -38
- data/spec/environment/production.rb +0 -27
- data/spec/environment/staging.rb +0 -32
- data/spec/environment/testing.rb +0 -32
- data/spec/helpers/appstore_project_helper.rb +0 -221
- data/spec/helpers/blueprint_helper.rb +0 -27
- data/spec/helpers/cli_helper.rb +0 -38
- data/spec/helpers/connection_helper.rb +0 -43
- data/spec/helpers/constants.rb +0 -32
- data/spec/helpers/crypto_helper.rb +0 -19
- data/spec/helpers/csv_helper.rb +0 -20
- data/spec/helpers/process_helper.rb +0 -35
- data/spec/helpers/project_helper.rb +0 -74
- data/spec/helpers/schedule_helper.rb +0 -33
- data/spec/helpers/spec_helper.rb +0 -17
- data/spec/integration/ads_output_stage_spec.rb +0 -45
- data/spec/integration/blueprint_updates_spec.rb +0 -107
- data/spec/integration/blueprint_with_ca_spec.rb +0 -56
- data/spec/integration/blueprint_with_grain_spec.rb +0 -74
- data/spec/integration/channel_configuration_spec.rb +0 -67
- data/spec/integration/clients_spec.rb +0 -164
- data/spec/integration/command_datawarehouse_spec.rb +0 -45
- data/spec/integration/command_projects_spec.rb +0 -32
- data/spec/integration/commands/command_projects_spec.rb +0 -22
- data/spec/integration/connection_spec.rb +0 -37
- data/spec/integration/core/connection_spec.rb +0 -56
- data/spec/integration/core/logging_spec.rb +0 -132
- data/spec/integration/core/project_spec.rb +0 -54
- data/spec/integration/create_from_template_spec.rb +0 -29
- data/spec/integration/create_project_spec.rb +0 -27
- data/spec/integration/date_dim_switch_spec.rb +0 -154
- data/spec/integration/deprecated_load_spec.rb +0 -60
- data/spec/integration/full_process_schedule_spec.rb +0 -367
- data/spec/integration/full_project_spec.rb +0 -592
- data/spec/integration/helpers_spec.rb +0 -16
- data/spec/integration/lcm_spec.rb +0 -54
- data/spec/integration/mandatory_user_filter_spec.rb +0 -53
- data/spec/integration/mixins/id_to_uri_spec.rb +0 -56
- data/spec/integration/models/data_product_spec.rb +0 -71
- data/spec/integration/models/domain_spec.rb +0 -162
- data/spec/integration/models/invitation_spec.rb +0 -17
- data/spec/integration/models/label_spec.rb +0 -49
- data/spec/integration/models/membership_spec.rb +0 -127
- data/spec/integration/models/metadata/report_spec.rb +0 -54
- data/spec/integration/models/metric_spec.rb +0 -24
- data/spec/integration/models/params_spec.rb +0 -118
- data/spec/integration/models/process_spec.rb +0 -35
- data/spec/integration/models/profile_spec.rb +0 -210
- data/spec/integration/models/project_role_spec.rb +0 -94
- data/spec/integration/models/project_spec.rb +0 -225
- data/spec/integration/models/schedule_spec.rb +0 -477
- data/spec/integration/models/unit_project_spec.rb +0 -130
- data/spec/integration/over_to_user_filters_spec.rb +0 -98
- data/spec/integration/partial_md_export_import_spec.rb +0 -41
- data/spec/integration/project_spec.rb +0 -381
- data/spec/integration/rest_spec.rb +0 -214
- data/spec/integration/schedule_spec.rb +0 -611
- data/spec/integration/segments_spec.rb +0 -100
- data/spec/integration/subscription_spec.rb +0 -88
- data/spec/integration/urn_date_dim_spec.rb +0 -53
- data/spec/integration/user_filters_spec.rb +0 -310
- data/spec/integration/user_group_spec.rb +0 -147
- data/spec/integration/variables_spec.rb +0 -189
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/can_assign_a_custom_logger.yml +0 -2287
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/client_logs_when_given_custom_message.yml +0 -2287
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/has_the_request_id_logged_when_I_passed_it.yml +0 -2287
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_off/Disables_logging.yml +0 -2287
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_on/Enables_logging.yml +0 -2287
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project/Returns_project_assigned.yml +0 -354
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_nil.yml +0 -299
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_directly.yml +0 -354
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_ID.yml +0 -354
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_URL.yml +0 -354
- data/spec/integration/vcr_cassettes/GoodData_-_project/_with_project/Uses_project_specified.yml +0 -354
- data/spec/integration/vcr_cassettes/GoodData_Metric/all.yml +0 -2065
- data/spec/integration/vcr_cassettes/GoodData_Metric/should_be_able_to_update_folders.yml +0 -119
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/all.yml +0 -9812
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_get_json_containing_correct_id.yml +0 -174
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_return_nil_for_unknown_id.yml +0 -58
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_throw_BadRequest_for_-1.yml +0 -63
- data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_connect/Connects_using_username_and_password.yml +0 -299
- data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_disconnect/Connects_using_username_and_password.yml +0 -299
- data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_generate_request_id/Generates_a_non-empty_string.yml +0 -2287
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_/Should_list_user_groups_as_Array.yml +0 -56
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_add_members/Should_add_member.yml +0 -315
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_members/Should_return_members_as_array.yml +0 -54
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_remove_members/Should_remove_existing_members.yml +0 -258
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_save/updates_existing_group.yml +0 -159
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_set_members/Should_set_new_members.yml +0 -158
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/all.yml +0 -809
- data/spec/logging_in_logging_out_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -110
- data/spec/unit/actions/associate_clients_spec.rb +0 -48
- data/spec/unit/actions/collect_client_projects_spec.rb +0 -47
- data/spec/unit/actions/collect_clients_spec.rb +0 -65
- data/spec/unit/actions/collect_data_product_spec.rb +0 -58
- data/spec/unit/actions/collect_dynamic_schedule_params_spec.rb +0 -56
- data/spec/unit/actions/collect_meta_spec.rb +0 -88
- data/spec/unit/actions/collect_segment_clients_spec.rb +0 -82
- data/spec/unit/actions/collect_tagged_objects_spec.rb +0 -126
- data/spec/unit/actions/collect_users_brick_users_spec.rb +0 -36
- data/spec/unit/actions/create_segment_masters_spec.rb +0 -65
- data/spec/unit/actions/ensure_data_product_spec.rb +0 -39
- data/spec/unit/actions/ensure_technical_users_domain_spec.rb +0 -53
- data/spec/unit/actions/ensure_technical_users_project_spec.rb +0 -76
- data/spec/unit/actions/execute_schedules_spec.rb +0 -94
- data/spec/unit/actions/provision_clients_spec.rb +0 -46
- data/spec/unit/actions/purge_clients_spec.rb +0 -47
- data/spec/unit/actions/rename_existing_client_projects_spec.rb +0 -54
- data/spec/unit/actions/segments_filter_spec.rb +0 -46
- data/spec/unit/actions/shared_examples_for_user_actions.rb +0 -43
- data/spec/unit/actions/synchronize_cas_spec.rb +0 -58
- data/spec/unit/actions/synchronize_clients_spec.rb +0 -71
- data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +0 -206
- data/spec/unit/actions/synchronize_ldm_spec.rb +0 -70
- data/spec/unit/actions/synchronize_user_filters_spec.rb +0 -208
- data/spec/unit/actions/synchronize_user_groups_spec.rb +0 -49
- data/spec/unit/actions/synchronize_users_spec.rb +0 -180
- data/spec/unit/bricks/bricks_spec.rb +0 -34
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +0 -98
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +0 -15
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +0 -15
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +0 -15
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +0 -30
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +0 -15
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +0 -15
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +0 -15
- data/spec/unit/cli/cli_spec.rb +0 -17
- data/spec/unit/cli/commands/cmd_auth_spec.rb +0 -17
- data/spec/unit/core/nil_logger_spec.rb +0 -13
- data/spec/unit/extensions/hash_spec.rb +0 -22
- data/spec/unit/godzilla/goodzilla_spec.rb +0 -74
- data/spec/unit/helpers/check_helper_production_spec.rb +0 -34
- data/spec/unit/helpers/check_helper_spec.rb +0 -134
- data/spec/unit/helpers/csv_helper_spec.rb +0 -22
- data/spec/unit/helpers/data_helper_spec.rb +0 -67
- data/spec/unit/helpers/global_helpers_spec.rb +0 -264
- data/spec/unit/helpers_spec.rb +0 -254
- data/spec/unit/lcm/lcm2_spec.rb +0 -100
- data/spec/unit/lcm/user_bricks_helper_spec.rb +0 -58
- data/spec/unit/models/blueprint/attribute_sort_by_spec.rb +0 -20
- data/spec/unit/models/blueprint/attributes_spec.rb +0 -28
- data/spec/unit/models/blueprint/dataset_spec.rb +0 -120
- data/spec/unit/models/blueprint/label_blueprint_field_spec.rb +0 -43
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +0 -642
- data/spec/unit/models/blueprint/reference_spec.rb +0 -28
- data/spec/unit/models/blueprint/schema_builder_spec.rb +0 -36
- data/spec/unit/models/blueprint/to_wire_spec.rb +0 -196
- data/spec/unit/models/dataset_blueprint.rb +0 -14
- data/spec/unit/models/execution_spec.rb +0 -109
- data/spec/unit/models/from_wire_spec.rb +0 -321
- data/spec/unit/models/metadata_spec.rb +0 -140
- data/spec/unit/models/metric_spec.rb +0 -129
- data/spec/unit/models/model_spec.rb +0 -87
- data/spec/unit/models/project_creator_spec.rb +0 -90
- data/spec/unit/models/project_spec.rb +0 -94
- data/spec/unit/models/report_result_data_spec.rb +0 -194
- data/spec/unit/models/to_manifest_spec.rb +0 -165
- data/spec/unit/models/user_filters/user_filter_builder_spec.rb +0 -149
- data/spec/unit/models/user_filters_spec.rb +0 -95
- data/spec/unit/models/variable_spec.rb +0 -280
- data/spec/unit/rest/phmap_spec.rb +0 -117
- data/spec/unit/rest/polling_spec.rb +0 -101
- data/spec/unit/rest/resource_spec.rb +0 -10
- data/spec/vcr_configurer.rb +0 -63
@@ -1,120 +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 GoodData::Model::DatasetBlueprint do
|
10
|
-
before(:each) do
|
11
|
-
@model_view = MultiJson.load(File.read('./spec/data/wire_models/model_view.json'))
|
12
|
-
@blueprint = GoodData::Model::FromWire.from_wire(@model_view)
|
13
|
-
@dataset = @blueprint.datasets('dataset.opportunityanalysis')
|
14
|
-
@small_blueprint = GoodData::Model::ProjectBlueprint.build('my_bp') do |p|
|
15
|
-
p.add_dataset('dataset.countries') do |d|
|
16
|
-
d.add_anchor('attr.country')
|
17
|
-
d.add_label('label.country.name', reference: 'attr.country')
|
18
|
-
end
|
19
|
-
p.add_dataset('dataset.repos') do |d|
|
20
|
-
d.add_anchor('attr.repository')
|
21
|
-
d.add_label('label.repo.name', reference: 'attr.repository')
|
22
|
-
d.add_reference('dataset.countries')
|
23
|
-
end
|
24
|
-
p.add_dataset('dataset.devs') do |d|
|
25
|
-
d.add_anchor('attr.dev')
|
26
|
-
d.add_label('label.dev.name', reference: 'attr.dev')
|
27
|
-
end
|
28
|
-
p.add_dataset('dataset.commits') do |d|
|
29
|
-
d.add_anchor('attr.commits')
|
30
|
-
d.add_attribute('attr.quality')
|
31
|
-
d.add_label('label.quality', reference: 'attr.quality')
|
32
|
-
d.add_fact('more_numbers')
|
33
|
-
d.add_reference('dataset.repos')
|
34
|
-
d.add_reference('dataset.devs')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#facts' do
|
40
|
-
it 'should return facts on dataset' do
|
41
|
-
expect(@dataset.facts.count).to eq 2
|
42
|
-
expect(@dataset.facts.map(&:id).to_set).to eq [
|
43
|
-
'fact.opportunityanalysis.buckets_to_display',
|
44
|
-
'fact.opportunityanalysis.month_fact'
|
45
|
-
].to_set
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should be able to pick specific fact' do
|
49
|
-
expect(@dataset.facts('fact.opportunityanalysis.buckets_to_display').id).to eq 'fact.opportunityanalysis.buckets_to_display'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#attributes' do
|
54
|
-
it 'should return attributes on dataset' do
|
55
|
-
expect(@dataset.attributes.count).to eq 2
|
56
|
-
expect(@dataset.attributes.map(&:id).to_set).to eq [
|
57
|
-
'attr.opportunityanalysis.month',
|
58
|
-
'attr.opportunityanalysis.cohorttype'
|
59
|
-
].to_set
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should return attributes on dataset' do
|
63
|
-
expect(@dataset.attributes('attr.opportunityanalysis.cohorttype').id).to eq 'attr.opportunityanalysis.cohorttype'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#labels' do
|
68
|
-
it 'should return labels on dataset' do
|
69
|
-
expect(@dataset.labels.count).to eq 4
|
70
|
-
expect(@dataset.labels.map(&:id).to_set).to eq [
|
71
|
-
'label.opportunityanalysis.month.monthsortingnew',
|
72
|
-
'label.opportunityanalysis.month',
|
73
|
-
'label.opportunityanalysis.cohorttype',
|
74
|
-
'label.opportunityanalysis.techoppanalysis'
|
75
|
-
].to_set
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#references' do
|
80
|
-
it 'should return references on dataset' do
|
81
|
-
expect(@dataset.references.count).to eq 2
|
82
|
-
expect(@dataset.references.map { |r| r.data[:dataset] }).to eq [
|
83
|
-
'dataset.opp_records',
|
84
|
-
'dataset.consolidatedmarketingstatus'
|
85
|
-
]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe '#referenced_by' do
|
90
|
-
it 'should return datasets that are referencing this one' do
|
91
|
-
expect(@dataset.referenced_by).to eq []
|
92
|
-
dimension = @blueprint.datasets('dataset.opp_records')
|
93
|
-
expect(dimension.referenced_by.map(&:id)).to eq ['dataset.opportunityanalysis']
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#referencing' do
|
98
|
-
it 'should return datasets that are referenced by this one (the references in the dataset leads to those datasets)' do
|
99
|
-
expect(@dataset.referencing.map(&:id)).to eq ['dataset.opp_records', 'dataset.consolidatedmarketingstatus']
|
100
|
-
dimension = @blueprint.datasets('dataset.productline')
|
101
|
-
expect(dimension.referencing.map(&:id)).to be_empty
|
102
|
-
dimension = @blueprint.datasets('dataset.opp_records')
|
103
|
-
expect(dimension.referencing.map(&:id).count).to eq 28
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe '#breaks' do
|
108
|
-
it 'should return attributes that the dataset can break' do
|
109
|
-
expect(@small_blueprint.datasets('dataset.countries').breaks.map(&:id)).to eq ['attr.country', 'attr.repository', 'attr.quality']
|
110
|
-
expect(@small_blueprint.datasets('dataset.devs').breaks.map(&:id)).to eq ['attr.dev', 'attr.quality']
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#broken_by' do
|
115
|
-
it 'should return attributes that the dataset can be broken by' do
|
116
|
-
expect(@small_blueprint.datasets('dataset.commits').broken_by.map(&:id)).to eq ['attr.quality', 'attr.repository', 'attr.country', 'attr.dev']
|
117
|
-
expect(@small_blueprint.datasets('dataset.devs').broken_by.map(&:id)).to eq ['attr.dev']
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
@@ -1,43 +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 GoodData::Model::LabelBlueprintField do
|
10
|
-
before(:each) do
|
11
|
-
@model_view = MultiJson.load(File.read('./spec/data/wire_models/model_view.json'))
|
12
|
-
@blueprint = GoodData::Model::FromWire.from_wire(@model_view)
|
13
|
-
@dataset = @blueprint.datasets('dataset.opportunityanalysis')
|
14
|
-
@attribute = @dataset.attributes('attr.opportunityanalysis.month')
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#attribute' do
|
18
|
-
it 'should return attribute on label' do
|
19
|
-
labels = @attribute.labels
|
20
|
-
expect(labels.count).to eq 2
|
21
|
-
|
22
|
-
expect(labels[0].attribute).to eq @attribute
|
23
|
-
expect(labels[1].attribute).to eq @attribute
|
24
|
-
|
25
|
-
expect(labels[0].dataset_blueprint).to eq @dataset
|
26
|
-
expect(labels[1].dataset_blueprint).to eq @dataset
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'reading the label' do
|
31
|
-
before do
|
32
|
-
@label = @blueprint.datasets('dataset.opportunityanalysis').labels('label.opportunityanalysis.techoppanalysis')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should return attribute on label' do
|
36
|
-
expect(@label.gd_type).to eq 'GDC.text'
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should return attribute on label' do
|
40
|
-
expect(@label.gd_data_type).to eq 'VARCHAR(128)'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,642 +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 GoodData::Model::ProjectBlueprint do
|
10
|
-
before(:each) do
|
11
|
-
@blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprints/test_project_model_spec.json')
|
12
|
-
@invalid_blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprints/invalid_blueprint.json')
|
13
|
-
@spec_blueprint = GoodData::Model::FromWire.from_wire(MultiJson.load(File.read('./spec/data/wire_models/model_view.json')))
|
14
|
-
@repos = @blueprint.find_dataset('dataset.repos')
|
15
|
-
@commits = @blueprint.find_dataset('dataset.commits')
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#title' do
|
19
|
-
it "should return the title" do
|
20
|
-
expect(@blueprint.title).to eq "RubyGem Dev Week test"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#valid?' do
|
25
|
-
it 'valid blueprint should be marked as valid' do
|
26
|
-
expect(@blueprint.valid?).to eq true
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'model should be invalid if it contains more than one anchor' do
|
30
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
31
|
-
p.add_dataset("dataset.repos") do |d|
|
32
|
-
d.add_anchor("repo_id")
|
33
|
-
d.add_anchor("repo_id2")
|
34
|
-
d.add_fact("numbers")
|
35
|
-
d.add_attribute("name")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
expect(bp.valid?).to be_falsey
|
39
|
-
errors = bp.validate
|
40
|
-
expect(errors.map { |x| x[:type] }.to_set).to eq [:attribute_without_label, :more_than_on_anchor].to_set
|
41
|
-
expect(errors.count).to eq 2
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'model should be invalid if it contains no anchor' do
|
45
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
46
|
-
p.add_dataset("dataset.repos") do |d|
|
47
|
-
d.add_fact("numbers")
|
48
|
-
d.add_attribute("name")
|
49
|
-
d.add_label('some_label', reference: 'name')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
expect(bp.valid?).to be_falsey
|
53
|
-
errors = bp.validate
|
54
|
-
expect(errors.first[:type]).to eq :no_anchor
|
55
|
-
expect(errors.count).to eq 1
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'model should be invalid if it has invalid gd data type' do
|
59
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
60
|
-
p.add_dataset("dataset.repos") do |d|
|
61
|
-
d.add_anchor("attr.repository", label_id: 'label.repo.name', label_gd_data_type: "INTEGERX")
|
62
|
-
d.add_attribute("attr.attribute1", title: 'Some attribute')
|
63
|
-
d.add_label('label.attribute1.name', gd_data_type: "SOMEOTHER", reference: "attr.attribute1")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
expect(bp.valid?).to be_falsey
|
67
|
-
errors = bp.validate
|
68
|
-
expect(errors.count).to eq 2
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'model should be valid if it has int specified as integer and default should be decimal' do
|
72
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
73
|
-
p.add_dataset("dataset.repos") do |d|
|
74
|
-
d.add_anchor("attr.repository")
|
75
|
-
d.add_label('label.repository.name', reference: 'attr.repository')
|
76
|
-
d.add_attribute("attr.attribute1", title: 'Some attribute')
|
77
|
-
d.add_label('label.attribute1.name', reference: 'attr.attribute1')
|
78
|
-
d.add_fact('some_numbers', gd_data_type: 'INT')
|
79
|
-
d.add_fact('more_numbers')
|
80
|
-
end
|
81
|
-
end
|
82
|
-
bp.valid?.should be_truthy
|
83
|
-
errors = bp.validate
|
84
|
-
expect(errors.count).to eq 0
|
85
|
-
facts = bp.to_wire[:diffRequest][:targetModel][:projectModel][:datasets].first[:dataset][:facts]
|
86
|
-
expect(facts[0][:fact][:dataType]).to eq 'INT'
|
87
|
-
expect(facts[1][:fact][:dataType]).to eq 'DECIMAL(12,2)'
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'invalid blueprint should be marked as invalid' do
|
91
|
-
expect(@invalid_blueprint.valid?).to eq false
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '#validate' do
|
96
|
-
it 'valid blueprint should give you empty array of errors' do
|
97
|
-
expect(@blueprint.validate).to be_empty
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'invalid blueprint should give you list of violating references' do
|
101
|
-
errors = @invalid_blueprint.validate
|
102
|
-
expect(errors.size).to eq 5
|
103
|
-
expect(errors).to match_array([
|
104
|
-
{
|
105
|
-
:type => :wrong_label_reference,
|
106
|
-
:label => "some_label_id",
|
107
|
-
:wrong_reference => "attr.repos.repo_id ERROR"
|
108
|
-
},
|
109
|
-
{
|
110
|
-
type: :invalid_identifier,
|
111
|
-
id: 'some_attr_id(hello)'
|
112
|
-
},
|
113
|
-
{
|
114
|
-
type: :duplicated_identifier,
|
115
|
-
id: 'some_label_id'
|
116
|
-
},
|
117
|
-
{
|
118
|
-
type: :wrong_label_reference,
|
119
|
-
label: "some_label_id",
|
120
|
-
wrong_reference: "some_attr_id"
|
121
|
-
},
|
122
|
-
{
|
123
|
-
type: :attribute_without_label,
|
124
|
-
attribute: "some_attr_id(hello)"
|
125
|
-
}
|
126
|
-
])
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'invalid label is caught correctly' do
|
130
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
131
|
-
p.add_dataset("dataset.repos") do |d|
|
132
|
-
d.add_anchor("attr.repository", label_id: 'label.repo.name')
|
133
|
-
d.add_attribute("attr.attribute1", title: 'Some attribute')
|
134
|
-
d.add_label('label.attribute1.name', reference: 'attr.attribute23123')
|
135
|
-
d.add_label('label.attribute1.ssn', reference: 'attr.attribute23123')
|
136
|
-
d.add_fact('some_numbers', gd_data_type: 'INT')
|
137
|
-
d.add_fact('more_numbers')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
expect(bp.valid?).to be_falsey
|
141
|
-
errors = bp.validate
|
142
|
-
expect(errors.count).to eq 3
|
143
|
-
expect(errors).to eq [
|
144
|
-
{
|
145
|
-
:type => :wrong_label_reference,
|
146
|
-
:label => "label.attribute1.name",
|
147
|
-
:wrong_reference => "attr.attribute23123"
|
148
|
-
},
|
149
|
-
{
|
150
|
-
:type => :wrong_label_reference,
|
151
|
-
:label => "label.attribute1.ssn",
|
152
|
-
:wrong_reference => "attr.attribute23123"
|
153
|
-
},
|
154
|
-
{
|
155
|
-
:type => :attribute_without_label,
|
156
|
-
:attribute => "attr.attribute1"
|
157
|
-
}
|
158
|
-
]
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe '#remove_dataset!' do
|
163
|
-
it "should be able to remove dataset by name" do
|
164
|
-
expect(@blueprint.datasets.count).to eq 3
|
165
|
-
bp = @blueprint.remove_dataset!('dataset.repos')
|
166
|
-
expect(bp).to be_kind_of(GoodData::Model::ProjectBlueprint)
|
167
|
-
expect(@blueprint.datasets.count).to eq 2
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should be able to remove dataset by reference" do
|
171
|
-
expect(@blueprint.datasets.count).to eq 3
|
172
|
-
dataset = @blueprint.find_dataset('dataset.repos')
|
173
|
-
bp = @blueprint.remove_dataset!(dataset)
|
174
|
-
expect(bp).to be_kind_of(GoodData::Model::ProjectBlueprint)
|
175
|
-
expect(@blueprint.datasets.count).to eq 2
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should be able to remove dataset by name" do
|
179
|
-
expect(@blueprint.datasets.count).to eq 3
|
180
|
-
bp = GoodData::Model::ProjectBlueprint.remove_dataset!(@blueprint, 'dataset.repos')
|
181
|
-
expect(bp).to be_kind_of(Hash)
|
182
|
-
expect(@blueprint.datasets.count).to eq 2
|
183
|
-
end
|
184
|
-
|
185
|
-
it "should be able to remove dataset by reference" do
|
186
|
-
expect(@blueprint.datasets.count).to eq 3
|
187
|
-
dataset = @blueprint.find_dataset('dataset.repos')
|
188
|
-
bp = GoodData::Model::ProjectBlueprint.remove_dataset!(@blueprint, dataset)
|
189
|
-
expect(bp).to be_kind_of(Hash)
|
190
|
-
expect(@blueprint.datasets.count).to eq 2
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
describe '#references' do
|
195
|
-
it 'references return empty array if there is no reference' do
|
196
|
-
refs = @blueprint.find_dataset('dataset.devs').references
|
197
|
-
expect(refs).to be_empty
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe '#find_dataset' do
|
202
|
-
it 'should be able to get dataset by identifier' do
|
203
|
-
ds = @blueprint.find_dataset('dataset.devs')
|
204
|
-
expect(ds.id).to eq 'dataset.devs'
|
205
|
-
expect(ds).to be_kind_of(GoodData::Model::DatasetBlueprint)
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'should throw an error if the dataset with a given name could not be found' do
|
209
|
-
expect { @blueprint.find_dataset('nonexisting_dataset') }.to raise_error
|
210
|
-
end
|
211
|
-
|
212
|
-
it "should be pssible to find a dataset using dataset" do
|
213
|
-
ds = @blueprint.find_dataset('dataset.devs')
|
214
|
-
sds = @blueprint.find_dataset(ds)
|
215
|
-
expect(ds).to eq sds
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe '#to_blueprint' do
|
220
|
-
it "should be possible to create ProjectBlueprint from SchemaBuilder" do
|
221
|
-
builder = GoodData::Model::SchemaBuilder.create("stuff") do |d|
|
222
|
-
d.add_anchor("anchor_id")
|
223
|
-
d.add_attribute("id", title: "My Id")
|
224
|
-
d.add_label("label", reference: "id")
|
225
|
-
d.add_fact("amount", title: "Amount")
|
226
|
-
end
|
227
|
-
bp2 = builder.to_blueprint
|
228
|
-
expect(bp2.valid?).to eq true
|
229
|
-
end
|
230
|
-
|
231
|
-
it "should be possible to create ProjectBlueprint from SchemaBuilder" do
|
232
|
-
builder = GoodData::Model::SchemaBuilder.create("stuff") do |d|
|
233
|
-
d.add_anchor("anchor_id")
|
234
|
-
d.add_attribute("id", title: "My Id")
|
235
|
-
d.add_label("label", reference: "id")
|
236
|
-
d.add_fact("amount", title: "Amount")
|
237
|
-
end
|
238
|
-
|
239
|
-
bp1 = GoodData::Model::ProjectBlueprint.new(builder)
|
240
|
-
expect(bp1.valid?).to eq true
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe '#dataset?' do
|
245
|
-
it 'should be able to tell me if ceratain dataset by name is in the blueprint' do
|
246
|
-
expect(@blueprint.dataset?('dataset.devs')).to be_truthy
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe '#anchor?' do
|
251
|
-
it 'should tell you it has anchor when it does' do
|
252
|
-
expect(@repos.anchor?).to eq true
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
describe '#anchor' do
|
257
|
-
it 'should tell you anchor does have labels' do
|
258
|
-
expect(@commits.anchor.labels.count).to eq 0
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'anchor should have labels' do
|
262
|
-
expect(@repos.anchor.labels.first.id).to eq 'some_label_id'
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
describe '#attributes' do
|
267
|
-
it 'attribute should have labels' do
|
268
|
-
expect(@repos.attributes.first.labels.first.id).to eq 'some_attr_label_id'
|
269
|
-
end
|
270
|
-
|
271
|
-
it "should return attributes form all datasets" do
|
272
|
-
expect(@blueprint.attributes.count).to eq 1
|
273
|
-
end
|
274
|
-
|
275
|
-
it 'should be able to grab attribute' do
|
276
|
-
expect(@repos.labels.size).to eq 2
|
277
|
-
expect(@repos.labels('some_attr_label_id').attribute).to eq @repos.attributes('some_attr_id')
|
278
|
-
expect(@repos.labels('some_label_id').attribute.id).to eq 'attr.repos.repo_id'
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
describe '#facts' do
|
283
|
-
it 'commits should have one fact' do
|
284
|
-
expect(@commits.facts.size).to eq 1
|
285
|
-
end
|
286
|
-
|
287
|
-
it 'commits should have one fact' do
|
288
|
-
expect(@repos.facts.size).to eq 0
|
289
|
-
end
|
290
|
-
|
291
|
-
it "should return facts form all datasets" do
|
292
|
-
expect(@blueprint.facts.count).to eq 1
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
describe '#labels' do
|
297
|
-
it 'Anchor on repos should have a label' do
|
298
|
-
expect(@repos.anchor.labels.size).to eq 1
|
299
|
-
end
|
300
|
-
|
301
|
-
it 'should not have a label for a dataset without anchor with label' do
|
302
|
-
expect(@commits.anchor.labels).to eq []
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should return labels form all datasets" do
|
306
|
-
expect(@blueprint.labels.count).to eq 4
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
describe '#attributes_and_anchors' do
|
311
|
-
it "should return labels form all datasets" do
|
312
|
-
expect(@blueprint.attributes_and_anchors.count).to eq 4
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe '#merge' do
|
317
|
-
it "should be able to merge models without mutating the original" do
|
318
|
-
additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/blueprints/additional_dataset_module.json")
|
319
|
-
expect(@blueprint.datasets.count).to eq 3
|
320
|
-
new_bp = @blueprint.merge(additional_blueprint)
|
321
|
-
expect(@blueprint.datasets.count).to eq 3
|
322
|
-
expect(new_bp.datasets.count).to eq 4
|
323
|
-
end
|
324
|
-
|
325
|
-
it "should perform merge in associative matter. Order should not matter." do
|
326
|
-
a = GoodData::Model::ProjectBlueprint.build("p") do |p|
|
327
|
-
p.add_date_dimension("updated_on")
|
328
|
-
p.add_dataset('stuff') do |d|
|
329
|
-
d.add_anchor('stuff_id')
|
330
|
-
d.add_label('name', reference: 'stuff_id')
|
331
|
-
d.add_date('updated_on')
|
332
|
-
end
|
333
|
-
end
|
334
|
-
b = GoodData::Model::ProjectBlueprint.build("p") do |p|
|
335
|
-
p.add_date_dimension("created_on")
|
336
|
-
p.add_dataset('stuff') do |d|
|
337
|
-
d.add_attribute('attr_id')
|
338
|
-
d.add_label('attr_name', reference: 'attr_id')
|
339
|
-
d.add_date('created_on')
|
340
|
-
end
|
341
|
-
end
|
342
|
-
# those two are the same. Notice that we have made the titles the same
|
343
|
-
# Merging titles is not associative
|
344
|
-
a_b = a.merge(b)
|
345
|
-
b_a = b.merge(a)
|
346
|
-
expect(a_b.valid?).to eq true
|
347
|
-
expect(b_a.valid?).to eq true
|
348
|
-
expect(b_a).to eq a_b
|
349
|
-
end
|
350
|
-
|
351
|
-
it "should perform merge in associative matter. Order should not matter." do
|
352
|
-
a = GoodData::Model::ProjectBlueprint.build("p") do |p|
|
353
|
-
p.add_date_dimension("updated_on")
|
354
|
-
p.add_dataset('stuff') do |d|
|
355
|
-
d.add_anchor('stuff_id')
|
356
|
-
d.add_label('name', reference: 'stuff_id')
|
357
|
-
d.add_date('updated_on')
|
358
|
-
end
|
359
|
-
end
|
360
|
-
b = GoodData::Model::ProjectBlueprint.build("p") do |p|
|
361
|
-
p.add_date_dimension("created_on")
|
362
|
-
p.add_dataset('stuff') do |d|
|
363
|
-
d.add_attribute('attr_id')
|
364
|
-
d.add_label('attr_name', reference: 'attr_id')
|
365
|
-
d.add_date('created_on')
|
366
|
-
end
|
367
|
-
end
|
368
|
-
# those two are the same. Notice that we have made the titles the same
|
369
|
-
# Merging titles is not associative
|
370
|
-
a_b = a.merge(b)
|
371
|
-
b_a = b.merge(a)
|
372
|
-
expect(a_b.valid?).to eq true
|
373
|
-
expect(b_a.valid?).to eq true
|
374
|
-
expect(b_a).to eq a_b
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
describe '#merge!' do
|
379
|
-
it "should be able to merge models" do
|
380
|
-
additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/blueprints/additional_dataset_module.json")
|
381
|
-
expect(@blueprint.datasets.count).to eq 3
|
382
|
-
@blueprint.merge!(additional_blueprint)
|
383
|
-
expect(@blueprint.datasets.count).to eq 4
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
it "should be able to add datasets on the fly" do
|
388
|
-
builder = GoodData::Model::SchemaBuilder.new("stuff") do |d|
|
389
|
-
d.add_attribute("id", title: "My Id")
|
390
|
-
d.add_fact("amount", title: "Amount")
|
391
|
-
end
|
392
|
-
dataset = builder.to_blueprint
|
393
|
-
expect(@blueprint.datasets.count).to eq 3
|
394
|
-
@blueprint.add_dataset!(dataset)
|
395
|
-
expect(@blueprint.datasets.count).to eq 4
|
396
|
-
end
|
397
|
-
|
398
|
-
it "should be able to serialize itself to a hash" do
|
399
|
-
ser = @blueprint.to_hash
|
400
|
-
ser.is_a?(Hash)
|
401
|
-
expect(ser.keys).to eq [:title, :datasets, :date_dimensions, :include_ca]
|
402
|
-
end
|
403
|
-
|
404
|
-
it "should be able to tell you whether a dataset is referencing any others including date dimensions" do
|
405
|
-
d = @blueprint.datasets('dataset.commits')
|
406
|
-
referenced_datasets = @blueprint.referenced_by(d)
|
407
|
-
expect(referenced_datasets.count).to eq 3
|
408
|
-
end
|
409
|
-
|
410
|
-
it "should be able to find star centers - datasets that are not referenced by any other - these are typical fact tables" do
|
411
|
-
centers = @blueprint.find_star_centers
|
412
|
-
expect(centers.count).to eq 1
|
413
|
-
expect(centers.first.id).to eq 'dataset.commits'
|
414
|
-
end
|
415
|
-
|
416
|
-
it "should be able to return all attributes or anchors that can break metrics computed in the context of given dataset" do
|
417
|
-
commits = @blueprint.datasets('dataset.commits')
|
418
|
-
expect(commits.broken_by.count).to eq 3
|
419
|
-
expect(commits.broken_by.map(&:id)).to eq ["attr.devs.dev_id", "some_attr_id", "attr.repos.repo_id"]
|
420
|
-
end
|
421
|
-
|
422
|
-
it 'blueprint can be set without date reference and default format is set' do
|
423
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
424
|
-
p.add_date_dimension("committed_on")
|
425
|
-
|
426
|
-
p.add_dataset("dataset.repos") do |d|
|
427
|
-
d.add_anchor("attr.repository")
|
428
|
-
d.add_label('label.repo.name')
|
429
|
-
d.add_attribute("attr.attribute1", title: 'Some attribute')
|
430
|
-
d.add_label('label.attribute1.name', reference: 'attr.attribute1')
|
431
|
-
d.add_label('label.attribute1.ssn', reference: 'attr.attribute1')
|
432
|
-
d.add_fact('some_numbers', gd_data_type: 'INT')
|
433
|
-
d.add_fact('more_numbers')
|
434
|
-
d.add_date('opportunity_comitted', dataset: 'committed_on')
|
435
|
-
end
|
436
|
-
end
|
437
|
-
expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map { |d| d.data[:format] }).to eq [GoodData::Model::DEFAULT_DATE_FORMAT]
|
438
|
-
end
|
439
|
-
|
440
|
-
it 'blueprint can be set with explicit date' do
|
441
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
442
|
-
p.add_date_dimension("committed_on")
|
443
|
-
|
444
|
-
p.add_dataset("dataset.repos") do |d|
|
445
|
-
d.add_anchor("attr.repository", label_id: 'label.repo.name')
|
446
|
-
d.add_attribute("attr.attribute1")
|
447
|
-
d.add_label('label.attribute1.name', title: 'Some attribute', reference: 'attr.attribute1')
|
448
|
-
d.add_label('label.attribute1.ssn', reference: 'attr.attribute1')
|
449
|
-
d.add_fact('some_numbers', gd_data_type: 'INT')
|
450
|
-
d.add_fact('more_numbers')
|
451
|
-
d.add_date('opportunity_comitted', dataset: 'committed_on', format: 'yyyy/MM/dd')
|
452
|
-
end
|
453
|
-
end
|
454
|
-
expect(bp.valid?).to be_truthy
|
455
|
-
expect(bp.datasets.flat_map { |d| d.find_columns_by_type(:date) }.map { |d| d.data[:format] }).to eq ['yyyy/MM/dd']
|
456
|
-
end
|
457
|
-
|
458
|
-
describe '#remove' do
|
459
|
-
it 'can remove the anchor' do
|
460
|
-
bp = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
461
|
-
p.add_dataset("dataset.repos") do |d|
|
462
|
-
d.add_anchor("attr.repository", label_id: 'label.repo.name')
|
463
|
-
d.add_label('label.repository.name', title: 'Some attribute', reference: 'attr.repository')
|
464
|
-
end
|
465
|
-
end
|
466
|
-
expect(bp.datasets('dataset.repos').anchor.labels.count).to eq 1
|
467
|
-
bp.datasets('dataset.repos').anchor.remove!
|
468
|
-
expect(bp.datasets('dataset.repos').anchor.labels.count).to eq 0
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
|
-
describe '#move!' do
|
473
|
-
it 'can move attribute around' do
|
474
|
-
expect(@blueprint.datasets('dataset.repos').fields.count).to eq 4
|
475
|
-
expect(@blueprint.datasets('dataset.commits').fields.count).to eq 5
|
476
|
-
attr_before = @blueprint.datasets('dataset.repos').attributes('some_attr_id')
|
477
|
-
expect(attr_before).to_not be_nil
|
478
|
-
expect(@blueprint.datasets('dataset.commits').attributes('some_attr_id')).to be_nil
|
479
|
-
expect(attr_before.labels.first.dataset_blueprint.id).to eq 'dataset.repos'
|
480
|
-
@blueprint.move!('some_attr_id', 'dataset.repos', 'dataset.commits')
|
481
|
-
|
482
|
-
attr_after = @blueprint.datasets('dataset.commits').attributes('some_attr_id')
|
483
|
-
|
484
|
-
expect(@blueprint.datasets('dataset.repos').fields.count).to eq 2
|
485
|
-
expect(@blueprint.datasets('dataset.commits').fields.count).to eq 7
|
486
|
-
expect(@blueprint.datasets('dataset.repos').attributes('some_attr_id')).to be_nil
|
487
|
-
expect(attr_after).to_not be_nil
|
488
|
-
expect(attr_after.labels.first.dataset_blueprint.id).to eq 'dataset.commits'
|
489
|
-
end
|
490
|
-
|
491
|
-
it 'can move fact around' do
|
492
|
-
@blueprint.move!('fact.commits.lines_changed', 'dataset.commits', 'dataset.repos')
|
493
|
-
expect(@blueprint.datasets('dataset.commits').facts.count).to eq 0
|
494
|
-
expect(@blueprint.datasets('dataset.repos').facts.count).to eq 1
|
495
|
-
end
|
496
|
-
|
497
|
-
it 'crashes gracefully when nonexistent field is being moved' do
|
498
|
-
expect do
|
499
|
-
@blueprint.move!('nonexistent_field', 'dataset.commits', 'dataset.repos')
|
500
|
-
end.to raise_exception 'Column nonexistent_field cannot be found in dataset dataset.commits'
|
501
|
-
end
|
502
|
-
|
503
|
-
it 'crashes gracefully when datasets does not exist' do
|
504
|
-
expect do
|
505
|
-
@blueprint.move!('nonexistent_field', 'dataset.A', 'dataset.repos')
|
506
|
-
end.to raise_exception 'Dataset "dataset.A" could not be found'
|
507
|
-
end
|
508
|
-
|
509
|
-
it 'crashes gracefully when datasets does not exist' do
|
510
|
-
expect do
|
511
|
-
@blueprint.move!('nonexistent_field', 'dataset.commits', 'dataset.B')
|
512
|
-
end.to raise_exception 'Dataset "dataset.B" could not be found'
|
513
|
-
end
|
514
|
-
end
|
515
|
-
|
516
|
-
it 'should be able to refactor facts from attributes' do
|
517
|
-
blueprint = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
518
|
-
p.add_dataset('opportunities') do |d|
|
519
|
-
d.add_anchor('opportunities.id')
|
520
|
-
d.add_fact('opportunities.age')
|
521
|
-
d.add_fact('opportunities.amount')
|
522
|
-
d.add_attribute('opportunities.name')
|
523
|
-
d.add_label('label.opportunities.name', reference: 'opportunities.name')
|
524
|
-
d.add_attribute('opportunities.region')
|
525
|
-
d.add_label('label.opportunities.region', reference: 'opportunities.region')
|
526
|
-
d.add_reference('user_id', dataset: 'users')
|
527
|
-
d.add_reference('account_id', dataset: 'accounts')
|
528
|
-
end
|
529
|
-
|
530
|
-
p.add_dataset('users') do |d|
|
531
|
-
d.add_anchor('users.id')
|
532
|
-
d.add_attribute('users.name')
|
533
|
-
d.add_label('label.users.name', reference: 'users.name')
|
534
|
-
end
|
535
|
-
|
536
|
-
p.add_dataset('accounts') do |d|
|
537
|
-
d.add_anchor('accounts.id')
|
538
|
-
d.add_attribute('accounts.name')
|
539
|
-
d.add_label('label.accounts.region', reference: 'accounts.name')
|
540
|
-
end
|
541
|
-
end
|
542
|
-
|
543
|
-
refactored = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
544
|
-
p.add_dataset('opportunities') do |d|
|
545
|
-
d.add_anchor('opportunities.id')
|
546
|
-
d.add_fact('opportunities.age')
|
547
|
-
d.add_fact('opportunities.amount')
|
548
|
-
d.add_reference('user_id', dataset: 'users')
|
549
|
-
d.add_reference('accounts')
|
550
|
-
d.add_reference('accounts')
|
551
|
-
d.add_reference('opportunities_dim')
|
552
|
-
end
|
553
|
-
|
554
|
-
p.add_dataset('opportunities_dim') do |d|
|
555
|
-
d.add_anchor('vymysli_id')
|
556
|
-
d.add_label('label.vymysli_id', reference: 'vymysli_id')
|
557
|
-
|
558
|
-
d.add_attribute('opportunities.name')
|
559
|
-
d.add_label('label.opportunities.name', reference: 'opportunities.name')
|
560
|
-
d.add_attribute('opportunities.region')
|
561
|
-
d.add_label('label.opportunities.region', reference: 'opportunities.region')
|
562
|
-
end
|
563
|
-
|
564
|
-
p.add_dataset('users') do |d|
|
565
|
-
d.add_anchor('users.id')
|
566
|
-
d.add_attribute('users.name')
|
567
|
-
d.add_label('label.users.name', reference: 'users.name')
|
568
|
-
end
|
569
|
-
|
570
|
-
p.add_dataset('accounts') do |d|
|
571
|
-
d.add_anchor('accounts.id')
|
572
|
-
d.add_attribute('accounts.name')
|
573
|
-
d.add_label('label.accounts.region', reference: 'accounts.name')
|
574
|
-
end
|
575
|
-
end
|
576
|
-
expect(blueprint.refactor_split_df('opportunities')).to eq refactored
|
577
|
-
end
|
578
|
-
|
579
|
-
it 'should be able to refactor facts as a split into 2 datasets' do
|
580
|
-
blueprint = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
581
|
-
p.add_dataset('opportunities') do |d|
|
582
|
-
d.add_anchor('opportunities.id')
|
583
|
-
d.add_fact('opportunities.age')
|
584
|
-
d.add_fact('opportunities.amount')
|
585
|
-
d.add_attribute('opportunities.name')
|
586
|
-
d.add_label('label.opportunities.name', reference: 'opportunities.name')
|
587
|
-
d.add_attribute('opportunities.region')
|
588
|
-
d.add_label('label.opportunities.region', reference: 'opportunities.region')
|
589
|
-
d.add_reference('user_id', dataset: 'users')
|
590
|
-
d.add_reference('account_id', dataset: 'accounts')
|
591
|
-
end
|
592
|
-
|
593
|
-
p.add_dataset('users') do |d|
|
594
|
-
d.add_anchor('users.id')
|
595
|
-
d.add_attribute('users.name')
|
596
|
-
d.add_label('label.users.name', reference: 'users.name')
|
597
|
-
end
|
598
|
-
|
599
|
-
p.add_dataset('accounts') do |d|
|
600
|
-
d.add_anchor('accounts.id')
|
601
|
-
d.add_attribute('accounts.name')
|
602
|
-
d.add_label('label.accounts.region', reference: 'accounts.name')
|
603
|
-
end
|
604
|
-
end
|
605
|
-
|
606
|
-
refactored = GoodData::Model::ProjectBlueprint.build("my_bp") do |p|
|
607
|
-
p.add_dataset('opportunities') do |d|
|
608
|
-
d.add_anchor('opportunities.id')
|
609
|
-
d.add_fact('opportunities.amount')
|
610
|
-
d.add_attribute('opportunities.name')
|
611
|
-
d.add_label('label.opportunities.name', reference: 'opportunities.name')
|
612
|
-
d.add_attribute('opportunities.region')
|
613
|
-
d.add_label('label.opportunities.region', reference: 'opportunities.region')
|
614
|
-
d.add_reference('user_id', dataset: 'users')
|
615
|
-
d.add_reference('account_id', dataset: 'accounts')
|
616
|
-
end
|
617
|
-
|
618
|
-
p.add_dataset('users') do |d|
|
619
|
-
d.add_anchor('users.id')
|
620
|
-
d.add_attribute('users.name')
|
621
|
-
d.add_label('label.users.name', reference: 'users.name')
|
622
|
-
end
|
623
|
-
|
624
|
-
p.add_dataset('accounts') do |d|
|
625
|
-
d.add_anchor('accounts.id')
|
626
|
-
d.add_attribute('accounts.name')
|
627
|
-
d.add_label('label.accounts.region', reference: 'accounts.name')
|
628
|
-
end
|
629
|
-
|
630
|
-
p.add_dataset('opportunities_age_fact') do |d|
|
631
|
-
d.add_anchor('opportunities_age_fact.id')
|
632
|
-
d.add_fact('opportunities.age')
|
633
|
-
d.add_reference('user_id', dataset: 'users')
|
634
|
-
d.add_reference('account_id', dataset: 'accounts')
|
635
|
-
end
|
636
|
-
end
|
637
|
-
|
638
|
-
col_names = ['opportunities.age']
|
639
|
-
# that should be possible to express with #refactor_split_facts
|
640
|
-
expect(blueprint.refactor_split_facts('opportunities', col_names, 'opportunities_age_fact')).to eq refactored
|
641
|
-
end
|
642
|
-
end
|