From 5d9586a127e3ee733760c788b5c5535501fcaac6 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Tue, 10 May 2022 17:05:36 +0100 Subject: [PATCH] Map joint tenancy field (#565) --- .../imports/case_logs_import_service.rb | 1 + .../00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml | 510 ++++++++++++++++++ .../imports/case_logs_import_service_spec.rb | 16 +- 3 files changed, 522 insertions(+), 5 deletions(-) create mode 100644 spec/fixtures/softwire_imports/case_logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 56ccbd8d8..123cacc93 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -49,6 +49,7 @@ module Imports attributes["startdate"] = compose_date(xml_doc, "DAY", "MONTH", "YEAR") attributes["owning_organisation_id"] = find_organisation_id(xml_doc, "OWNINGORGID", "OWNINGORGNAME", "HCNUM") attributes["managing_organisation_id"] = find_organisation_id(xml_doc, "MANINGORGID", "MANINGORGNAME", "MANHCNUM") + attributes["joint"] = unsafe_string_as_integer(xml_doc, "joint") attributes["startertenancy"] = unsafe_string_as_integer(xml_doc, "_2a") attributes["tenancy"] = unsafe_string_as_integer(xml_doc, "Q2b") attributes["tenancyother"] = string_or_nil(xml_doc, "Q2ba") diff --git a/spec/fixtures/softwire_imports/case_logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml b/spec/fixtures/softwire_imports/case_logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml new file mode 100644 index 000000000..f5a5c87e4 --- /dev/null +++ b/spec/fixtures/softwire_imports/case_logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml @@ -0,0 +1,510 @@ + + + 2022-CORE-SR-GN + 00d2343e-d5fa-4c89-8400-ec3854b0f2b4 + c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa + 35459cb12d312a472d8585b97b865917e8f2144e + 35459cb12d312a472d8585b97b865917e8f2144e + 2022-04-14T16:01:30.369241Z + 2022-04-14T16:01:30.369241Z + submitted-valid + 2022 + Manual Entry + + + + + Yes + + + 2022-04-14 +
5985624
+ 1 Private Registered Provider + <_2bTenCode>600009258 + +
+
+ + 52 + + Female + 10) Person prefers not to say + 1 White: English/Scottish/Welsh/Northern Irish/British + 18 United Kingdom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 Don’t Know + 6 Don’t Know + 19 To move to independent accommodation + + 28 Living with friends or family + 1 No + SR2 8SW + + Sunderland + E08000024 + 3 Don’t know + + + + + + 1 Yes + 2 No + 2 No + + 2 Tenant applied direct (no referral or nomination) + + + + + 2 No + + + + + 2 No + + + + + + + + Yes + 3 Tenant prefers not to say + + + + + + + + + + + + + + + + + 2 No + <_2a>1 Yes + 2 Assured – lifetime + + <_2cYears/> + + + SR8 3HF + Durham + E06000047 + + + 15 First let of newbuild property + 1 + + 7 House + 1 Purpose built + 2 No + 2 + 2022-04-14 + + + + 3 Don’t know + Refused + + + 3 Don’t know + 4 Don’t Know + 7 Weekly for 48 weeks + 106.00 + + + + 106.00 + + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 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 + 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 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 52 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 52 + 0 + 52 + 2022-04-14Z + 2022-04-29Z + + + + + + + + + + + + + 0 + 0 + 0 + 0 + 0 + 20 + 20 + C + 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 + 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 + 1 New Tenant + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 3 = 1 adult + + + 3 + + + 1 Private Registered Provider + + + E12000001 + 107178 + Believe Housing Ltd. + Believe Housing Ltd. + 8076 + 8076 + + 107178 + + + 3 + + + + + + + + + + 13 + + + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 97.85 + 97.85 + + + + 0.00 + + + + 97.85 + 97.85 + + + + 0 + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 84.15 + 0 + + 0 + 77 + 5 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 14 + 4 + 2022 + 14 + 4 + 2022 + + + + SR2 + 8SW + + + + diff --git a/spec/services/imports/case_logs_import_service_spec.rb b/spec/services/imports/case_logs_import_service_spec.rb index d02c60aee..82f05472c 100644 --- a/spec/services/imports/case_logs_import_service_spec.rb +++ b/spec/services/imports/case_logs_import_service_spec.rb @@ -5,8 +5,10 @@ RSpec.describe Imports::CaseLogsImportService do 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_id3) { "00d2343e-d5fa-4c89-8400-ec3854b0f2b4" } let(:storage_service) { instance_double(StorageService) } let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json", "2021_2022") } + let(:real_2022_2023_form) { Form.new("config/forms/2022_2023.json", "2022_2023") } let(:logger) { instance_double(ActiveSupport::Logger) } context "when importing users" do @@ -19,15 +21,19 @@ RSpec.describe Imports::CaseLogsImportService do before do # Stub the S3 file listing and download allow(storage_service).to receive(:list_files) - .and_return(%W[#{remote_folder}/#{case_log_id}.xml #{remote_folder}/#{case_log_id2}.xml]) + .and_return(%W[#{remote_folder}/#{case_log_id}.xml #{remote_folder}/#{case_log_id2}.xml #{remote_folder}/#{case_log_id3}.xml]) allow(storage_service).to receive(:get_file_io) .with("#{remote_folder}/#{case_log_id}.xml") .and_return(open_file(fixture_directory, case_log_id), open_file(fixture_directory, case_log_id)) allow(storage_service).to receive(:get_file_io) .with("#{remote_folder}/#{case_log_id2}.xml") .and_return(open_file(fixture_directory, case_log_id2), open_file(fixture_directory, case_log_id2)) + allow(storage_service).to receive(:get_file_io) + .with("#{remote_folder}/#{case_log_id3}.xml") + .and_return(open_file(fixture_directory, case_log_id3), open_file(fixture_directory, case_log_id3)) # Stub the form handler to use the real form - allow(FormHandler.instance).to receive(:get_form).with(anything).and_return(real_2021_2022_form) + allow(FormHandler.instance).to receive(:get_form).with("2021_2022").and_return(real_2021_2022_form) + allow(FormHandler.instance).to receive(:get_form).with("2022_2023").and_return(real_2022_2023_form) WebMock.stub_request(:get, /api.postcodes.io\/postcodes\/LS166FT/) .to_return(status: 200, body: '{"status":200,"result":{"codes":{"admin_district":"E08000035"}}}', headers: {}) @@ -41,15 +47,15 @@ RSpec.describe Imports::CaseLogsImportService do expect(logger).not_to receive(:warn) expect(logger).not_to receive(:info) expect { case_log_service.create_logs(remote_folder) } - .to change(CaseLog, :count).by(2) + .to change(CaseLog, :count).by(3) end it "only updates existing case logs" do expect(logger).not_to receive(:error) expect(logger).not_to receive(:warn) - expect(logger).to receive(:info).with(/Updating case log/).twice + expect(logger).to receive(:info).with(/Updating case log/).exactly(3).times expect { 2.times { case_log_service.create_logs(remote_folder) } } - .to change(CaseLog, :count).by(2) + .to change(CaseLog, :count).by(3) end end end