diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 787f94aba..553ddb553 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -2,6 +2,9 @@ module Imports class CaseLogsImportService < ImportService def create_logs(folder) import_from(folder, :create_log) + if @logs_with_discrepancies.count > 0 + @logger.warn("The following case logs had status discrepancies: [#{@logs_with_discrepancies.join(", ")}]") + end end private @@ -226,7 +229,8 @@ 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" + @logger.warn "Case log with old id:#{case_log.old_id} is incomplete but status should be complete" + @logs_with_discrepancies << case_log.old_id end end diff --git a/app/services/imports/import_service.rb b/app/services/imports/import_service.rb index 664790055..e45498004 100644 --- a/app/services/imports/import_service.rb +++ b/app/services/imports/import_service.rb @@ -5,6 +5,7 @@ module Imports def initialize(storage_service, logger = Rails.logger) @storage_service = storage_service @logger = logger + @logs_with_discrepancies = [] end def import_from(folder, create_method) diff --git a/spec/fixtures/softwire_imports/case_logs/5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd.xml b/spec/fixtures/softwire_imports/case_logs/5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd.xml new file mode 100644 index 000000000..2531314dd --- /dev/null +++ b/spec/fixtures/softwire_imports/case_logs/5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd.xml @@ -0,0 +1,514 @@ + + + 2021-CORE-IR-GN + 5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd + 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 0016bb145..04df07418 100644 --- a/spec/services/imports/case_logs_import_service_spec.rb +++ b/spec/services/imports/case_logs_import_service_spec.rb @@ -69,6 +69,7 @@ RSpec.describe Imports::CaseLogsImportService do context "when there are status discrepancies" do let(:case_log_id4) { "893ufj2s-lq77-42m4-rty6-ej09gh585uy1" } + let(:case_log_id5) { "5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd" } let(:case_log_file) { open_file(fixture_directory, case_log_id4) } let(:case_log_xml) { Nokogiri::XML(case_log_file) } @@ -76,6 +77,9 @@ RSpec.describe Imports::CaseLogsImportService 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)) + allow(storage_service).to receive(:get_file_io) + .with("#{remote_folder}/#{case_log_id5}.xml") + .and_return(open_file(fixture_directory, case_log_id5), open_file(fixture_directory, case_log_id5)) end it "the logger logs a warning with the case log's old id/filename" do @@ -84,6 +88,16 @@ RSpec.describe Imports::CaseLogsImportService do case_log_service.send(:create_log, case_log_xml) end + + it "on completion the ids of all logs with status discrepancies are logged in a warning" do + allow(storage_service).to receive(:list_files) + .and_return(%W[#{remote_folder}/#{case_log_id4}.xml #{remote_folder}/#{case_log_id5}.xml]) + allow(logger).to receive(:warn).with(/is not completed/) + allow(logger).to receive(:warn).with(/is incomplete but status should be complete/) + expect(logger).to receive(:warn).with(/The following case logs had status discrepancies: \[893ufj2s-lq77-42m4-rty6-ej09gh585uy1, 5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd\]/).exactly(1).times + + case_log_service.create_logs(remote_folder) + end end end