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,273 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::PccMdsPull do
|
4
|
+
|
5
|
+
context '#Instance Methods' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@mock_sd = mock_model(Services::ServiceDefinition)
|
9
|
+
@mock_sd.stub(:hostname).and_return('the_server')
|
10
|
+
@mock_sd.stub(:username).and_return('the_user')
|
11
|
+
@mock_sd.stub(:base_uri).and_return('/home')
|
12
|
+
|
13
|
+
mock_credentials = mock_model(Services::Credential)
|
14
|
+
mock_credentials.stub(:password).and_return('the_password')
|
15
|
+
|
16
|
+
@mock_account_map = mock_model(Services::AccountMapping)
|
17
|
+
@mock_account_map.stub(:account_code).and_return('kind')
|
18
|
+
|
19
|
+
@pcc_mds_pull = Services::PccMdsPull.new(@mock_sd)
|
20
|
+
@pcc_mds_pull.stub(:server_credentials).and_return(mock_credentials)
|
21
|
+
@pcc_mds_pull.stub(:account_map).and_return(@mock_account_map)
|
22
|
+
end
|
23
|
+
|
24
|
+
context '#ftp_server' do
|
25
|
+
|
26
|
+
it "should return a reference to the ftp server to use for file access" do
|
27
|
+
mock_ftp_server = double("FtpServer")
|
28
|
+
Services::FtpServer.
|
29
|
+
should_receive(:new).
|
30
|
+
with('the_server',
|
31
|
+
'the_user',
|
32
|
+
'the_password',
|
33
|
+
'/home').
|
34
|
+
and_return(mock_ftp_server)
|
35
|
+
|
36
|
+
expect(@pcc_mds_pull.ftp_server).to be(mock_ftp_server)
|
37
|
+
|
38
|
+
# Call it again; but it shouldn't construct a new instance
|
39
|
+
# (see expectations)
|
40
|
+
expect(@pcc_mds_pull.ftp_server).to be(mock_ftp_server)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context '#list_available_files' do
|
46
|
+
|
47
|
+
before(:each) do
|
48
|
+
@mock_ftp_server = double("FtpServer")
|
49
|
+
@mock_ftp_server.
|
50
|
+
stub(:connect).
|
51
|
+
and_yield(@mock_ftp_server)
|
52
|
+
|
53
|
+
@mock_configured_account = mock_model(Services::ConfiguredAccount)
|
54
|
+
@mock_configured_account.stub(:account_id).and_return(3)
|
55
|
+
|
56
|
+
@pcc_mds_pull.stub(:ftp_server).and_return(@mock_ftp_server)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return an empty array if no files are available" do
|
60
|
+
@mock_ftp_server.
|
61
|
+
should_receive(:file_list).
|
62
|
+
with('kind', '*.zip').
|
63
|
+
and_return([])
|
64
|
+
|
65
|
+
expect(@pcc_mds_pull.list_available_files(@mock_configured_account)).to eq([])
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return an array of tuples when files are available" do
|
69
|
+
@mock_ftp_server.
|
70
|
+
should_receive(:file_list).
|
71
|
+
with('kind', '*.zip').
|
72
|
+
and_return([ 'file_1.zip', 'file_2.zip' ])
|
73
|
+
|
74
|
+
expect(@pcc_mds_pull.list_available_files(@mock_configured_account)).to eq([ [ 'file_1.zip', 'file_1.zip' ], [ 'file_2.zip', 'file_2.zip' ] ])
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
context '#perform_file_downloads' do
|
80
|
+
|
81
|
+
before(:each) do
|
82
|
+
@mock_ftp_server = double("FtpServer")
|
83
|
+
@mock_ftp_server.
|
84
|
+
stub(:connect).
|
85
|
+
and_yield(@mock_ftp_server)
|
86
|
+
|
87
|
+
@mock_configured_account = mock_model(Services::ConfiguredAccount)
|
88
|
+
@mock_configured_account.stub(:account_id).and_return(3)
|
89
|
+
|
90
|
+
@pcc_mds_pull.stub(:ftp_server).and_return(@mock_ftp_server)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return an empty array of available file ids if no files are specified for download" do
|
94
|
+
@pcc_mds_pull.
|
95
|
+
should_not_receive(:download_file)
|
96
|
+
|
97
|
+
expect(@pcc_mds_pull.perform_file_downloads(@mock_configured_account, [])).to eq([])
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should return an array of the available file ids that were actually downloaded" do
|
101
|
+
mock_af_1 = mock_model(Services::AvailableFile)
|
102
|
+
mock_af_2 = mock_model(Services::AvailableFile)
|
103
|
+
mock_af_3 = mock_model(Services::AvailableFile)
|
104
|
+
|
105
|
+
@pcc_mds_pull.
|
106
|
+
should_receive(:download_file).
|
107
|
+
with(@mock_ftp_server, mock_af_1, 'kind').
|
108
|
+
and_return(mock_af_1.id)
|
109
|
+
@pcc_mds_pull.
|
110
|
+
should_receive(:download_file).
|
111
|
+
with(@mock_ftp_server, mock_af_2, 'kind').
|
112
|
+
and_return(nil) # File not actually downloaded successfully
|
113
|
+
@pcc_mds_pull.
|
114
|
+
should_receive(:download_file).
|
115
|
+
with(@mock_ftp_server, mock_af_3, 'kind').
|
116
|
+
and_return(mock_af_3.id)
|
117
|
+
|
118
|
+
expect(@pcc_mds_pull.perform_file_downloads(@mock_configured_account, [mock_af_1, mock_af_2, mock_af_3])).to eq([ mock_af_1.id, mock_af_3.id ])
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
context '#perform_cleanup_on_remote_server' do
|
124
|
+
|
125
|
+
before(:each) do
|
126
|
+
@mock_ftp_server = double("FtpServer")
|
127
|
+
@mock_ftp_server.
|
128
|
+
stub(:connect).
|
129
|
+
and_yield(@mock_ftp_server)
|
130
|
+
|
131
|
+
@mock_configured_account = mock_model(Services::ConfiguredAccount)
|
132
|
+
@mock_configured_account.stub(:account_id).and_return(3)
|
133
|
+
|
134
|
+
@pcc_mds_pull.stub(:ftp_server).and_return(@mock_ftp_server)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should return an empty array if no files needed to be cleaned up" do
|
138
|
+
@mock_configured_account.should_receive(:available_files).and_return do
|
139
|
+
double("AvailableFiles").tap do | available_files |
|
140
|
+
available_files.should_receive(:deleted).and_return([])
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
@pcc_mds_pull.should_not_receive(:remove_file)
|
145
|
+
|
146
|
+
expect(@pcc_mds_pull.perform_cleanup_on_remote_server(@mock_configured_account)).to eq([])
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return an empty array if no files were successfully cleaned up" do
|
150
|
+
mock_af_1 = mock_model(Services::AvailableFile)
|
151
|
+
mock_af_2 = mock_model(Services::AvailableFile)
|
152
|
+
mock_af_3 = mock_model(Services::AvailableFile)
|
153
|
+
|
154
|
+
@mock_configured_account.should_receive(:available_files).and_return do
|
155
|
+
double("AvailableFiles").tap do | available_files |
|
156
|
+
available_files.should_receive(:deleted).and_return([ mock_af_1, mock_af_2, mock_af_3 ])
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
@pcc_mds_pull.
|
161
|
+
should_receive(:remove_file).
|
162
|
+
with(@mock_ftp_server, mock_af_1, 'kind').
|
163
|
+
and_return(nil)
|
164
|
+
|
165
|
+
@pcc_mds_pull.
|
166
|
+
should_receive(:remove_file).
|
167
|
+
with(@mock_ftp_server, mock_af_2, 'kind').
|
168
|
+
and_return(nil)
|
169
|
+
|
170
|
+
@pcc_mds_pull.
|
171
|
+
should_receive(:remove_file).
|
172
|
+
with(@mock_ftp_server, mock_af_3, 'kind').
|
173
|
+
and_return(nil)
|
174
|
+
|
175
|
+
expect(@pcc_mds_pull.perform_cleanup_on_remote_server(@mock_configured_account)).to eq([])
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should return an array of the successfully removed files" do
|
179
|
+
mock_af_1 = mock_model(Services::AvailableFile)
|
180
|
+
mock_af_2 = mock_model(Services::AvailableFile)
|
181
|
+
mock_af_3 = mock_model(Services::AvailableFile)
|
182
|
+
|
183
|
+
@mock_configured_account.should_receive(:available_files).and_return do
|
184
|
+
double("AvailableFiles").tap do | available_files |
|
185
|
+
available_files.should_receive(:deleted).and_return([ mock_af_1, mock_af_2, mock_af_3 ])
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
@pcc_mds_pull.
|
190
|
+
should_receive(:remove_file).
|
191
|
+
with(@mock_ftp_server, mock_af_1, 'kind').
|
192
|
+
and_return(23)
|
193
|
+
|
194
|
+
@pcc_mds_pull.
|
195
|
+
should_receive(:remove_file).
|
196
|
+
with(@mock_ftp_server, mock_af_2, 'kind').
|
197
|
+
and_return(nil)
|
198
|
+
|
199
|
+
@pcc_mds_pull.
|
200
|
+
should_receive(:remove_file).
|
201
|
+
with(@mock_ftp_server, mock_af_3, 'kind').
|
202
|
+
and_return(82)
|
203
|
+
|
204
|
+
expect(@pcc_mds_pull.perform_cleanup_on_remote_server(@mock_configured_account)).to eq([ 23, 82 ])
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
context '#download_file' do
|
210
|
+
|
211
|
+
it "should return the id of the file if successfully downloaded" do
|
212
|
+
mock_af = mock_model(Services::AvailableFile)
|
213
|
+
mock_af.should_receive(:request_id).and_return('file_1')
|
214
|
+
mock_af.should_receive(:download_path).and_return('/tmp')
|
215
|
+
|
216
|
+
mock_server = double("FtpServer")
|
217
|
+
mock_server.
|
218
|
+
should_receive(:download_file).
|
219
|
+
with('kind', 'file_1', '/tmp')
|
220
|
+
|
221
|
+
expect(@pcc_mds_pull.download_file(mock_server, mock_af, 'kind')).to eq(mock_af.id)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should return nil if file was not successfully downloaded" do
|
225
|
+
mock_af = mock_model(Services::AvailableFile)
|
226
|
+
mock_af.should_receive(:request_id).and_return('file_1')
|
227
|
+
mock_af.should_receive(:download_path).and_return('/tmp')
|
228
|
+
mock_af.should_receive(:to_rrepr).and_return("")
|
229
|
+
|
230
|
+
mock_server = double("FtpServer")
|
231
|
+
mock_server.
|
232
|
+
should_receive(:download_file).
|
233
|
+
with('kind', 'file_1', '/tmp').
|
234
|
+
and_raise(Exception)
|
235
|
+
|
236
|
+
expect(@pcc_mds_pull.download_file(mock_server, mock_af, 'kind')).to be_nil
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
context '#remove_file' do
|
242
|
+
|
243
|
+
it "should return the id of the file if successfully removed" do
|
244
|
+
mock_af = mock_model(Services::AvailableFile)
|
245
|
+
mock_af.should_receive(:request_id).and_return('file_1')
|
246
|
+
|
247
|
+
mock_server = double("FtpServer")
|
248
|
+
mock_server.
|
249
|
+
should_receive(:remove_file).
|
250
|
+
with('kind', 'file_1')
|
251
|
+
|
252
|
+
expect(@pcc_mds_pull.remove_file(mock_server, mock_af, 'kind')).to eq(mock_af.id)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should return nil if the file is not successfully removed" do
|
256
|
+
mock_af = mock_model(Services::AvailableFile)
|
257
|
+
mock_af.should_receive(:request_id).and_return('file_1')
|
258
|
+
mock_af.should_receive(:to_rrepr).and_return("")
|
259
|
+
|
260
|
+
mock_server = double("FtpServer")
|
261
|
+
mock_server.
|
262
|
+
should_receive(:remove_file).
|
263
|
+
with('kind', 'file_1').
|
264
|
+
and_raise(Exception)
|
265
|
+
|
266
|
+
expect(@pcc_mds_pull.remove_file(mock_server, mock_af, 'kind')).to be_nil
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::ServiceImplementation do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@mock_sd = double("ServiceDefinition")
|
7
|
+
end
|
8
|
+
|
9
|
+
context '#initialize' do
|
10
|
+
|
11
|
+
it "should hold onto the specified service definition" do
|
12
|
+
si = Services::ServiceImplementation.new @mock_sd
|
13
|
+
|
14
|
+
expect(si.service_definition).to be(@mock_sd)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#server_credentials' do
|
20
|
+
|
21
|
+
it "should return the first set of credentials associated with the service definition" do
|
22
|
+
mock_credentials = double("Credentials")
|
23
|
+
|
24
|
+
si = Services::ServiceImplementation.new @mock_sd
|
25
|
+
|
26
|
+
@mock_sd.should_receive(:credentials).and_return([ mock_credentials ])
|
27
|
+
|
28
|
+
expect(si.server_credentials).to be(mock_credentials)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should cache the credentials after the first call" do
|
32
|
+
mock_credentials = double("Credentials")
|
33
|
+
|
34
|
+
si = Services::ServiceImplementation.new @mock_sd
|
35
|
+
|
36
|
+
@mock_sd.should_receive(:credentials).exactly(1).times.and_return([ mock_credentials ])
|
37
|
+
|
38
|
+
expect(si.server_credentials).to be(mock_credentials)
|
39
|
+
|
40
|
+
expect(si.server_credentials).to be(mock_credentials)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should raise an exception if there are no credentials associated with the server" do
|
44
|
+
si = Services::ServiceImplementation.new @mock_sd
|
45
|
+
|
46
|
+
@mock_sd.should_receive(:credentials).exactly(1).times.and_return([ ])
|
47
|
+
@mock_sd.should_receive(:to_rrepr).and_return("The Error")
|
48
|
+
|
49
|
+
expect { si.server_credentials }.to raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
context '#account_map' do
|
55
|
+
|
56
|
+
it "should look up the account mapping for the specified account id" do
|
57
|
+
@mock_sd.should_receive(:third_party_id).and_return(9)
|
58
|
+
|
59
|
+
si = Services::ServiceImplementation.new @mock_sd
|
60
|
+
|
61
|
+
mock_account_map = double("AccountMapping")
|
62
|
+
|
63
|
+
Services::AccountMapping.
|
64
|
+
should_receive(:where).
|
65
|
+
with(account_id: 2, third_party_id: 9).
|
66
|
+
and_return([ mock_account_map ])
|
67
|
+
|
68
|
+
expect(si.account_map(2)).to be(mock_account_map)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should raise an exception if the account mapping doesn't exist" do
|
72
|
+
@mock_sd.should_receive(:third_party_id).and_return(9)
|
73
|
+
|
74
|
+
@mock_sd.should_receive(:to_rrepr).and_return("The Error")
|
75
|
+
|
76
|
+
si = Services::ServiceImplementation.new @mock_sd
|
77
|
+
|
78
|
+
Services::AccountMapping.
|
79
|
+
should_receive(:where).
|
80
|
+
with(account_id: 2, third_party_id: 9).
|
81
|
+
and_return([ ])
|
82
|
+
|
83
|
+
expect { si.account_map(2) }.to raise_error
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::SltcApiException do
|
4
|
+
|
5
|
+
context '#initialize' do
|
6
|
+
|
7
|
+
it "should have a message that is whatever is returned from :format_exception_message" do
|
8
|
+
inner_exception = Exception.new
|
9
|
+
|
10
|
+
ex = Services::SltcApiException.new(inner_exception)
|
11
|
+
expect(ex.message).to eq("Unknown SimpleLTC API Error (no http_code associated with inner exception)")
|
12
|
+
expect(ex.inner_exception).to eq(inner_exception)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'Public Instance Methods' do
|
18
|
+
|
19
|
+
context '#http_code' do
|
20
|
+
|
21
|
+
it "should return the value of the http_code attribute of the inner exception" do
|
22
|
+
inner_exception = Exception.new("Error Message")
|
23
|
+
inner_exception.stub(:http_code).and_return(500)
|
24
|
+
|
25
|
+
ex = Services::SltcApiException.new(inner_exception)
|
26
|
+
expect(ex.http_code).to eq(500)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return nil if the inner exception doesn't have an http_code attribute" do
|
30
|
+
inner_exception = Exception.new("Error Message")
|
31
|
+
|
32
|
+
ex = Services::SltcApiException.new(inner_exception)
|
33
|
+
expect(ex.http_code).to be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
context '#http_message' do
|
39
|
+
|
40
|
+
it "should return the message string from the inner exception" do
|
41
|
+
inner_exception = Exception.new("Error Message")
|
42
|
+
|
43
|
+
ex = Services::SltcApiException.new(inner_exception)
|
44
|
+
expect(ex.http_message).to eq("Error Message")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'Private Instance Methods' do
|
52
|
+
|
53
|
+
context '#basic_message_fmt' do
|
54
|
+
|
55
|
+
it "should provide a message that displays the http_code and message when an http_code is present" do
|
56
|
+
mock_exception = double("Exception")
|
57
|
+
mock_exception.stub(:http_code).and_return(500)
|
58
|
+
mock_exception.stub(:message).and_return("General Error")
|
59
|
+
|
60
|
+
ex = Services::SltcApiException.new(mock_exception)
|
61
|
+
expect(ex.send(:basic_message_fmt)).to eq("500: General Error")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return a general message if no http_code is found on the inner exception" do
|
65
|
+
inner_exception = Exception.new
|
66
|
+
ex = Services::SltcApiException.new(inner_exception)
|
67
|
+
expect(ex.send(:basic_message_fmt)).to eq("no http_code associated with inner exception")
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
context '#extract_sltc_error_information' do
|
73
|
+
|
74
|
+
it "should return an error message displaying the SLTC error code/message when provided in the response" do
|
75
|
+
inner_exception = Exception.new("Error Message")
|
76
|
+
inner_exception.stub(:http_code).and_return(500)
|
77
|
+
inner_exception.stub(:response).and_return('{ "ErrorCode": 12, "Message": "Sltc Error Message" }')
|
78
|
+
|
79
|
+
ex = Services::SltcApiException.new(inner_exception)
|
80
|
+
expect(ex.send(:extract_sltc_error_information)).to eq("SimpleLTC error response: (12) Sltc Error Message (500: Error Message)")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return the raw json as part of the message if no 'Message' key is found in response" do
|
84
|
+
inner_exception = Exception.new("Error Message")
|
85
|
+
inner_exception.stub(:http_code).and_return(500)
|
86
|
+
inner_exception.stub(:response).and_return('{ "ErrorCode": 12 }')
|
87
|
+
|
88
|
+
ex = Services::SltcApiException.new(inner_exception)
|
89
|
+
expect(ex.send(:extract_sltc_error_information)).to eq("No error message in SimpleLTC error response ({ \"ErrorCode\": 12 }) (500: Error Message)")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return the raw json as part of the message if the response json does not parse to a hash" do
|
93
|
+
inner_exception = Exception.new("Error Message")
|
94
|
+
inner_exception.stub(:http_code).and_return(500)
|
95
|
+
inner_exception.stub(:response).and_return('[ 1 ]')
|
96
|
+
|
97
|
+
ex = Services::SltcApiException.new(inner_exception)
|
98
|
+
expect(ex.send(:extract_sltc_error_information)).to eq("No error message in SimpleLTC error response ([ 1 ]) (500: Error Message)")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should format the exception returned when there was an error parsing the json response" do
|
102
|
+
inner_exception = Exception.new("Error Message")
|
103
|
+
inner_exception.stub(:http_code).and_return(500)
|
104
|
+
inner_exception.stub(:response).and_return('{ "ErrorCode":')
|
105
|
+
|
106
|
+
ex = Services::SltcApiException.new(inner_exception)
|
107
|
+
expect(ex.send(:extract_sltc_error_information)).to eq("Error parsing SimpleLTC API Error JSON ({ \"ErrorCode\":): 757: unexpected token at '{ \"ErrorCode\":' (500: Error Message)")
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
context '#format_exception_message' do
|
113
|
+
|
114
|
+
it "should return a generic error message if there is no raw json" do
|
115
|
+
inner_exception = Exception.new("Error Message")
|
116
|
+
inner_exception.stub(:http_code).and_return(500)
|
117
|
+
inner_exception.stub(:response).and_return(nil)
|
118
|
+
|
119
|
+
ex = Services::SltcApiException.new(inner_exception)
|
120
|
+
expect(ex.send(:format_exception_message)).to eq("Unknown SimpleLTC API Error (500: Error Message)")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should return the value returned by extract_sltc_error_information if the json response is not nil" do
|
124
|
+
inner_exception = Exception.new("Error Message")
|
125
|
+
inner_exception.stub(:http_code).and_return(500)
|
126
|
+
inner_exception.stub(:response).and_return('{ "ErrorCode": 12, "Message": "Sltc Error Message" }')
|
127
|
+
|
128
|
+
ex = Services::SltcApiException.new(inner_exception)
|
129
|
+
ex.should_receive(:extract_sltc_error_information).and_return("Message returned from extract_sltc_error_information")
|
130
|
+
expect(ex.send(:format_exception_message)).to eq("Message returned from extract_sltc_error_information")
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::SltcApi do
|
4
|
+
|
5
|
+
context '#initialize' do
|
6
|
+
|
7
|
+
it "should faithfully reproduce the parameters in the accessors" do
|
8
|
+
|
9
|
+
api = Services::SltcApi.new("https://api-test.simpleltc.com/v1",
|
10
|
+
"the_token",
|
11
|
+
"the_account",
|
12
|
+
"the_username",
|
13
|
+
"the_password")
|
14
|
+
|
15
|
+
expect(api.base_uri).to eq('https://api-test.simpleltc.com/v1')
|
16
|
+
expect(api.api_key).to eq('the_token')
|
17
|
+
expect(api.account).to eq('the_account')
|
18
|
+
expect(api.username).to eq('the_username')
|
19
|
+
expect(api.password).to eq('the_password')
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'Instance Methods' do
|
26
|
+
|
27
|
+
before(:each) do
|
28
|
+
@api = Services::SltcApi.new("https://api-test.simpleltc.com/v1",
|
29
|
+
"the_token",
|
30
|
+
"the_account",
|
31
|
+
"the_username",
|
32
|
+
"the_password")
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context '#get_response' do
|
37
|
+
|
38
|
+
it "should return a hash converted from JSON when using the default no-parameter" do
|
39
|
+
response = @api.send(:get_response) do
|
40
|
+
'{ "Message" : "The Message" }'
|
41
|
+
end
|
42
|
+
|
43
|
+
expect(response).to be_a(Hash)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return the raw body of the block if the 'binary_response' parameter is true" do
|
47
|
+
response = @api.send(:get_response, true) do
|
48
|
+
'{ "Message" : "The Message" }'
|
49
|
+
end
|
50
|
+
|
51
|
+
expect(response).to eq('{ "Message" : "The Message" }')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should raise an SltcApiException if a RestClient::Exception is raised in the block" do
|
55
|
+
expect { @api.send(:get_response) { raise RestClient::Exception } }.to raise_error(Services::SltcApiException)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should allow a non-RestClient::Exception to be raised out of the method" do
|
59
|
+
ex = Exception.new
|
60
|
+
expect { @api.send(:get_response) { raise ex } }.to raise_error(ex)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context '#authentication_headers' do
|
66
|
+
|
67
|
+
it "should return a hash of the headers to be sent for authentication" do
|
68
|
+
expected_hash = {
|
69
|
+
'SLTC-Api-Key' => 'the_token',
|
70
|
+
"Host"=>"api-test.simpleltc.com"
|
71
|
+
}
|
72
|
+
|
73
|
+
expect(@api.send(:authentication_headers)).to eq(expected_hash)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context '#list_providers' do
|
78
|
+
|
79
|
+
it "should make the web service call and return the response as a hash" do
|
80
|
+
json = '[ { "id" : 3993, "name" : "Rouster Health" }, { "id" : 3994, "name" : "Blueth Health" }, { "id" : 4003, "name" : "Orange Health" } ]'
|
81
|
+
providers = [
|
82
|
+
{ 'id' => 3993, 'name' => "Rouster Health" },
|
83
|
+
{ 'id' => 3994, 'name' => "Blueth Health" },
|
84
|
+
{ 'id' => 4003, 'name' => "Orange Health" }
|
85
|
+
]
|
86
|
+
|
87
|
+
@api.should_receive(:build_url).and_return('the_url')
|
88
|
+
@api.should_receive(:authentication_headers).and_return( { header: 'the_headers' } )
|
89
|
+
|
90
|
+
RestClient::Request.
|
91
|
+
should_receive(:execute).
|
92
|
+
with({ method: :get,
|
93
|
+
url: 'the_url',
|
94
|
+
user: 'the_username@the_account',
|
95
|
+
password: 'the_password',
|
96
|
+
headers: { header: 'the_headers', 'Accept' => 'application/json' }}).
|
97
|
+
and_return(json)
|
98
|
+
|
99
|
+
expect(@api.list_providers).to eq(providers)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
context '#list_batches' do
|
105
|
+
|
106
|
+
it "should make the web service call and return the response as a hash" do
|
107
|
+
json = '[ { "id" : 1, "provider" : { "id" : 12, "name" : "Health" }, "filename" : "the_filename", "status" : "Verified", "statusDate" : "2013-10-01T00:00Z", "uploadDate" : "2013-10-01T01:00Z", "totalRecords" : 12 } ]'
|
108
|
+
batches = [
|
109
|
+
{ "id" => 1, "provider" => { "id" => 12, "name" => "Health" }, "filename" => 'the_filename', "status" => "Verified", "statusDate" => "2013-10-01T00:00Z", "uploadDate" => "2013-10-01T01:00Z", "totalRecords" => 12 }
|
110
|
+
]
|
111
|
+
|
112
|
+
@api.should_receive(:build_url).and_return('the_url')
|
113
|
+
@api.should_receive(:authentication_headers).and_return( { header: 'the_headers' } )
|
114
|
+
@api.should_receive(:account).and_return('the_account')
|
115
|
+
@api.should_receive(:password).and_return('the_password')
|
116
|
+
|
117
|
+
# RestClient.should_receive(:get).with('the_url', { header: 'the_headers', 'Accept' => 'application/json' }).and_return(json)
|
118
|
+
RestClient::Request.
|
119
|
+
should_receive(:execute).
|
120
|
+
with({ method: :get,
|
121
|
+
url: 'the_url',
|
122
|
+
user: "the_username@the_account",
|
123
|
+
password: "the_password",
|
124
|
+
headers: { header: 'the_headers', 'Accept' => 'application/json' } }).
|
125
|
+
and_return(json)
|
126
|
+
|
127
|
+
expect(@api.list_providers).to eq(batches)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'Private Methods' do
|
135
|
+
before(:each) do
|
136
|
+
@api = Services::SltcApi.new("https://api-test.simpleltc.com/v1",
|
137
|
+
"the_token",
|
138
|
+
"the_account",
|
139
|
+
"the_username",
|
140
|
+
"the_password")
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
context '#authentication_headers' do
|
145
|
+
|
146
|
+
it "should incorporate all the necessary headers for authentication" do
|
147
|
+
expect(@api.send(:authentication_headers)).to eq({
|
148
|
+
'SLTC-Api-Key' => 'the_token',
|
149
|
+
'Host' => 'api-test.simpleltc.com'
|
150
|
+
})
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context '#build_url' do
|
155
|
+
|
156
|
+
it "should return the url that has no parameters" do
|
157
|
+
expect(@api.send(:build_url, :MdsBatches)).
|
158
|
+
to eq("https://api-test.simpleltc.com/v1/MdsBatches")
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should return the url that has a string parameter" do
|
162
|
+
expect(@api.send(:build_url, :MdsBatches, 'value')).
|
163
|
+
to eq("https://api-test.simpleltc.com/v1/MdsBatches/value")
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should return the url that has multiple query parameters" do
|
167
|
+
expect(@api.send(:build_url, :MdsBatches, { a: 'aval', b: 'bval' })).
|
168
|
+
to eq("https://api-test.simpleltc.com/v1/MdsBatches?a=aval&b=bval")
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should return the url that has a single query parameter" do
|
172
|
+
expect(@api.send(:build_url, :MdsBatches, { a: 'aval' })).
|
173
|
+
to eq("https://api-test.simpleltc.com/v1/MdsBatches?a=aval")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should return the url that has an empty hash of query parameters" do
|
177
|
+
expect(@api.send(:build_url, :MdsBatches, {})).
|
178
|
+
to eq("https://api-test.simpleltc.com/v1/MdsBatches")
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should return the url that has a query parameter value that is a time" do
|
182
|
+
d = Time.now
|
183
|
+
dv = d.strftime("%Y-%m-%dT%H:%MZ")
|
184
|
+
expect(@api.send(:build_url, :MdsBatches, {d: d})).
|
185
|
+
to eq("https://api-test.simpleltc.com/v1/MdsBatches?d=#{dv}")
|
186
|
+
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|