From f382dd77499fa9b2632e6c07f03f669e0cc974eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Wed, 20 Apr 2022 17:07:58 +0100 Subject: [PATCH] Fix irproduct mapping --- .../imports/case_logs_import_service.rb | 6 +- db/schema.rb | 2 +- .../166fc004-392e-47a8-acb8-1c018734882b.xml | 514 ++++++++++++++++++ .../imports/case_logs_import_service_spec.rb | 7 +- 4 files changed, 525 insertions(+), 4 deletions(-) create mode 100644 spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 1f91bd35e..d94c2c5e5 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -53,8 +53,8 @@ module Imports attributes["tenancylength"] = safe_string_as_integer(xml_doc, "_2cYears") attributes["needstype"] = needs_type(xml_doc) attributes["lar"] = london_affordable_rent(xml_doc) - attributes["irproduct"] = unsafe_string_as_integer(xml_doc, "IRPRODUCT") - attributes["irproduct_other"] = string_or_nil(xml_doc, "IRPRODUCTOTHER") + attributes["irproduct"] = unsafe_string_as_integer(xml_doc, "IRProduct") + attributes["irproduct_other"] = string_or_nil(xml_doc, "IRProductOther") attributes["rent_type"] = rent_type(xml_doc, attributes["lar"], attributes["irproduct"]) attributes["hhmemb"] = safe_string_as_integer(xml_doc, "HHMEMB") (1..8).each do |index| @@ -150,6 +150,8 @@ module Imports attributes["updated_at"] = Date.parse(field_value(xml_doc, "meta", "modified-date")) case_log = CaseLog.new(attributes) + pp attributes + pp case_log.send(:mandatory_fields) case_log.save! end diff --git a/db/schema.rb b/db/schema.rb index c06c0e7e4..8a8103a23 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -305,12 +305,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_04_11_092231) do t.string "last_sign_in_ip" t.integer "role" t.string "old_user_id" - t.string "phone" t.integer "failed_attempts", default: 0 t.string "unlock_token" t.datetime "locked_at", precision: nil t.boolean "is_dpo", default: false t.boolean "is_key_contact", default: false + t.string "phone" t.integer "second_factor_attempts_count", default: 0 t.string "encrypted_otp_secret_key" t.string "encrypted_otp_secret_key_iv" diff --git a/spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml b/spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml new file mode 100644 index 000000000..e119e81ce --- /dev/null +++ b/spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml @@ -0,0 +1,514 @@ + + + 2021-CORE-IR-GN + 166fc004-392e-47a8-acb8-1c018734882b + e29c492473446dca4d50224f2bb7cf965a261d6f + 26139d1be7a44ebb1af23d3f8882c14025e9903c + 26139d1be7a44ebb1af23d3f8882c14025e9903c + 2022-04-12T14:10:59.953121Z + 2022-04-12T14:10:59.953121Z + submitted-valid + 2021 + Manual Entry + + + + + Yes + 2 London Living Rent + + 2021-11-10 +
300072
+ 1 Private Registered Provider + + <_1btenagree>1 This Landlord + <_1bifanother/> + <_1bCOREcode/> + +
+ + <_2a>2 No + 2 Assured + + <_2bTenCode>TEN0021 + <_2cYears/> + + + 37 + + Female + 1) Full Time + 1 White: English/Scottish/Welsh/Northern Irish/British + 1 UK national resident in UK + 34 + + Female + Other + 1) Full Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 No + + + 2 No + + + 9 Not in receipt of either UC or HB + + + 3 None + + 200.00 + 1 Weekly + + + 8 (Non-violent) relationship breakdown with partner + + + + <_9b override-field="">2 No + + + + + Yes + + 1 Yes + + + + Yes + + + + + + + 28 Living with friends or family + Blackpool + E09000009 + FY1 1JD + + 1 Just moved to Local Authority area + 1 Just moved to Local Authority area + + + 1 Not homeless + 2 No + + + + + + + + 2 No + 2 No + 2 No + + + 10 Other social landlord + + + + 1 Weekly for 52 weeks + 100.00 + + + + 100.00 + + + 2021-04-15 + + 0 + PROPREF0042 + + + 2 + 1 Flat / maisonette + 1 Purpose built + 2 No + 4 An Intermediate Rent basis + 10 Relet - tenant evicted due to arrears + + + Basingstoke & Deane + E07000084 + RG21 3HU + + + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + <_100>0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + <_70>0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 37 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 37 + 0 + 37 + 2022-04-12Z + 2022-04-27Z + + + + + + + + + + + + + 0 + 0 + 0 + 0 + 20 + 0 + 20 + C + 1 + 1 + 1 + 1 + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 2 + 2 Existing Tenant + 1 + 1 + 209 + 2 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 = 2 adults + 200.00 + 200.00 + 13 + + 200.00 + 1 Private Registered Provider + + + E12000008 + 107138 + 1 Test + 1 Test + 655 + 655 + + 107138 + + + + + + + + + + + + + 13 + + + 13 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 100.00 + 100.00 + + + + 0.00 + + + + 100.00 + 100.00 + + + + 0 + + + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 100.00 + 23.35 + + 0 + 0 + 0 + + + 0 + 0 + 23.35 + 0 + 0 + 0 + 0 + 0 + 0 + 10 + 11 + 2021 + 15 + 4 + 2021 + + + + FY1 + 1JD + + + +
diff --git a/spec/services/imports/case_logs_import_service_spec.rb b/spec/services/imports/case_logs_import_service_spec.rb index 7af288654..55b6cadca 100644 --- a/spec/services/imports/case_logs_import_service_spec.rb +++ b/spec/services/imports/case_logs_import_service_spec.rb @@ -4,7 +4,9 @@ RSpec.describe Imports::CaseLogsImportService do let(:remote_folder) { "case_logs" } let(:fixture_directory) { "spec/fixtures/softwire_imports/case_logs" } let(:case_log_id) { "0ead17cb-1668-442d-898c-0d52879ff592" } + let(:case_log_id2) { "166fc004-392e-47a8-acb8-1c018734882b" } let(:case_log_file) { File.open("#{fixture_directory}/#{case_log_id}.xml") } + let(:case_log_file2) { File.open("#{fixture_directory}/#{case_log_id2}.xml") } let(:storage_service) { instance_double(StorageService) } let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json", "2021_2022") } @@ -14,10 +16,13 @@ RSpec.describe Imports::CaseLogsImportService do before do # Stub the S3 file listing and download allow(storage_service).to receive(:list_files) - .and_return(["#{remote_folder}/#{case_log_id}.xml"]) + .and_return(%W[#{remote_folder}/#{case_log_id}.xml #{remote_folder}/#{case_log_id2}.xml]) allow(storage_service).to receive(:get_file_io) .with("#{remote_folder}/#{case_log_id}.xml") .and_return(case_log_file) + allow(storage_service).to receive(:get_file_io) + .with("#{remote_folder}/#{case_log_id2}.xml") + .and_return(case_log_file2) # Stub the form handler to use the real form allow(FormHandler.instance).to receive(:get_form).with(anything).and_return(real_2021_2022_form) end