marty 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +11 -589
- data/Gemfile +9 -9
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -3
- data/app/components/marty/api_auth_view.rb +3 -3
- data/app/components/marty/api_config_view.rb +8 -8
- data/app/components/marty/api_log_view.rb +16 -20
- data/app/components/marty/auth_app.rb +6 -6
- data/app/components/marty/base_rule_view.rb +27 -19
- data/app/components/marty/config_view.rb +12 -9
- data/app/components/marty/data_grid_view.rb +26 -26
- data/app/components/marty/delorean_rule_view.rb +0 -1
- data/app/components/marty/event_view.rb +27 -27
- data/app/components/marty/extras/layout.rb +26 -26
- data/app/components/marty/extras/misc.rb +2 -2
- data/app/components/marty/grid.rb +13 -13
- data/app/components/marty/grid_append_only.rb +0 -1
- data/app/components/marty/import_type_view.rb +13 -13
- data/app/components/marty/import_view.rb +17 -16
- data/app/components/marty/log_view.rb +16 -14
- data/app/components/marty/main_auth_app.rb +59 -59
- data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
- data/app/components/marty/mcfly_grid_panel.rb +10 -10
- data/app/components/marty/new_posting_form.rb +11 -11
- data/app/components/marty/new_posting_window.rb +0 -1
- data/app/components/marty/posting_grid.rb +12 -13
- data/app/components/marty/promise_view.rb +6 -6
- data/app/components/marty/report_form.rb +50 -53
- data/app/components/marty/report_select.rb +27 -27
- data/app/components/marty/reporting.rb +4 -4
- data/app/components/marty/script_form.rb +40 -42
- data/app/components/marty/script_grid.rb +24 -24
- data/app/components/marty/script_tester.rb +40 -42
- data/app/components/marty/scripting.rb +25 -27
- data/app/components/marty/simple_app.rb +24 -9
- data/app/components/marty/tag_grid.rb +12 -13
- data/app/components/marty/user_view.rb +35 -35
- data/app/controllers/marty/application_controller.rb +3 -4
- data/app/controllers/marty/components_controller.rb +1 -1
- data/app/controllers/marty/delayed_job_controller.rb +1 -0
- data/app/controllers/marty/diagnostic/controller.rb +4 -6
- data/app/controllers/marty/job_controller.rb +6 -6
- data/app/controllers/marty/report_controller.rb +11 -11
- data/app/controllers/marty/rpc_controller.rb +15 -16
- data/app/helpers/marty/script_set.rb +4 -4
- data/app/models/marty/api_auth.rb +4 -5
- data/app/models/marty/api_config.rb +1 -1
- data/app/models/marty/base.rb +9 -8
- data/app/models/marty/base_rule.rb +18 -13
- data/app/models/marty/config.rb +4 -5
- data/app/models/marty/data_grid.rb +157 -181
- data/app/models/marty/delorean_rule.rb +63 -62
- data/app/models/marty/enum.rb +1 -1
- data/app/models/marty/event.rb +56 -59
- data/app/models/marty/helper.rb +38 -6
- data/app/models/marty/import_type.rb +6 -6
- data/app/models/marty/log.rb +3 -2
- data/app/models/marty/name_validator.rb +3 -2
- data/app/models/marty/pg_enum.rb +3 -4
- data/app/models/marty/posting.rb +20 -24
- data/app/models/marty/promise.rb +28 -30
- data/app/models/marty/script.rb +30 -28
- data/app/models/marty/tag.rb +8 -8
- data/app/models/marty/token.rb +2 -2
- data/app/models/marty/user.rb +24 -23
- data/app/models/marty/vw_promise.rb +10 -11
- data/config/routes.rb +2 -2
- data/delorean/blame_report.dl +268 -0
- data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
- data/delorean/table_report.dl +34 -0
- data/docker-compose.dummy.yml +2 -3
- data/lib/marty/aws/base.rb +8 -8
- data/lib/marty/aws/request.rb +4 -4
- data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
- data/lib/marty/content_handler.rb +25 -25
- data/lib/marty/data_change.rb +49 -71
- data/lib/marty/data_conversion.rb +20 -28
- data/lib/marty/data_exporter.rb +25 -28
- data/lib/marty/data_importer.rb +25 -27
- data/lib/marty/engine.rb +1 -2
- data/lib/marty/json_schema.rb +22 -24
- data/lib/marty/logger.rb +6 -9
- data/lib/marty/mcfly_model.rb +20 -24
- data/lib/marty/migrations.rb +37 -35
- data/lib/marty/monkey.rb +33 -33
- data/lib/marty/permissions.rb +18 -18
- data/lib/marty/promise_job.rb +17 -17
- data/lib/marty/promise_proxy.rb +6 -6
- data/lib/marty/relation.rb +6 -7
- data/lib/marty/rpc_call.rb +13 -12
- data/lib/marty/rule_script_set.rb +32 -28
- data/lib/marty/schema_helper.rb +37 -51
- data/lib/marty/util.rb +25 -24
- data/lib/marty/version.rb +1 -1
- data/lib/marty/xl.rb +121 -115
- data/make-dummy.mk +3 -0
- data/marty.gemspec +21 -21
- data/other/marty/api/base.rb +34 -35
- data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
- data/other/marty/diagnostic/base.rb +13 -14
- data/other/marty/diagnostic/collection.rb +2 -1
- data/other/marty/diagnostic/connections.rb +8 -6
- data/other/marty/diagnostic/database.rb +1 -0
- data/other/marty/diagnostic/delayed_job_version.rb +7 -9
- data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
- data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
- data/other/marty/diagnostic/environment_variables.rb +17 -15
- data/other/marty/diagnostic/fatal.rb +1 -1
- data/other/marty/diagnostic/node.rb +5 -9
- data/other/marty/diagnostic/nodes.rb +7 -5
- data/other/marty/diagnostic/packer.rb +7 -7
- data/other/marty/diagnostic/reporter.rb +24 -27
- data/other/marty/diagnostic/version.rb +3 -5
- data/script/rails +2 -1
- data/spec/controllers/application_controller_spec.rb +6 -6
- data/spec/controllers/delayed_job_controller_spec.rb +4 -4
- data/spec/controllers/diagnostic/controller_spec.rb +59 -60
- data/spec/controllers/job_controller_spec.rb +68 -69
- data/spec/controllers/rpc_controller_spec.rb +353 -359
- data/spec/controllers/rpc_import_spec.rb +15 -16
- data/spec/dummy/delorean/blame_report.dl +110 -15
- data/spec/dummy/delorean/data_report.dl +4 -4
- data/spec/dummy/delorean/marty_fields.dl +63 -0
- data/spec/dummy/delorean/table_report.dl +34 -0
- data/spec/features/auth_app_spec.rb +1 -2
- data/spec/features/data_import_spec.rb +2 -3
- data/spec/features/enum_spec.rb +42 -46
- data/spec/features/jobs_dashboard_spec.rb +14 -8
- data/spec/features/log_view_spec.rb +40 -43
- data/spec/features/reporting_spec.rb +15 -15
- data/spec/features/rule_spec.rb +195 -190
- data/spec/features/scripting_spec.rb +17 -20
- data/spec/features/scripting_test_spec.rb +32 -33
- data/spec/features/user_view_spec.rb +15 -17
- data/spec/job_helper.rb +11 -11
- data/spec/lib/data_blame_spec.rb +82 -0
- data/spec/lib/data_exporter_spec.rb +31 -32
- data/spec/lib/data_importer_spec.rb +382 -395
- data/spec/lib/delorean_query_spec.rb +117 -119
- data/spec/lib/json_schema_spec.rb +382 -392
- data/spec/lib/logger_spec.rb +23 -24
- data/spec/lib/mcfly_model_spec.rb +112 -109
- data/spec/lib/migrations_spec.rb +10 -10
- data/spec/lib/struct_compare_spec.rb +6 -6
- data/spec/lib/table_report_spec.rb +90 -0
- data/spec/lib/xl_spec.rb +63 -65
- data/spec/lib/xl_styles_spec.rb +16 -19
- data/spec/models/api_auth_spec.rb +30 -30
- data/spec/models/config_spec.rb +32 -32
- data/spec/models/data_grid_spec.rb +642 -655
- data/spec/models/event_spec.rb +96 -88
- data/spec/models/import_type_spec.rb +20 -20
- data/spec/models/posting_spec.rb +35 -35
- data/spec/models/promise_spec.rb +5 -5
- data/spec/models/rule_spec.rb +280 -269
- data/spec/models/script_spec.rb +27 -18
- data/spec/models/user_spec.rb +9 -9
- data/spec/other/diagnostic/base_spec.rb +20 -19
- data/spec/other/diagnostic/collection_spec.rb +6 -5
- data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
- data/spec/other/diagnostic/reporter_spec.rb +31 -33
- data/spec/spec_helper.rb +5 -5
- data/spec/support/chromedriver.rb +3 -5
- data/spec/support/components/netzke_combobox.rb +1 -1
- data/spec/support/components/netzke_grid.rb +17 -17
- data/spec/support/custom_matchers.rb +2 -2
- data/spec/support/download_helper.rb +1 -1
- data/spec/support/helper.rb +1 -2
- data/spec/support/netzke.rb +31 -31
- data/spec/support/performance_helper.rb +8 -8
- data/spec/support/post_run_logger.rb +1 -2
- data/spec/support/setup.rb +1 -4
- data/spec/support/shared_connection.rb +2 -2
- data/spec/support/structure_compare.rb +21 -22
- data/spec/support/suite.rb +1 -2
- data/spec/support/users.rb +5 -6
- metadata +32 -26
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Marty
|
|
4
|
-
|
|
5
|
-
groupings =<<EOF
|
|
4
|
+
groupings = <<EOF
|
|
6
5
|
name
|
|
7
6
|
g1
|
|
8
7
|
g2
|
|
9
8
|
g3
|
|
10
9
|
EOF
|
|
11
10
|
|
|
12
|
-
heads
|
|
11
|
+
heads = <<EOF
|
|
13
12
|
name condition_text
|
|
14
13
|
h1 foo
|
|
15
14
|
h2 bar
|
|
16
15
|
h3 baz
|
|
17
16
|
EOF
|
|
18
17
|
|
|
19
|
-
head_versions
|
|
18
|
+
head_versions = <<EOF
|
|
20
19
|
head__name version result_text
|
|
21
20
|
h1 base x=1
|
|
22
21
|
h1 600 x=2
|
|
@@ -24,7 +23,7 @@ h2 base y=z
|
|
|
24
23
|
h3 base z=4
|
|
25
24
|
EOF
|
|
26
25
|
|
|
27
|
-
grouping_head_versions
|
|
26
|
+
grouping_head_versions = <<EOF
|
|
28
27
|
grouping__name head_version__head head_version__version
|
|
29
28
|
g1 h1 base
|
|
30
29
|
g1 h1 600
|
|
@@ -32,39 +31,39 @@ g2 h2 base
|
|
|
32
31
|
g3 h3 base
|
|
33
32
|
EOF
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
describe DataExporter do
|
|
35
|
+
it 'be able to import and export nested keys' do
|
|
36
|
+
res = Marty::DataImporter.do_import_summary(Gemini::Grouping, groupings)
|
|
37
|
+
expect(res).to eq(create: 3)
|
|
38
|
+
Gemini::Grouping.count.should == 3
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
res = Marty::DataImporter.do_import_summary(Gemini::Head, heads)
|
|
41
|
+
expect(res).to eq(create: 3)
|
|
42
|
+
Gemini::Head.count.should == 3
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
res = Marty::DataImporter.do_import_summary(Gemini::HeadVersion, head_versions)
|
|
45
|
+
expect(res).to eq(create: 4)
|
|
46
|
+
Gemini::HeadVersion.count.should == 4
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
res = Marty::DataImporter.do_import_summary(Gemini::GroupingHeadVersion, grouping_head_versions)
|
|
49
|
+
expect(res).to eq(create: 4)
|
|
50
|
+
Gemini::GroupingHeadVersion.count.should == 4
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
res = Marty::DataExporter.do_export('infinity', Gemini::GroupingHeadVersion)
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
expect(res).to eq [
|
|
55
|
+
['grouping', 'head_version__head', 'head_version__version'],
|
|
56
|
+
['g1', 'h1', 'base'],
|
|
57
|
+
['g1', 'h1', '600'],
|
|
58
|
+
['g2', 'h2', 'base'],
|
|
59
|
+
['g3', 'h3', 'base']
|
|
60
|
+
]
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
csv = Marty::DataExporter.to_csv(res, col_sep: "\t")
|
|
64
63
|
|
|
65
|
-
|
|
64
|
+
res = Marty::DataImporter.do_import_summary(Gemini::GroupingHeadVersion, csv)
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
end
|
|
66
|
+
expect(res).to eq(same: 4)
|
|
69
67
|
end
|
|
70
68
|
end
|
|
69
|
+
end
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Marty
|
|
4
|
-
|
|
5
|
-
bud_cats =<<EOF
|
|
4
|
+
bud_cats = <<EOF
|
|
6
5
|
name
|
|
7
6
|
Conv Fixed 30
|
|
8
7
|
Conv Fixed 20
|
|
9
8
|
EOF
|
|
10
9
|
|
|
11
|
-
bud_cats2
|
|
10
|
+
bud_cats2 = <<EOF
|
|
12
11
|
namex
|
|
13
12
|
Conv Fixed 20
|
|
14
13
|
EOF
|
|
15
14
|
|
|
16
|
-
fannie_bup1
|
|
15
|
+
fannie_bup1 = <<EOF
|
|
17
16
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
18
17
|
Conv Fixed 30 2.250 4.42000 7.24000 12 2012
|
|
19
18
|
Conv Fixed 30 2.375 4.42000 7.24000 12 2012
|
|
@@ -24,18 +23,18 @@ Conv Fixed 20 2.875 4.24800 6.95900 12 2012
|
|
|
24
23
|
EOF
|
|
25
24
|
|
|
26
25
|
fannie_bup1_export =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fannie_bup2
|
|
26
|
+
[
|
|
27
|
+
['entity', 'bud_category', 'note_rate', 'settlement_mm',
|
|
28
|
+
'settlement_yy', 'buy_up', 'buy_down'],
|
|
29
|
+
[nil, 'Conv Fixed 30', 2.250, 12, 2012, 4.42, 7.24],
|
|
30
|
+
[nil, 'Conv Fixed 30', 2.375, 12, 2012, 4.42, 7.24],
|
|
31
|
+
[nil, 'Conv Fixed 30', 2.500, 12, 2012, 4.413, 7.228],
|
|
32
|
+
[nil, 'Conv Fixed 30', 2.625, 12, 2012, 4.375, 7.162],
|
|
33
|
+
[nil, 'Conv Fixed 30', 2.750, 12, 2012, 4.329, 7.093],
|
|
34
|
+
[nil, 'Conv Fixed 20', 2.875, 12, 2012, 4.248, 6.959],
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
fannie_bup2 = <<EOF
|
|
39
38
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
40
39
|
Conv Fixed 20 2.250 4.42000 7.24000 12 2012
|
|
41
40
|
Conv Fixed 20 2.375 4.42000 7.24000 12 2012
|
|
@@ -47,12 +46,12 @@ Conv Fixed 30 2.750 4.32900 7.09300 12 2012
|
|
|
47
46
|
Conv Fixed 20 2.875 3.333 4.444 12 2012
|
|
48
47
|
EOF
|
|
49
48
|
|
|
50
|
-
fannie_bup3
|
|
49
|
+
fannie_bup3 = <<EOF
|
|
51
50
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
52
51
|
Conv Fixed 30 2.250 1.123 2.345 12 2012
|
|
53
52
|
EOF
|
|
54
53
|
|
|
55
|
-
loan_programs
|
|
54
|
+
loan_programs = <<EOF
|
|
56
55
|
name amortization_type mortgage_type streamline_type high_balance_indicator state_array test_int_array test_string_array
|
|
57
56
|
Conv Fixed 30 Year Fixed Conventional Not Streamlined false [1] "[""foo""]"
|
|
58
57
|
Conv Fixed 30 Year HB Fixed Conventional Not Streamlined true "[""TN""]" [1,2] "[""foo"",""bar""]"
|
|
@@ -60,13 +59,13 @@ Conv Fixed 30 Year DURP <=80 Fixed Conventional DURP false "[""TN"",""CT""]" [1,
|
|
|
60
59
|
Conv Fixed 30 Year DURP <=80 HB Fixed Conventional DURP true "[""CA"",""NY""]" "[""foo"",""hi mom""]"
|
|
61
60
|
EOF
|
|
62
61
|
|
|
63
|
-
loan_programs_comma
|
|
62
|
+
loan_programs_comma = <<EOF
|
|
64
63
|
name,amortization_type,mortgage_type,state_array,test_string_array,streamline_type,high_balance_indicator
|
|
65
64
|
FHA Fixed 15 Year,Fixed,FHA,"[""FL"",""NV"",""ME""]","[""ABC"",""DEF""]",Not Streamlined,false
|
|
66
65
|
FHA Fixed 100 Year,Fixed,FHA,"[""FL"",""NV"",""ME""]","[""XYZ,"",""hi mom""]",Not Streamlined,false
|
|
67
66
|
EOF
|
|
68
67
|
|
|
69
|
-
loan_programs_encoded
|
|
68
|
+
loan_programs_encoded = <<EOF
|
|
70
69
|
name,amortization_type,mortgage_type,conforming,ltv_ratio_percent_range,high_balance_indicator,loan_amortization_period_count,streamline_type,extra_feature_type_id,arm_initial_reset_period_count,arm_initial_cap_percent,arm_periodic_cap_percent,arm_lifetime_cap_percent,arm_index_type_id,arm_margin_rate_percent,enum_state,state_array,test_int_array,test_string_array
|
|
71
70
|
VA Fixed 30 Year,Fixed,VA,true,,false,360,Not Streamlined,,,,,,,,,,eJyLNowFAAHTAOo=,eJyLVkrLz1eKBQAI+AJB
|
|
72
71
|
VA Fixed 30 Year HB,Fixed,VA,true,,true,360,Not Streamlined,,,,,,,,,eJyLVgrxU4oFAAWtAZ8=,eJyLNtQxigUAA9UBSA==,eJyLVkrLz1fSUUpKLFKKBQAbWAPm
|
|
@@ -74,24 +73,24 @@ VA Fixed 30 Year DURP <=80,Fixed,VA,true,,false,360,DURP,,,,,,,,,eJyLVgrxU9JRcg5
|
|
|
74
73
|
VA Fixed 30 Year DURP <=80 HB,Fixed,VA,true,,true,360,DURP,,,,,,,,,eJyLVnJ2VNJR8otUigUADy8CmA==,,eJyLVkrLz1fSUcrIVMjNz1WKBQApLQTr
|
|
75
74
|
EOF
|
|
76
75
|
|
|
77
|
-
fannie_bup4
|
|
76
|
+
fannie_bup4 = <<EOF
|
|
78
77
|
loan_program bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
79
78
|
Conv Fixed 30 Year Conv Fixed 30 2.250 1.123 2.345 12 2012
|
|
80
79
|
EOF
|
|
81
80
|
|
|
82
|
-
fannie_bup5
|
|
81
|
+
fannie_bup5 = <<EOF
|
|
83
82
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
84
83
|
Conv Fixed 20 2.250 1.123 2.345 12 2012
|
|
85
84
|
Conv Fixed XX 2.250 1.123 2.345 12 2012
|
|
86
85
|
EOF
|
|
87
86
|
|
|
88
|
-
fannie_bup6
|
|
87
|
+
fannie_bup6 = <<EOF
|
|
89
88
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
90
89
|
Conv Fixed 30 2.250 4.42000 7.24000 12 2012
|
|
91
90
|
Conv Fixed 30 2.375 a123 7.24000 12 2012
|
|
92
91
|
EOF
|
|
93
92
|
|
|
94
|
-
fannie_bup7
|
|
93
|
+
fannie_bup7 = <<EOF
|
|
95
94
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
96
95
|
Conv Fixed 30 $2.250 4.42% 7.24% 12 2012
|
|
97
96
|
Conv Fixed 30 $2.375 4.42% 7.24% 12 2012
|
|
@@ -101,404 +100,392 @@ Conv Fixed 30 $2.750 4.32900 7.09300 12 2012
|
|
|
101
100
|
Conv Fixed 20 $2.875 4.24800 6.95900 12 2012
|
|
102
101
|
EOF
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
describe DataImporter do
|
|
104
|
+
it 'should be able to import into classes with id as uniqueness' do
|
|
105
|
+
pending('Fix data importer to handle at least group_id as mcfly_uniqueness')
|
|
106
|
+
|
|
107
|
+
res = Marty::DataImporter.
|
|
108
|
+
do_import_summary(Gemini::Simple,
|
|
109
|
+
[{ 'some_name' => 'hello' }])
|
|
110
|
+
res.should == { create: 1 }
|
|
111
|
+
res = Marty::DataImporter.do_import_summary(
|
|
112
|
+
Gemini::Simple,
|
|
113
|
+
[{ 'group_id' => Gemini::Simple.first.group_id, 'some_name' => 'hello' }]
|
|
114
|
+
)
|
|
115
|
+
res.should == { same: 1 }
|
|
116
|
+
end
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
it 'should be able to import fannie buyups' do
|
|
119
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
120
|
+
res.should == { create: 2 }
|
|
121
|
+
Gemini::BudCategory.count.should == 2
|
|
122
|
+
|
|
123
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
124
|
+
res.should == { same: 2 }
|
|
125
|
+
Gemini::BudCategory.count.should == 2
|
|
126
|
+
|
|
127
|
+
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
128
|
+
res.should == { create: 6 }
|
|
129
|
+
Gemini::FannieBup.count.should == 6
|
|
130
|
+
|
|
131
|
+
# spot-check the import
|
|
132
|
+
bc = Gemini::BudCategory.find_by_name('Conv Fixed 30')
|
|
133
|
+
fb = Gemini::FannieBup.where(bud_category_id: bc.id, note_rate: 2.50).first
|
|
134
|
+
fb.buy_up.should == 4.41300
|
|
135
|
+
fb.buy_down.should == 7.22800
|
|
136
|
+
|
|
137
|
+
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
138
|
+
res.should == { same: 6 }
|
|
139
|
+
Gemini::FannieBup.count.should == 6
|
|
140
|
+
|
|
141
|
+
# dups should raise an error
|
|
142
|
+
dup = fannie_bup1.split("\n")[-1]
|
|
143
|
+
lambda {
|
|
144
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1 + dup)
|
|
145
|
+
}.should raise_error(Marty::DataImporter::Error)
|
|
146
|
+
end
|
|
117
147
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
Gemini::
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
# spot-check the import
|
|
132
|
-
bc = Gemini::BudCategory.find_by_name("Conv Fixed 30")
|
|
133
|
-
fb = Gemini::FannieBup.where(bud_category_id: bc.id, note_rate: 2.50).first
|
|
134
|
-
fb.buy_up.should == 4.41300
|
|
135
|
-
fb.buy_down.should == 7.22800
|
|
136
|
-
|
|
137
|
-
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
138
|
-
res.should == {same: 6}
|
|
139
|
-
Gemini::FannieBup.count.should == 6
|
|
140
|
-
|
|
141
|
-
# dups should raise an error
|
|
142
|
-
dup = fannie_bup1.split("\n")[-1]
|
|
143
|
-
lambda {
|
|
144
|
-
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1+dup)
|
|
145
|
-
}.should raise_error(Marty::DataImporter::Error)
|
|
146
|
-
end
|
|
148
|
+
it 'should be able to use comma separated files' do
|
|
149
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
150
|
+
res = Marty::DataImporter.
|
|
151
|
+
do_import_summary(Gemini::FannieBup,
|
|
152
|
+
fannie_bup1.gsub("\t", ','),
|
|
153
|
+
'infinity',
|
|
154
|
+
nil,
|
|
155
|
+
nil,
|
|
156
|
+
',',
|
|
157
|
+
)
|
|
158
|
+
res.should == { create: 6 }
|
|
159
|
+
Gemini::FannieBup.count.should == 6
|
|
160
|
+
end
|
|
147
161
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
",",
|
|
157
|
-
)
|
|
158
|
-
res.should == {create: 6}
|
|
159
|
-
Gemini::FannieBup.count.should == 6
|
|
160
|
-
end
|
|
162
|
+
it 'should be all-or-nothing' do
|
|
163
|
+
lambda {
|
|
164
|
+
Marty::DataImporter.
|
|
165
|
+
do_import_summary(Gemini::BudCategory,
|
|
166
|
+
bud_cats + bud_cats.sub(/name\n/, ''))
|
|
167
|
+
}.should raise_error(Marty::DataImporter::Error)
|
|
168
|
+
Gemini::BudCategory.count.should == 0
|
|
169
|
+
end
|
|
161
170
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
do_import_summary(Gemini::BudCategory,
|
|
166
|
-
bud_cats+bud_cats.sub(/name\n/, ""))
|
|
167
|
-
}.should raise_error(Marty::DataImporter::Error)
|
|
168
|
-
Gemini::BudCategory.count.should == 0
|
|
169
|
-
end
|
|
171
|
+
it 'should be able to perform updates mixed with inserts' do
|
|
172
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
173
|
+
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
175
|
+
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup3)
|
|
176
|
+
res.should == { update: 1 }
|
|
174
177
|
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
res = Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup2)
|
|
179
|
+
res.should == { same: 2, create: 2, update: 2, blank: 2 }
|
|
180
|
+
end
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
it 'should be able to import with cleaner' do
|
|
183
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
184
|
+
res = Marty::DataImporter.
|
|
185
|
+
do_import_summary(Gemini::FannieBup,
|
|
186
|
+
fannie_bup1,
|
|
187
|
+
'infinity',
|
|
188
|
+
'import_cleaner',
|
|
189
|
+
)
|
|
190
|
+
res.should == { create: 6 }
|
|
191
|
+
|
|
192
|
+
res = Marty::DataImporter.
|
|
193
|
+
do_import_summary(Gemini::FannieBup,
|
|
194
|
+
fannie_bup1,
|
|
195
|
+
'infinity',
|
|
196
|
+
'import_cleaner',
|
|
197
|
+
)
|
|
198
|
+
res.should == { same: 6 }
|
|
199
|
+
|
|
200
|
+
res = Marty::DataImporter.
|
|
201
|
+
do_import_summary(Gemini::FannieBup,
|
|
202
|
+
fannie_bup3,
|
|
203
|
+
'infinity',
|
|
204
|
+
'import_cleaner',
|
|
205
|
+
)
|
|
206
|
+
res.should == { update: 1, clean: 5 }
|
|
207
|
+
|
|
208
|
+
res = Marty::DataImporter.
|
|
209
|
+
do_import_summary(Gemini::FannieBup,
|
|
210
|
+
fannie_bup2,
|
|
211
|
+
'infinity',
|
|
212
|
+
'import_cleaner',
|
|
213
|
+
)
|
|
214
|
+
res.should == { create: 6, blank: 2, clean: 1 }
|
|
215
|
+
end
|
|
181
216
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
217
|
+
it 'should be able to import with validation' do
|
|
218
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
219
|
+
|
|
220
|
+
# first load some old data
|
|
221
|
+
res = Marty::DataImporter.
|
|
222
|
+
do_import_summary(Gemini::FannieBup,
|
|
223
|
+
fannie_bup1,
|
|
224
|
+
'infinity',
|
|
225
|
+
)
|
|
226
|
+
res.should == { create: 6 }
|
|
227
|
+
|
|
228
|
+
lambda {
|
|
229
|
+
Marty::DataImporter.
|
|
230
|
+
do_import_summary(Gemini::FannieBup,
|
|
231
|
+
fannie_bup1.sub('2012', '2100'), # change 1st row
|
|
232
|
+
'infinity',
|
|
233
|
+
nil,
|
|
234
|
+
'import_validation',
|
|
235
|
+
)
|
|
236
|
+
}.should raise_error(Marty::DataImporter::Error)
|
|
237
|
+
|
|
238
|
+
res = Marty::DataImporter.
|
|
239
|
+
do_import_summary(Gemini::FannieBup,
|
|
240
|
+
fannie_bup1.gsub('2012', '2100'),
|
|
241
|
+
'infinity',
|
|
242
|
+
nil,
|
|
243
|
+
'import_validation',
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
res.should == { create: 6 }
|
|
247
|
+
|
|
248
|
+
lambda {
|
|
249
|
+
Marty::DataImporter.
|
|
250
|
+
do_import_summary(Gemini::FannieBup,
|
|
251
|
+
fannie_bup3,
|
|
252
|
+
'infinity',
|
|
253
|
+
'import_cleaner',
|
|
254
|
+
'import_validation',
|
|
255
|
+
)
|
|
256
|
+
}.should raise_error(Marty::DataImporter::Error)
|
|
257
|
+
|
|
258
|
+
res = Marty::DataImporter.
|
|
259
|
+
do_import_summary(Gemini::FannieBup,
|
|
260
|
+
fannie_bup3.gsub('2012', '2100'),
|
|
261
|
+
'infinity',
|
|
262
|
+
'import_cleaner',
|
|
263
|
+
'import_validation',
|
|
264
|
+
)
|
|
265
|
+
res.should == { update: 1, clean: 11 }
|
|
266
|
+
end
|
|
191
267
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
268
|
+
it 'should be able to import with preprocess' do
|
|
269
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
270
|
+
res = Marty::DataImporter.
|
|
271
|
+
do_import_summary(Gemini::FannieBup,
|
|
272
|
+
fannie_bup7,
|
|
273
|
+
'infinity',
|
|
274
|
+
'import_cleaner',
|
|
275
|
+
nil,
|
|
276
|
+
"\t",
|
|
277
|
+
false,
|
|
278
|
+
'import_preprocess',
|
|
279
|
+
)
|
|
280
|
+
res.should == { create: 6 }
|
|
281
|
+
end
|
|
199
282
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
283
|
+
it 'should be able to import with validation - allow prior month' do
|
|
284
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
285
|
+
|
|
286
|
+
# first load some data without any validation
|
|
287
|
+
res = Marty::DataImporter.
|
|
288
|
+
do_import_summary(Gemini::FannieBup, fannie_bup1, 'infinity')
|
|
289
|
+
res.should == { create: 6 }
|
|
290
|
+
|
|
291
|
+
now = DateTime.now
|
|
292
|
+
cm, cy = now.month, now.year
|
|
293
|
+
pm1, py1 = (now - 1.month).month, (now - 1.month).year
|
|
294
|
+
pm2, py2 = (now - 2.months).month, (now - 2.months).year
|
|
295
|
+
|
|
296
|
+
# Load data into current mm/yy
|
|
297
|
+
lambda {
|
|
298
|
+
Marty::DataImporter.
|
|
299
|
+
do_import_summary(Gemini::FannieBup,
|
|
300
|
+
fannie_bup1.gsub("12\t2012", "#{cm}\t#{cy}"),
|
|
301
|
+
'infinity',
|
|
302
|
+
nil,
|
|
303
|
+
'import_validation',
|
|
304
|
+
)
|
|
305
|
+
}.should_not raise_error
|
|
306
|
+
|
|
307
|
+
# Load data into prior mm/yy - should fail since import_validation
|
|
308
|
+
# only allows current or future months
|
|
309
|
+
lambda {
|
|
310
|
+
Marty::DataImporter.
|
|
311
|
+
do_import_summary(Gemini::FannieBup,
|
|
312
|
+
fannie_bup1.gsub("12\t2012", "#{pm1}\t#{py1}"),
|
|
313
|
+
'infinity',
|
|
314
|
+
nil,
|
|
315
|
+
'import_validation',
|
|
316
|
+
)
|
|
317
|
+
}.should raise_error(Marty::DataImporter::Error)
|
|
318
|
+
|
|
319
|
+
# Load data into prior mm/yy - should not fail since
|
|
320
|
+
# import_validation_allow_prior_month is specified
|
|
321
|
+
lambda {
|
|
322
|
+
Marty::DataImporter.
|
|
323
|
+
do_import_summary(Gemini::FannieBup,
|
|
324
|
+
fannie_bup1.gsub("12\t2012", "#{pm1}\t#{py1}"),
|
|
325
|
+
'infinity',
|
|
326
|
+
nil,
|
|
327
|
+
'import_validation_allow_prior_month',
|
|
328
|
+
)
|
|
329
|
+
}.should_not raise_error
|
|
330
|
+
|
|
331
|
+
# Load data into mm/yy more than 1 month prior - should fail even
|
|
332
|
+
# if import_validation_allow_prior_month is specified
|
|
333
|
+
lambda {
|
|
334
|
+
Marty::DataImporter.
|
|
335
|
+
do_import_summary(Gemini::FannieBup,
|
|
336
|
+
fannie_bup1.gsub("12\t2012", "#{pm2}\t#{py2}"),
|
|
337
|
+
'infinity',
|
|
338
|
+
nil,
|
|
339
|
+
'import_validation_allow_prior_month',
|
|
340
|
+
)
|
|
341
|
+
}.should raise_error(Marty::DataImporter::Error)
|
|
342
|
+
end
|
|
207
343
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
344
|
+
it 'should properly handle validation errors' do
|
|
345
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
346
|
+
res = Marty::DataImporter.
|
|
347
|
+
do_import_summary(Gemini::LoanProgram, loan_programs)
|
|
348
|
+
res.should == { create: 4 }
|
|
349
|
+
|
|
350
|
+
begin
|
|
351
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup4)
|
|
352
|
+
rescue Marty::DataImporter::Error => exc
|
|
353
|
+
exc.lines.should == [0]
|
|
354
|
+
else
|
|
355
|
+
raise 'should have had an exception'
|
|
215
356
|
end
|
|
357
|
+
end
|
|
216
358
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
'
|
|
233
|
-
|
|
234
|
-
'
|
|
235
|
-
|
|
236
|
-
|
|
359
|
+
it 'should load array types (incl encoded)' do
|
|
360
|
+
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs)
|
|
361
|
+
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs_comma,
|
|
362
|
+
'infinity', nil, nil, ',')
|
|
363
|
+
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs_encoded,
|
|
364
|
+
'infinity', nil, nil, ',')
|
|
365
|
+
lpset = Gemini::LoanProgram.all.pluck(:name, :state_array,
|
|
366
|
+
:test_int_array,
|
|
367
|
+
:test_string_array).to_set
|
|
368
|
+
expect(lpset).to eq([['Conv Fixed 30 Year', nil, [1], ['foo']],
|
|
369
|
+
['Conv Fixed 30 Year HB', ['TN'], [1, 2],
|
|
370
|
+
['foo', 'bar']],
|
|
371
|
+
['Conv Fixed 30 Year DURP <=80', ['TN', 'CT'],
|
|
372
|
+
[1, 2, 3], ['foo', 'bar']],
|
|
373
|
+
['Conv Fixed 30 Year DURP <=80 HB', ['CA', 'NY'],
|
|
374
|
+
nil, ['foo', 'hi mom']],
|
|
375
|
+
['FHA Fixed 15 Year', ['FL', 'NV', 'ME'], nil,
|
|
376
|
+
['ABC', 'DEF']],
|
|
377
|
+
['FHA Fixed 100 Year', ['FL', 'NV', 'ME'], nil,
|
|
378
|
+
['XYZ,', 'hi mom']],
|
|
379
|
+
['VA Fixed 30 Year', nil, [1], ['foo']],
|
|
380
|
+
['VA Fixed 30 Year HB', ['TN'], [1, 2],
|
|
381
|
+
['foo', 'bar']],
|
|
382
|
+
['VA Fixed 30 Year DURP <=80', ['TN', 'CT'],
|
|
383
|
+
[1, 2, 3], ['foo', 'bar']],
|
|
384
|
+
['VA Fixed 30 Year DURP <=80 HB', ['CA', 'NY'],
|
|
385
|
+
nil, ['foo', 'hi mom']],].to_set)
|
|
386
|
+
end
|
|
237
387
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
fannie_bup1.gsub("2012", "2100"),
|
|
241
|
-
'infinity',
|
|
242
|
-
nil,
|
|
243
|
-
'import_validation',
|
|
244
|
-
)
|
|
245
|
-
|
|
246
|
-
res.should == {create: 6}
|
|
247
|
-
|
|
248
|
-
lambda {
|
|
249
|
-
Marty::DataImporter.
|
|
250
|
-
do_import_summary(Gemini::FannieBup,
|
|
251
|
-
fannie_bup3,
|
|
252
|
-
'infinity',
|
|
253
|
-
'import_cleaner',
|
|
254
|
-
'import_validation',
|
|
255
|
-
)
|
|
256
|
-
}.should raise_error(Marty::DataImporter::Error)
|
|
388
|
+
it 'should properly handle cases where an association item is missing' do
|
|
389
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
257
390
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
res.should == {update: 1, clean: 11}
|
|
391
|
+
begin
|
|
392
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup5)
|
|
393
|
+
rescue Marty::DataImporter::Error => exc
|
|
394
|
+
exc.lines.should == [1]
|
|
395
|
+
exc.message.should =~ /Conv Fixed XX/
|
|
396
|
+
else
|
|
397
|
+
raise 'should have had an exception'
|
|
266
398
|
end
|
|
399
|
+
end
|
|
267
400
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
'infinity',
|
|
274
|
-
'import_cleaner',
|
|
275
|
-
nil,
|
|
276
|
-
"\t",
|
|
277
|
-
false,
|
|
278
|
-
'import_preprocess',
|
|
279
|
-
)
|
|
280
|
-
res.should == {create: 6}
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
it "should be able to import with validation - allow prior month" do
|
|
284
|
-
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
285
|
-
|
|
286
|
-
# first load some data without any validation
|
|
287
|
-
res = Marty::DataImporter.
|
|
288
|
-
do_import_summary(Gemini::FannieBup, fannie_bup1, 'infinity')
|
|
289
|
-
res.should == {create: 6}
|
|
290
|
-
|
|
291
|
-
now = DateTime.now
|
|
292
|
-
cm, cy = now.month, now.year
|
|
293
|
-
pm1, py1 = (now - 1.month).month, (now - 1.month).year
|
|
294
|
-
pm2, py2 = (now - 2.months).month, (now - 2.months).year
|
|
295
|
-
|
|
296
|
-
# Load data into current mm/yy
|
|
297
|
-
lambda {
|
|
298
|
-
Marty::DataImporter.
|
|
299
|
-
do_import_summary(Gemini::FannieBup,
|
|
300
|
-
fannie_bup1.gsub("12\t2012", "#{cm}\t#{cy}"),
|
|
301
|
-
'infinity',
|
|
302
|
-
nil,
|
|
303
|
-
'import_validation',
|
|
304
|
-
)
|
|
305
|
-
}.should_not raise_error
|
|
306
|
-
|
|
307
|
-
# Load data into prior mm/yy - should fail since import_validation
|
|
308
|
-
# only allows current or future months
|
|
309
|
-
lambda {
|
|
310
|
-
Marty::DataImporter.
|
|
311
|
-
do_import_summary(Gemini::FannieBup,
|
|
312
|
-
fannie_bup1.gsub("12\t2012", "#{pm1}\t#{py1}"),
|
|
313
|
-
'infinity',
|
|
314
|
-
nil,
|
|
315
|
-
'import_validation',
|
|
316
|
-
)
|
|
317
|
-
}.should raise_error(Marty::DataImporter::Error)
|
|
318
|
-
|
|
319
|
-
# Load data into prior mm/yy - should not fail since
|
|
320
|
-
# import_validation_allow_prior_month is specified
|
|
321
|
-
lambda {
|
|
322
|
-
Marty::DataImporter.
|
|
323
|
-
do_import_summary(Gemini::FannieBup,
|
|
324
|
-
fannie_bup1.gsub("12\t2012", "#{pm1}\t#{py1}"),
|
|
325
|
-
'infinity',
|
|
326
|
-
nil,
|
|
327
|
-
'import_validation_allow_prior_month',
|
|
328
|
-
)
|
|
329
|
-
}.should_not raise_error
|
|
330
|
-
|
|
331
|
-
# Load data into mm/yy more than 1 month prior - should fail even
|
|
332
|
-
# if import_validation_allow_prior_month is specified
|
|
333
|
-
lambda {
|
|
334
|
-
Marty::DataImporter.
|
|
335
|
-
do_import_summary(Gemini::FannieBup,
|
|
336
|
-
fannie_bup1.gsub("12\t2012", "#{pm2}\t#{py2}"),
|
|
337
|
-
'infinity',
|
|
338
|
-
nil,
|
|
339
|
-
'import_validation_allow_prior_month',
|
|
340
|
-
)
|
|
341
|
-
}.should raise_error(Marty::DataImporter::Error)
|
|
342
|
-
end
|
|
401
|
+
it 'should check for bad header' do
|
|
402
|
+
lambda {
|
|
403
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats2)
|
|
404
|
+
}.should raise_error(Marty::DataImporter::Error, /namex/)
|
|
405
|
+
end
|
|
343
406
|
|
|
344
|
-
|
|
345
|
-
|
|
407
|
+
it 'should handle bad data' do
|
|
408
|
+
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
409
|
+
begin
|
|
346
410
|
res = Marty::DataImporter.
|
|
347
|
-
do_import_summary(Gemini::
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
exc.lines.should == [0]
|
|
354
|
-
else
|
|
355
|
-
raise "should have had an exception"
|
|
356
|
-
end
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
it "should load array types (incl encoded)" do
|
|
360
|
-
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs)
|
|
361
|
-
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs_comma,
|
|
362
|
-
'infinity', nil, nil, ',')
|
|
363
|
-
Marty::DataImporter.do_import(Gemini::LoanProgram, loan_programs_encoded,
|
|
364
|
-
'infinity', nil, nil, ',')
|
|
365
|
-
lpset = Gemini::LoanProgram.all.pluck(:name, :state_array,
|
|
366
|
-
:test_int_array,
|
|
367
|
-
:test_string_array).to_set
|
|
368
|
-
expect(lpset).to eq([["Conv Fixed 30 Year", nil, [1], ['foo']],
|
|
369
|
-
["Conv Fixed 30 Year HB", ["TN"], [1, 2],
|
|
370
|
-
['foo', 'bar']],
|
|
371
|
-
["Conv Fixed 30 Year DURP <=80", ["TN", "CT"],
|
|
372
|
-
[1, 2, 3], ['foo', 'bar']],
|
|
373
|
-
["Conv Fixed 30 Year DURP <=80 HB", ["CA", "NY"],
|
|
374
|
-
nil, ['foo', 'hi mom']],
|
|
375
|
-
["FHA Fixed 15 Year", ["FL","NV","ME"], nil,
|
|
376
|
-
['ABC', 'DEF']],
|
|
377
|
-
["FHA Fixed 100 Year", ["FL","NV","ME"], nil,
|
|
378
|
-
['XYZ,', 'hi mom']],
|
|
379
|
-
["VA Fixed 30 Year", nil, [1], ['foo']],
|
|
380
|
-
["VA Fixed 30 Year HB", ["TN"], [1, 2],
|
|
381
|
-
['foo', 'bar']],
|
|
382
|
-
["VA Fixed 30 Year DURP <=80", ["TN", "CT"],
|
|
383
|
-
[1, 2, 3], ['foo', 'bar']],
|
|
384
|
-
["VA Fixed 30 Year DURP <=80 HB", ["CA", "NY"],
|
|
385
|
-
nil, ['foo', 'hi mom']],
|
|
386
|
-
].to_set)
|
|
387
|
-
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
it "should properly handle cases where an association item is missing" do
|
|
391
|
-
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
392
|
-
|
|
393
|
-
begin
|
|
394
|
-
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup5)
|
|
395
|
-
rescue Marty::DataImporter::Error => exc
|
|
396
|
-
exc.lines.should == [1]
|
|
397
|
-
exc.message.should =~ /Conv Fixed XX/
|
|
398
|
-
else
|
|
399
|
-
raise "should have had an exception"
|
|
400
|
-
end
|
|
401
|
-
end
|
|
402
|
-
|
|
403
|
-
it "should check for bad header" do
|
|
404
|
-
lambda {
|
|
405
|
-
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats2)
|
|
406
|
-
}.should raise_error(Marty::DataImporter::Error, /namex/)
|
|
407
|
-
end
|
|
408
|
-
|
|
409
|
-
it "should handle bad data" do
|
|
410
|
-
res = Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
411
|
-
begin
|
|
412
|
-
res = Marty::DataImporter.
|
|
413
|
-
do_import_summary(Gemini::FannieBup, fannie_bup6)
|
|
414
|
-
rescue Marty::DataImporter::Error => exc
|
|
415
|
-
exc.lines.should == [1]
|
|
416
|
-
exc.message.should =~ /bad float/
|
|
417
|
-
else
|
|
418
|
-
raise "should have had an exception"
|
|
419
|
-
end
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
it "should be able to export" do
|
|
423
|
-
Marty::Script.load_scripts(nil, Date.today)
|
|
424
|
-
Marty::ScriptSet.clear_cache
|
|
425
|
-
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
426
|
-
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
427
|
-
p = Marty::Posting.do_create("BASE", DateTime.tomorrow, '?')
|
|
428
|
-
|
|
429
|
-
engine = Marty::ScriptSet.new.get_engine("DataReport")
|
|
430
|
-
res = engine.evaluate("TableReport",
|
|
431
|
-
"result_raw",
|
|
432
|
-
{
|
|
433
|
-
"pt_name" => p.name,
|
|
434
|
-
"class_name" => "Gemini::FannieBup",
|
|
435
|
-
},
|
|
436
|
-
)
|
|
437
|
-
res[0].should == fannie_bup1_export[0]
|
|
438
|
-
res[1..-1].sort.should == fannie_bup1_export[1..-1].sort
|
|
411
|
+
do_import_summary(Gemini::FannieBup, fannie_bup6)
|
|
412
|
+
rescue Marty::DataImporter::Error => exc
|
|
413
|
+
exc.lines.should == [1]
|
|
414
|
+
exc.message.should =~ /bad float/
|
|
415
|
+
else
|
|
416
|
+
raise 'should have had an exception'
|
|
439
417
|
end
|
|
440
418
|
end
|
|
441
419
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
p
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
{
|
|
459
|
-
"pt_name1" => p.name,
|
|
460
|
-
"pt_name2" => p2.name
|
|
461
|
-
},
|
|
462
|
-
)
|
|
463
|
-
end
|
|
420
|
+
it 'should be able to export' do
|
|
421
|
+
Marty::Script.load_scripts(nil, Date.today)
|
|
422
|
+
Marty::ScriptSet.clear_cache
|
|
423
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
424
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
425
|
+
p = Marty::Posting.do_create('BASE', DateTime.tomorrow, '?')
|
|
426
|
+
|
|
427
|
+
res = Marty::Script.evaluate(
|
|
428
|
+
nil, 'DataReport', 'TableReport', 'result_raw',
|
|
429
|
+
'pt_name' => p.name,
|
|
430
|
+
'class_name' => 'Gemini::FannieBup',
|
|
431
|
+
)
|
|
432
|
+
res[0].should == fannie_bup1_export[0]
|
|
433
|
+
res[1..-1].sort.should == fannie_bup1_export[1..-1].sort
|
|
434
|
+
end
|
|
435
|
+
end
|
|
464
436
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
437
|
+
describe 'Blame Report without yml translations' do
|
|
438
|
+
before(:each) do
|
|
439
|
+
I18n.backend.store_translations(:en,
|
|
440
|
+
attributes: {
|
|
441
|
+
note_rate: nil
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
Marty::Script.load_scripts(nil, Date.today)
|
|
445
|
+
Marty::ScriptSet.clear_cache
|
|
446
|
+
p = Marty::Posting.do_create('BASE', DateTime.yesterday, 'yesterday')
|
|
447
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
448
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
449
|
+
p2 = Marty::Posting.do_create('BASE', DateTime.now, 'now is the time')
|
|
450
|
+
|
|
451
|
+
@res = Marty::Script.evaluate(
|
|
452
|
+
nil, 'BlameReport', 'DataBlameReport', 'result',
|
|
453
|
+
'pt_name1' => p.name,
|
|
454
|
+
'pt_name2' => p2.name
|
|
455
|
+
)
|
|
471
456
|
end
|
|
472
457
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
note_rate: "Note Rate"
|
|
478
|
-
}
|
|
479
|
-
})
|
|
480
|
-
Marty::Script.load_scripts(nil, Date.today)
|
|
481
|
-
Marty::ScriptSet.clear_cache
|
|
482
|
-
p = Marty::Posting.do_create("BASE", DateTime.yesterday, 'yesterday')
|
|
483
|
-
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
484
|
-
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
485
|
-
p2 = Marty::Posting.do_create("BASE", DateTime.now, 'now is the time')
|
|
486
|
-
engine = Marty::ScriptSet.new.get_engine("BlameReport")
|
|
487
|
-
@res = engine.evaluate("DataBlameReport",
|
|
488
|
-
"result",
|
|
489
|
-
{
|
|
490
|
-
"pt_name1" => p.name,
|
|
491
|
-
"pt_name2" => p2.name
|
|
492
|
-
},
|
|
493
|
-
)
|
|
458
|
+
context 'when exporting' do
|
|
459
|
+
it 'exports the column_name' do
|
|
460
|
+
expect(@res[0][1][0][1].length).to eq(12)
|
|
461
|
+
expect(@res[0][1][0][1][7]).to eq('note_rate')
|
|
494
462
|
end
|
|
463
|
+
end
|
|
464
|
+
end
|
|
495
465
|
|
|
496
|
-
|
|
497
|
-
|
|
466
|
+
describe 'Blame Report with yml translations' do
|
|
467
|
+
before(:each) do
|
|
468
|
+
I18n.backend.store_translations(:en, attributes: { note_rate: 'Note Rate' })
|
|
469
|
+
|
|
470
|
+
Marty::Script.load_scripts(nil, Date.today)
|
|
471
|
+
Marty::ScriptSet.clear_cache
|
|
472
|
+
p = Marty::Posting.do_create('BASE', DateTime.yesterday, 'yesterday')
|
|
473
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
474
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup1)
|
|
475
|
+
p2 = Marty::Posting.do_create('BASE', DateTime.now, 'now is the time')
|
|
476
|
+
|
|
477
|
+
@res = Marty::Script.evaluate(
|
|
478
|
+
nil, 'BlameReport', 'DataBlameReport', 'result',
|
|
479
|
+
'pt_name1' => p.name,
|
|
480
|
+
'pt_name2' => p2.name,
|
|
481
|
+
)
|
|
482
|
+
end
|
|
498
483
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
484
|
+
context 'when exporting' do
|
|
485
|
+
it 'exports the locale value for the column header' do
|
|
486
|
+
expect(@res[0][1][0][1].length).to eq(12)
|
|
487
|
+
expect(@res[0][1][0][1][7]).to eq('Note Rate')
|
|
502
488
|
end
|
|
503
489
|
end
|
|
504
490
|
end
|
|
491
|
+
end
|