From 0c476447a4d8bc712a63a649009db70bdb9ef1d0 Mon Sep 17 00:00:00 2001 From: Dushan Despotovic Date: Fri, 27 May 2022 09:34:33 +0100 Subject: [PATCH] add test and code for logging old id of status discrepancies --- .../imports/case_logs_import_service.rb | 1 + .../893ufj2s-lq77-42m4-rty6-ej09gh585uy1.xml | 514 ++++++++++++++++++ .../imports/case_logs_import_service_spec.rb | 21 + 3 files changed, 536 insertions(+) create mode 100644 spec/fixtures/softwire_imports/case_logs/893ufj2s-lq77-42m4-rty6-ej09gh585uy1.xml diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 0b74e2fc5..787f94aba 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -226,6 +226,7 @@ module Imports def check_status_completed(case_log, previous_status) if previous_status.include?("submitted") && case_log.status != "completed" @logger.warn "Case log #{case_log.id} is not completed" + @logger.warn "Case log with old id:#{case_log.old_id} is incomplete but status should be complete" end end diff --git a/spec/fixtures/softwire_imports/case_logs/893ufj2s-lq77-42m4-rty6-ej09gh585uy1.xml b/spec/fixtures/softwire_imports/case_logs/893ufj2s-lq77-42m4-rty6-ej09gh585uy1.xml new file mode 100644 index 000000000..f01bb1baa --- /dev/null +++ b/spec/fixtures/softwire_imports/case_logs/893ufj2s-lq77-42m4-rty6-ej09gh585uy1.xml @@ -0,0 +1,514 @@ + + + 2021-CORE-IR-GN + 893ufj2s-lq77-42m4-rty6-ej09gh585uy1 + e29c492473446dca4d50224f2bb7cf965a261d6f + 7c5bd5fb549c09a2c55d7cb90d7ba84927e64618 + 7c5bd5fb549c09a2c55d7cb90d7ba84927e64618 + 2022-04-11T13:46:23.953121Z + 2022-04-11T13:46:23.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 + + + 7 UC – without housing element (not in receipt of HB and tenants not eligible for housing support e.g. residential care home) + + + 3 None + + + + + + 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 + + + + 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 + 1 + DLUHC + DLUHC + 655 + 655 + + 1 + + + + + + + + + + + + + 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 d30939021..0016bb145 100644 --- a/spec/services/imports/case_logs_import_service_spec.rb +++ b/spec/services/imports/case_logs_import_service_spec.rb @@ -66,6 +66,25 @@ RSpec.describe Imports::CaseLogsImportService do expect { 2.times { case_log_service.create_logs(remote_folder) } } .to change(CaseLog, :count).by(3) end + + context "when there are status discrepancies" do + let(:case_log_id4) { "893ufj2s-lq77-42m4-rty6-ej09gh585uy1" } + let(:case_log_file) { open_file(fixture_directory, case_log_id4) } + let(:case_log_xml) { Nokogiri::XML(case_log_file) } + + before do + allow(storage_service).to receive(:get_file_io) + .with("#{remote_folder}/#{case_log_id4}.xml") + .and_return(open_file(fixture_directory, case_log_id4), open_file(fixture_directory, case_log_id4)) + end + + it "the logger logs a warning with the case log's old id/filename" do + expect(logger).to receive(:warn).with(/is not completed/).exactly(1).times + expect(logger).to receive(:warn).with(/Case log with old id:#{case_log_id4} is incomplete but status should be complete/).exactly(1).times + + case_log_service.send(:create_log, case_log_xml) + end + end end context "when importing a specific log" do @@ -78,6 +97,8 @@ RSpec.describe Imports::CaseLogsImportService do it "does not import the voiddate" do allow(logger).to receive(:warn).with(/is not completed/) + allow(logger).to receive(:warn).with(/Case log with old id:#{case_log_id} is incomplete but status should be complete/) + case_log_service.send(:create_log, case_log_xml) case_log = CaseLog.where(old_id: case_log_id).first