pvdgm_services 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/Rakefile +40 -0
- data/app/contexts/services/accept_hl7_message_context.rb +32 -0
- data/app/contexts/services/application_mds_context.rb +21 -0
- data/app/contexts/services/complete_sltc_registration_process_context.rb +23 -0
- data/app/contexts/services/create_account_mapping_context.rb +23 -0
- data/app/contexts/services/create_configured_account_context.rb +26 -0
- data/app/contexts/services/create_configured_facility_context.rb +26 -0
- data/app/contexts/services/create_credential_context.rb +23 -0
- data/app/contexts/services/create_facility_mapping_context.rb +23 -0
- data/app/contexts/services/create_public_key_context.rb +22 -0
- data/app/contexts/services/create_service_context.rb +22 -0
- data/app/contexts/services/create_service_definition_context.rb +26 -0
- data/app/contexts/services/create_sltc_registration_context.rb +24 -0
- data/app/contexts/services/create_third_party_context.rb +22 -0
- data/app/contexts/services/hl7_message_trimming_context.rb +19 -0
- data/app/contexts/services/invoke_service_context.rb +21 -0
- data/app/contexts/services/list_sltc_providers_context.rb +22 -0
- data/app/contexts/services/mds_file_processing_context.rb +27 -0
- data/app/contexts/services/mds_file_upload_context.rb +25 -0
- data/app/contexts/services/mds_pull_context.rb +21 -0
- data/app/contexts/services/monthly_service_table_cleanup_context.rb +19 -0
- data/app/contexts/services/notify_new_registration_context.rb +22 -0
- data/app/contexts/services/notify_sltc_provider_change_context.rb +19 -0
- data/app/contexts/services/request_sltc_baseline_context.rb +23 -0
- data/app/contexts/services/update_account_mapping_context.rb +23 -0
- data/app/contexts/services/update_configured_account_context.rb +26 -0
- data/app/contexts/services/update_configured_facility_context.rb +26 -0
- data/app/contexts/services/update_credential_context.rb +23 -0
- data/app/contexts/services/update_facility_mapping_context.rb +23 -0
- data/app/contexts/services/update_public_key_context.rb +23 -0
- data/app/contexts/services/update_service_context.rb +23 -0
- data/app/contexts/services/update_service_definition_context.rb +26 -0
- data/app/contexts/services/update_third_party_context.rb +23 -0
- data/app/controllers/services/account_mappings_controller.rb +54 -0
- data/app/controllers/services/adts_controller.rb +35 -0
- data/app/controllers/services/application_controller.rb +17 -0
- data/app/controllers/services/assessment_requests_controller.rb +48 -0
- data/app/controllers/services/available_files_controller.rb +19 -0
- data/app/controllers/services/configured_account_base_controller.rb +17 -0
- data/app/controllers/services/configured_accounts_controller.rb +59 -0
- data/app/controllers/services/configured_facilities_controller.rb +65 -0
- data/app/controllers/services/facility_mappings_controller.rb +58 -0
- data/app/controllers/services/mds_files_controller.rb +75 -0
- data/app/controllers/services/mds_pull_accounts_controller.rb +57 -0
- data/app/controllers/services/public_keys_controller.rb +50 -0
- data/app/controllers/services/service_base_controller.rb +18 -0
- data/app/controllers/services/service_definition_base_controller.rb +31 -0
- data/app/controllers/services/service_definitions_controller.rb +59 -0
- data/app/controllers/services/services_controller.rb +56 -0
- data/app/controllers/services/sltc_providers_controller.rb +15 -0
- data/app/controllers/services/sltc_registrations_controller.rb +74 -0
- data/app/controllers/services/status_masking.rb +17 -0
- data/app/controllers/services/third_parties_controller.rb +47 -0
- data/app/controllers/services/third_party_base_controller.rb +17 -0
- data/app/controllers/services/validation_controller.rb +17 -0
- data/app/helpers/services/application_helper.rb +8 -0
- data/app/helpers/services/assessment_request_helper.rb +19 -0
- data/app/helpers/services/available_files_helper.rb +27 -0
- data/app/helpers/services/mds_pull_accounts_helper.rb +27 -0
- data/app/helpers/services/sltc_registrations_helper.rb +15 -0
- data/app/mailers/services_mailer.rb +57 -0
- data/app/models/services/abaqis_mds_push.rb +51 -0
- data/app/models/services/account_mapping.rb +10 -0
- data/app/models/services/application_api.rb +19 -0
- data/app/models/services/assessment_request.rb +18 -0
- data/app/models/services/available_file.rb +73 -0
- data/app/models/services/configured_account.rb +26 -0
- data/app/models/services/configured_facility.rb +16 -0
- data/app/models/services/credential.rb +9 -0
- data/app/models/services/facility_mapping.rb +12 -0
- data/app/models/services/ftp_server.rb +69 -0
- data/app/models/services/hl7_inbound_service.rb +47 -0
- data/app/models/services/hl7_message.rb +27 -0
- data/app/models/services/isc_code.rb +15 -0
- data/app/models/services/isc_code_lookup.rb +75 -0
- data/app/models/services/mds_assessment.rb +371 -0
- data/app/models/services/mds_content.rb +55 -0
- data/app/models/services/mds_pull.rb +41 -0
- data/app/models/services/mds_pull_account.rb +192 -0
- data/app/models/services/mds_push.rb +24 -0
- data/app/models/services/mds_upload.rb +64 -0
- data/app/models/services/mds_upload_content.rb +148 -0
- data/app/models/services/mds_ws_response.rb +21 -0
- data/app/models/services/mds_ws_response_handler.rb +31 -0
- data/app/models/services/pcc_mds_pull.rb +77 -0
- data/app/models/services/provider_change.rb +26 -0
- data/app/models/services/public_key.rb +11 -0
- data/app/models/services/service.rb +20 -0
- data/app/models/services/service_definition.rb +37 -0
- data/app/models/services/service_implementation.rb +29 -0
- data/app/models/services/sltc_api.rb +179 -0
- data/app/models/services/sltc_api_exception.rb +54 -0
- data/app/models/services/sltc_mds_pull.rb +230 -0
- data/app/models/services/sltc_registration.rb +23 -0
- data/app/models/services/third_party.rb +18 -0
- data/app/roles/services/account_mapping_creator.rb +13 -0
- data/app/roles/services/account_mapping_updator.rb +12 -0
- data/app/roles/services/configured_account_creator.rb +13 -0
- data/app/roles/services/configured_account_updater.rb +12 -0
- data/app/roles/services/configured_facility_creator.rb +13 -0
- data/app/roles/services/configured_facility_updater.rb +12 -0
- data/app/roles/services/credential_creator.rb +11 -0
- data/app/roles/services/credential_updater.rb +20 -0
- data/app/roles/services/facility_mapping_creator.rb +13 -0
- data/app/roles/services/facility_mapping_updater.rb +11 -0
- data/app/roles/services/hl7_adt_message_saver.rb +15 -0
- data/app/roles/services/hl7_message_trimmer.rb +14 -0
- data/app/roles/services/mds_assessment_categorizer.rb +71 -0
- data/app/roles/services/mds_file_processor.rb +86 -0
- data/app/roles/services/mds_notifications.rb +44 -0
- data/app/roles/services/monthly_service_table_cleaner.rb +19 -0
- data/app/roles/services/new_registration_notifier.rb +11 -0
- data/app/roles/services/public_key_creator.rb +14 -0
- data/app/roles/services/public_key_updater.rb +12 -0
- data/app/roles/services/service_creator.rb +13 -0
- data/app/roles/services/service_definition_creator.rb +13 -0
- data/app/roles/services/service_definition_updater.rb +12 -0
- data/app/roles/services/service_invoker.rb +25 -0
- data/app/roles/services/service_updater.rb +11 -0
- data/app/roles/services/sltc_baseline_requestor.rb +19 -0
- data/app/roles/services/sltc_provider_change_notifier.rb +25 -0
- data/app/roles/services/sltc_provider_lister.rb +13 -0
- data/app/roles/services/sltc_registration_completer.rb +81 -0
- data/app/roles/services/sltc_registration_saver.rb +13 -0
- data/app/roles/services/submit_mds_file_for_processing.rb +28 -0
- data/app/roles/services/third_party_creator.rb +13 -0
- data/app/roles/services/third_party_updater.rb +12 -0
- data/app/utils/services/file_upload_handler.rb +33 -0
- data/app/utils/services/mds_upload_filters.rb +26 -0
- data/app/utils/services/mds_xml_file_parser.rb +104 -0
- data/app/utils/services/upload_file.rb +13 -0
- data/app/validators/isc_code_validator.rb +42 -0
- data/app/validators/mds_birthdate_validator.rb +37 -0
- data/app/validators/mds_date_validator.rb +8 -0
- data/app/validators/mds_integer_validator.rb +15 -0
- data/app/validators/mds_version_validator.rb +16 -0
- data/app/validators/state_code_validator.rb +9 -0
- data/app/views/layouts/services/application.html.erb +14 -0
- data/app/views/services/account_mappings/index.json.jbuilder +9 -0
- data/app/views/services/account_mappings/show.json.jbuilder +7 -0
- data/app/views/services/assessment_requests/index.json.jbuilder +11 -0
- data/app/views/services/available_files/index.json.jbuilder +13 -0
- data/app/views/services/configured_accounts/index.json.jbuilder +13 -0
- data/app/views/services/configured_accounts/show.json.jbuilder +11 -0
- data/app/views/services/configured_facilities/index.json.jbuilder +13 -0
- data/app/views/services/configured_facilities/show.json.jbuilder +11 -0
- data/app/views/services/facility_mappings/index.json.jbuilder +10 -0
- data/app/views/services/facility_mappings/show.json.jbuilder +8 -0
- data/app/views/services/mds_files/create.builder +10 -0
- data/app/views/services/mds_pull_accounts/index.json.jbuilder +11 -0
- data/app/views/services/public_keys/index.json.jbuilder +8 -0
- data/app/views/services/public_keys/show.json.jbuilder +6 -0
- data/app/views/services/service_definitions/index.json.jbuilder +17 -0
- data/app/views/services/service_definitions/show.json.jbuilder +16 -0
- data/app/views/services/services/index.json.jbuilder +6 -0
- data/app/views/services/services/show.json.jbuilder +4 -0
- data/app/views/services/sltc_providers/index.json.jbuilder +10 -0
- data/app/views/services/sltc_registrations/index.json.jbuilder +10 -0
- data/app/views/services/third_parties/index.json.jbuilder +7 -0
- data/app/views/services/third_parties/show.json.jbuilder +5 -0
- data/app/views/services_mailer/burying_job.html.erb +20 -0
- data/app/views/services_mailer/delaying_job.html.erb +20 -0
- data/app/views/services_mailer/notify_sltc_client_registration.html.erb +39 -0
- data/app/views/services_mailer/notify_sltc_client_registration_invalid_request_type.html.erb +8 -0
- data/app/views/services_mailer/notify_sltc_client_registration_request_invalid.html.erb +10 -0
- data/app/views/services_mailer/notify_sltc_client_registration_validation_errors.html.erb +13 -0
- data/app/views/services_mailer/notify_sltc_provider_changes.html.erb +26 -0
- data/app/views/services_mailer/notify_support_about_no_mds_pull.html.erb +6 -0
- data/config/routes.rb +48 -0
- data/db/migrate/20140102000000_create_services_engine_tables.rb +131 -0
- data/db/migrate/20140517184450_new_services_columns.rb +24 -0
- data/db/migrate/20140525142842_new_configured_provider_table.rb +18 -0
- data/db/migrate/20140714172442_add_error_column_to_hl7_messages.rb +5 -0
- data/db/migrate/20140730164152_mds_upload_tables.rb +78 -0
- data/db/sql_data/service_data_setup.sql +24 -0
- data/lib/services/engine.rb +40 -0
- data/lib/services/version.rb +3 -0
- data/lib/services.rb +4 -0
- data/lib/tasks/services_tasks.rake +40 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +60 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +29 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +35 -0
- data/spec/dummy/config/environments/production.rb +68 -0
- data/spec/dummy/config/environments/test.rb +32 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/email.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +237 -0
- data/spec/dummy/db/sql_data/services_isc_codes.sql +878 -0
- data/spec/dummy/log/test.log +3498 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/abaqis_mds_push_spec.rb +120 -0
- data/spec/models/available_file_spec.rb +234 -0
- data/spec/models/configured_account_spec.rb +39 -0
- data/spec/models/ftp_server_spec.rb +221 -0
- data/spec/models/isc_code_lookup_spec.rb +125 -0
- data/spec/models/isc_code_spec.rb +5 -0
- data/spec/models/mds_assessment_spec.rb +1070 -0
- data/spec/models/mds_pull_account_spec.rb +468 -0
- data/spec/models/mds_pull_spec.rb +48 -0
- data/spec/models/mds_push_spec.rb +43 -0
- data/spec/models/mds_ws_response_spec.rb +54 -0
- data/spec/models/pcc_mds_pull_spec.rb +273 -0
- data/spec/models/service_implementation_spec.rb +88 -0
- data/spec/models/sltc_api_exception_spec.rb +136 -0
- data/spec/models/sltc_api_spec.rb +192 -0
- data/spec/models/sltc_mds_pull_spec.rb +776 -0
- data/spec/roles/account_mapping_creator_spec.rb +40 -0
- data/spec/roles/account_mapping_updator_spec.rb +16 -0
- data/spec/roles/configured_account_creator_spec.rb +40 -0
- data/spec/roles/configured_account_updater_spec.rb +16 -0
- data/spec/roles/configured_facility_creator_spec.rb +40 -0
- data/spec/roles/configured_facility_updater_spec.rb +16 -0
- data/spec/roles/credential_creator_spec.rb +23 -0
- data/spec/roles/credential_updater_spec.rb +38 -0
- data/spec/roles/facility_mapping_creator_spec.rb +40 -0
- data/spec/roles/facility_mapping_updater_spec.rb +16 -0
- data/spec/roles/hl7_adt_message_saver_spec.rb +35 -0
- data/spec/roles/hl7_message_trimmer_spec.rb +31 -0
- data/spec/roles/monthly_service_table_cleaner_spec.rb +27 -0
- data/spec/roles/new_registration_notifier_spec.rb +18 -0
- data/spec/roles/service_ceator_spec.rb +34 -0
- data/spec/roles/service_definition_creator_spec.rb +40 -0
- data/spec/roles/service_definition_updater_spec.rb +16 -0
- data/spec/roles/service_invoker_spec.rb +22 -0
- data/spec/roles/service_updater_spec.rb +17 -0
- data/spec/roles/sltc_baseline_requestor_spec.rb +30 -0
- data/spec/roles/sltc_provider_lister_spec.rb +27 -0
- data/spec/roles/sltc_registration_completer_spec.rb +187 -0
- data/spec/roles/sltc_registration_saver_spec.rb +34 -0
- data/spec/roles/third_party_creator_spec.rb +34 -0
- data/spec/roles/third_party_updater_spec.rb +17 -0
- data/spec/spec_helper.rb +72 -0
- metadata +581 -0
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::FtpServer do
|
4
|
+
|
5
|
+
context 'Instance Methods' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@ftp_srvr = Services::FtpServer.new('www.abaqis.com',
|
9
|
+
'the user_name',
|
10
|
+
'the password',
|
11
|
+
'/home')
|
12
|
+
end
|
13
|
+
|
14
|
+
context '#connect' do
|
15
|
+
|
16
|
+
it "should invoke the specified block with the sftp connection variable" do
|
17
|
+
mock_sftp = double("SFTP")
|
18
|
+
|
19
|
+
Net::SFTP.
|
20
|
+
should_receive(:start).
|
21
|
+
with('www.abaqis.com',
|
22
|
+
'the user_name',
|
23
|
+
password: 'the password', auth_methods: %w{ publickey password }).
|
24
|
+
and_return(mock_sftp)
|
25
|
+
|
26
|
+
@ftp_srvr.connect do | server |
|
27
|
+
expect(server).to be(mock_sftp)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should raise an exception if unable to connect to the sftp server" do
|
32
|
+
mock_sftp = double("SFTP")
|
33
|
+
|
34
|
+
ex = Exception.new
|
35
|
+
|
36
|
+
Net::SFTP.
|
37
|
+
should_receive(:start).
|
38
|
+
with('www.abaqis.com',
|
39
|
+
'the user_name',
|
40
|
+
password: 'the password',
|
41
|
+
auth_methods: %w{ publickey password }).
|
42
|
+
and_raise(ex)
|
43
|
+
|
44
|
+
expect { @ftp_srvr.connect { | sftp | expect(sftp).to be(mock_sftp) } }.to raise_error(ex)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context '#path' do
|
49
|
+
|
50
|
+
it "should return a path that doesn't have a filename when none is specified" do
|
51
|
+
expect(@ftp_srvr.path('the_subdir')).to eq('/home/the user_name/the_subdir')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return a path that doesn't have a filename when a nil filename is specified" do
|
55
|
+
expect(@ftp_srvr.path('the_subdir', nil)).to eq('/home/the user_name/the_subdir')
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return a path that has the filename when one is specified" do
|
59
|
+
expect(@ftp_srvr.path('the_subdir', 'the_file')).to eq('/home/the user_name/the_subdir/the_file')
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
context '#file_list' do
|
65
|
+
|
66
|
+
before(:each) do
|
67
|
+
@mock_sftp = double("SFTP")
|
68
|
+
|
69
|
+
Net::SFTP.
|
70
|
+
stub(:start).
|
71
|
+
and_yield(@mock_sftp)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should raise an error if called outside a connect block" do
|
75
|
+
expect { @ftp_srvr.file_list('/tmp') }.to raise_error
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return the list of files found in the directory without specifying a glob pattern" do
|
79
|
+
entry_1 = double("Entry")
|
80
|
+
entry_1.should_receive(:file?).and_return(true)
|
81
|
+
entry_1.should_receive(:name).and_return("Entry 1")
|
82
|
+
|
83
|
+
entry_2 = double("Entry")
|
84
|
+
entry_2.should_receive(:file?).and_return(false)
|
85
|
+
entry_2.should_not_receive(:name)
|
86
|
+
|
87
|
+
entry_3 = double("Entry")
|
88
|
+
entry_3.should_receive(:file?).and_return(true)
|
89
|
+
entry_3.should_receive(:name).and_return("Entry 3")
|
90
|
+
|
91
|
+
@mock_sftp.should_receive(:dir).and_return do
|
92
|
+
double("Directory").tap do | directory |
|
93
|
+
directory.should_receive(:glob).with('/home/the user_name/the_subdir', '*').and_return([ entry_1, entry_2, entry_3 ])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
@ftp_srvr.connect do | server |
|
98
|
+
expect(server.file_list('the_subdir')).to eq([ 'Entry 1', 'Entry 3' ])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should return the list of files found in the directory specifying a glob pattern" do
|
103
|
+
entry_1 = double("Entry")
|
104
|
+
entry_1.should_receive(:file?).and_return(true)
|
105
|
+
entry_1.should_receive(:name).and_return("Entry 1.zip")
|
106
|
+
|
107
|
+
entry_2 = double("Entry")
|
108
|
+
entry_2.should_receive(:file?).and_return(false)
|
109
|
+
entry_2.should_not_receive(:name)
|
110
|
+
|
111
|
+
entry_3 = double("Entry")
|
112
|
+
entry_3.should_receive(:file?).and_return(true)
|
113
|
+
entry_3.should_receive(:name).and_return("Entry 3.zip")
|
114
|
+
|
115
|
+
@mock_sftp.should_receive(:dir).and_return do
|
116
|
+
double("Directory").tap do | directory |
|
117
|
+
directory.should_receive(:glob).with('/home/the user_name/the_subdir', '*.zip').and_return([ entry_1, entry_2, entry_3 ])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
@ftp_srvr.connect do | server |
|
122
|
+
expect(server.file_list('the_subdir', '*.zip')).to eq([ 'Entry 1.zip', 'Entry 3.zip' ])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
context '#download_files' do
|
129
|
+
|
130
|
+
before(:each) do
|
131
|
+
@mock_sftp = double("SFTP")
|
132
|
+
|
133
|
+
Net::SFTP.
|
134
|
+
stub(:start).
|
135
|
+
and_yield(@mock_sftp)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should call the download file method for each file in the list" do
|
139
|
+
@ftp_srvr.should_receive(:download_file).with('the_subdir', 'file_1', '/tmp')
|
140
|
+
@ftp_srvr.should_receive(:download_file).with('the_subdir', 'file_2', '/tmp')
|
141
|
+
|
142
|
+
@ftp_srvr.connect do | server |
|
143
|
+
server.download_files 'the_subdir', [ 'file_1', 'file_2' ], '/tmp'
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
context '#download_file' do
|
150
|
+
|
151
|
+
before(:each) do
|
152
|
+
@mock_sftp = double("SFTP")
|
153
|
+
|
154
|
+
Net::SFTP.
|
155
|
+
stub(:start).
|
156
|
+
and_yield(@mock_sftp)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should raise an exception if called outside a connect block" do
|
160
|
+
expect { @ftp_srvr.download_file 'the_subdir', 'file_1', '/tmp' }.to raise_error
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should download the specified file to the specified directory" do
|
164
|
+
@ftp_srvr.should_receive(:mkdir_p).with('/tmp')
|
165
|
+
@mock_sftp.should_receive(:download!).with('/home/the user_name/the_subdir/file_1', '/tmp/file_1')
|
166
|
+
|
167
|
+
@ftp_srvr.connect do | server |
|
168
|
+
server.download_file 'the_subdir', 'file_1', '/tmp'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
context '#remove_files' do
|
175
|
+
|
176
|
+
before(:each) do
|
177
|
+
@mock_sftp = double("SFTP")
|
178
|
+
|
179
|
+
Net::SFTP.
|
180
|
+
stub(:start).
|
181
|
+
and_yield(@mock_sftp)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should call the remove_file method for each file in the list" do
|
185
|
+
@ftp_srvr.should_receive(:remove_file).with('the_subdir', 'file_1')
|
186
|
+
@ftp_srvr.should_receive(:remove_file).with('the_subdir', 'file_2')
|
187
|
+
|
188
|
+
@ftp_srvr.connect do | server |
|
189
|
+
server.remove_files('the_subdir', [ 'file_1', 'file_2' ])
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
context '#remove_file' do
|
196
|
+
|
197
|
+
before(:each) do
|
198
|
+
@mock_sftp = double("SFTP")
|
199
|
+
|
200
|
+
Net::SFTP.
|
201
|
+
stub(:start).
|
202
|
+
and_yield(@mock_sftp)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should raise an exception when called outside of a connect block" do
|
206
|
+
expect { @ftp_srvr.remove_file 'the_subdir', 'file_1' }.to raise_error
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should call the ftp session to actually erase the file" do
|
210
|
+
@mock_sftp.should_receive(:remove!).with('/home/the user_name/the_subdir/file_1')
|
211
|
+
|
212
|
+
@ftp_srvr.connect do | server |
|
213
|
+
server.remove_file('the_subdir', 'file_1')
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::IscCodeLookup do
|
4
|
+
|
5
|
+
it "determines whether the calculated isc code from the assessment attributes matches the provided isc code" do
|
6
|
+
nc_attributes_nc_isc = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "10", "itm_sbst_cd" => "NC"}, version: Services::MdsAssessment::VERSION1_0
|
7
|
+
nc_attributes_nq_isc = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "10", "itm_sbst_cd" => "NQ"}, version: Services::MdsAssessment::VERSION1_0
|
8
|
+
|
9
|
+
Services::IscCodeLookup.new(nc_attributes_nc_isc).valid_isc_value?().should be(true)
|
10
|
+
Services::IscCodeLookup.new(nc_attributes_nq_isc).valid_isc_value?().should_not be(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "provides the isc lookup value and isc provided value from passed assessment attributes" do
|
14
|
+
nc_lookup_nc_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "NC"}, version: Services::MdsAssessment::VERSION1_0
|
15
|
+
nq_lookup_nq_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "02", "a0310b" => "01", "a0310c" => "0", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "NQ"}, version: Services::MdsAssessment::VERSION1_0
|
16
|
+
np_lookup_np_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "01", "a0310c" => "0", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "NP"}, version: Services::MdsAssessment::VERSION1_0
|
17
|
+
ns_lookup_nn_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "07", "a0310c" => "1", "a0310d" => "^", "a0310f" => "99", "itm_sbst_cd" => "NN"}, version: Services::MdsAssessment::VERSION1_0
|
18
|
+
nsd_lookup_xx_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "07", "a0310c" => "1", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "XX"}, version: Services::MdsAssessment::VERSION1_0
|
19
|
+
no_lookup_sp_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "07", "a0310c" => "2", "a0310d" => "^", "a0310f" => "99", "itm_sbst_cd" => "SP"}, version: Services::MdsAssessment::VERSION1_0
|
20
|
+
nod_lookup_nod_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "07", "a0310c" => "2", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "NOD"}, version: Services::MdsAssessment::VERSION1_0
|
21
|
+
nd_lookup_kl_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "KL"}, version: Services::MdsAssessment::VERSION1_0
|
22
|
+
nt_lookup_nt_provided = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d" => "^", "a0310f" => "01", "itm_sbst_cd" => "NT"}, version: Services::MdsAssessment::VERSION1_0
|
23
|
+
sp_lookup_sp_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "01", "a0310c" => "0", "a0310d" => "0", "a0310f" => "10", "itm_sbst_cd" => "SP"}, version: Services::MdsAssessment::VERSION1_0
|
24
|
+
ss_lookup_ss_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "07", "a0310c" => "1", "a0310d" => "0", "a0310f" => "99", "itm_sbst_cd" => "SS"}, version: Services::MdsAssessment::VERSION1_0
|
25
|
+
ssd_lookup_ss_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "07", "a0310c" => "1", "a0310d" => "0", "a0310f" => "10", "itm_sbst_cd" => "SS"}, version: Services::MdsAssessment::VERSION1_0
|
26
|
+
so_lookup_sod_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "07", "a0310c" => "2", "a0310d" => "0", "a0310f" => "99", "itm_sbst_cd" => "SOD"}, version: Services::MdsAssessment::VERSION1_0
|
27
|
+
sod_lookup_so_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "07", "a0310c" => "2", "a0310d" => "0", "a0310f" => "10", "itm_sbst_cd" => "SO"}, version: Services::MdsAssessment::VERSION1_0
|
28
|
+
sd_lookup_nq_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d" => "0", "a0310f" => "10", "itm_sbst_cd" => "NQ"}, version: Services::MdsAssessment::VERSION1_0
|
29
|
+
st_lookup_st_provided = Services::MdsAssessment.new responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d" => "0", "a0310f" => "01", "itm_sbst_cd" => "ST"}, version: Services::MdsAssessment::VERSION1_0
|
30
|
+
|
31
|
+
#adding this one due to new isc lookup values using the new a0310c value of 4
|
32
|
+
nc_lookup_nc_provided2 = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "02", "a0310c" => "4", "a0310d" => "^", "a0310f" => "10", "itm_sbst_cd" => "NC"}, version: Services::MdsAssessment::VERSION1_0
|
33
|
+
|
34
|
+
Services::IscCodeLookup.new(nc_lookup_nc_provided).isc_lookup_value.should == 'NC'
|
35
|
+
Services::IscCodeLookup.new(nc_lookup_nc_provided).isc_provided_value.should == 'NC'
|
36
|
+
|
37
|
+
Services::IscCodeLookup.new(nq_lookup_nq_provided).isc_lookup_value.should == 'NQ'
|
38
|
+
Services::IscCodeLookup.new(nq_lookup_nq_provided).isc_provided_value.should == 'NQ'
|
39
|
+
|
40
|
+
Services::IscCodeLookup.new(np_lookup_np_provided).isc_lookup_value.should == 'NP'
|
41
|
+
Services::IscCodeLookup.new(np_lookup_np_provided).isc_provided_value.should == 'NP'
|
42
|
+
|
43
|
+
Services::IscCodeLookup.new(ns_lookup_nn_provided).isc_lookup_value.should == 'NS'
|
44
|
+
Services::IscCodeLookup.new(ns_lookup_nn_provided).isc_provided_value.should == 'NN'
|
45
|
+
|
46
|
+
Services::IscCodeLookup.new(nsd_lookup_xx_provided).isc_lookup_value.should == 'NSD'
|
47
|
+
Services::IscCodeLookup.new(nsd_lookup_xx_provided).isc_provided_value.should == 'XX'
|
48
|
+
|
49
|
+
Services::IscCodeLookup.new(no_lookup_sp_provided).isc_lookup_value.should == 'NO'
|
50
|
+
Services::IscCodeLookup.new(no_lookup_sp_provided).isc_provided_value.should == 'SP'
|
51
|
+
|
52
|
+
Services::IscCodeLookup.new(nod_lookup_nod_provided).isc_lookup_value.should == 'NOD'
|
53
|
+
Services::IscCodeLookup.new(nod_lookup_nod_provided).isc_provided_value.should == 'NOD'
|
54
|
+
|
55
|
+
Services::IscCodeLookup.new(nd_lookup_kl_provided).isc_lookup_value.should == 'ND'
|
56
|
+
Services::IscCodeLookup.new(nd_lookup_kl_provided).isc_provided_value.should == 'KL'
|
57
|
+
|
58
|
+
Services::IscCodeLookup.new(nt_lookup_nt_provided).isc_lookup_value.should == 'NT'
|
59
|
+
Services::IscCodeLookup.new(nt_lookup_nt_provided).isc_provided_value.should == 'NT'
|
60
|
+
|
61
|
+
Services::IscCodeLookup.new(sp_lookup_sp_provided).isc_lookup_value.should == 'SP'
|
62
|
+
Services::IscCodeLookup.new(sp_lookup_sp_provided).isc_provided_value.should == 'SP'
|
63
|
+
|
64
|
+
Services::IscCodeLookup.new(ss_lookup_ss_provided).isc_lookup_value.should == 'SS'
|
65
|
+
Services::IscCodeLookup.new(ss_lookup_ss_provided).isc_provided_value.should == 'SS'
|
66
|
+
|
67
|
+
Services::IscCodeLookup.new(ssd_lookup_ss_provided).isc_lookup_value.should == 'SSD'
|
68
|
+
Services::IscCodeLookup.new(ssd_lookup_ss_provided).isc_provided_value.should == 'SS'
|
69
|
+
|
70
|
+
Services::IscCodeLookup.new(so_lookup_sod_provided).isc_lookup_value.should == 'SO'
|
71
|
+
Services::IscCodeLookup.new(so_lookup_sod_provided).isc_provided_value.should == 'SOD'
|
72
|
+
|
73
|
+
Services::IscCodeLookup.new(sod_lookup_so_provided).isc_lookup_value.should == 'SOD'
|
74
|
+
Services::IscCodeLookup.new(sod_lookup_so_provided).isc_provided_value.should == 'SO'
|
75
|
+
|
76
|
+
Services::IscCodeLookup.new(sd_lookup_nq_provided).isc_lookup_value.should == 'SD'
|
77
|
+
Services::IscCodeLookup.new(sd_lookup_nq_provided).isc_provided_value.should == 'NQ'
|
78
|
+
|
79
|
+
Services::IscCodeLookup.new(st_lookup_st_provided).isc_lookup_value.should == 'ST'
|
80
|
+
Services::IscCodeLookup.new(st_lookup_st_provided).isc_provided_value.should == 'ST'
|
81
|
+
|
82
|
+
Services::IscCodeLookup.new(nc_lookup_nc_provided2).isc_lookup_value.should == "NC"
|
83
|
+
Services::IscCodeLookup.new(nc_lookup_nc_provided2).isc_provided_value.should == "NC"
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
it "the isc lookup value is nil if the assessment attributes do not match any isc lookup codes" do
|
88
|
+
invalid_isc_attributes = Services::MdsAssessment.new responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "01", "itm_sbst_cd" => "NQ"}, version: Services::MdsAssessment::VERSION1_0
|
89
|
+
Services::IscCodeLookup.new(invalid_isc_attributes).isc_lookup_value.should be_nil
|
90
|
+
end
|
91
|
+
|
92
|
+
it "the isc lookup value is nil if any of the required attributes are nil" do
|
93
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => nil, "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "01", "itm_sbst_cd" => "NC"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
94
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => nil, "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "01", "itm_sbst_cd" => "NQ"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
95
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => nil, "a0310c" => "0", "a0310d"=> "^", "a0310f" => "01", "itm_sbst_cd" => "NT"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
96
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => nil, "a0310d"=> "^", "a0310f" => "01", "itm_sbst_cd" => "SP"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
97
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d"=> nil, "a0310f" => "01", "itm_sbst_cd" => "SS"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
98
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => nil, "itm_sbst_cd" => "ST"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it "the isc lookup value is nil if any a0310a, a0310b, a0310f do not have leading zeros" do
|
102
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "1", "a0310b" => "01", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "10", "itm_sbst_cd" => ""}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
103
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "99", "a0310b" => "7", "a0310c" => "1", "a0310d"=> "^", "a0310f" => "10", "itm_sbst_cd" => ""}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
104
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d"=> "0", "a0310f" => "1", "itm_sbst_cd" => ""}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should be_nil
|
105
|
+
end
|
106
|
+
|
107
|
+
#it "raises an ArgumentError if the provided isc value (itm_sbst_cd) is not passed in" do
|
108
|
+
#expect {Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "1", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "10"}, version: Services::MdsAssessment::VERSION1_0}))}.to raise_error(ArgumentError)
|
109
|
+
#end
|
110
|
+
|
111
|
+
it "isc code is invalid if the provided isc code is nil" do
|
112
|
+
Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "1", "a0310a" => "01", "a0310b" => "1", "a0310c" => "0", "a0310d"=> "^", "a0310f" => "10", "itm_sbst_cd" => nil}, version: Services::MdsAssessment::VERSION1_0)).valid_isc_value?.should_not be(true)
|
113
|
+
end
|
114
|
+
|
115
|
+
#it "returns the inactivation isc code if X0100 = 3 for the 1.00 version of the mds" do
|
116
|
+
#Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d"=> "0", "a0310f" => "01", "itm_sbst_cd" => "BLAH", "x0100" => "3", "a0050" => "1"}, version: Services::MdsAssessment::VERSION1_0)).isc_lookup_value.should == 'XX'
|
117
|
+
#end
|
118
|
+
|
119
|
+
#it "returns the inactivation isc code if a0050 = 3 for the 1.10 version of the mds" do
|
120
|
+
#Services::IscCodeLookup.new(Services::MdsAssessment.new(responses: {"a0200" => "2", "a0310a" => "99", "a0310b" => "99", "a0310c" => "0", "a0310d"=> "0", "a0310f" => "01", "itm_sbst_cd" => "BLAH", "x0100" => "1", "a0050" => "3"}, version: Services::MdsAssessment::VERSION1_1)).isc_lookup_value.should == 'XX'
|
121
|
+
#end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
end
|