diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 8082db605..741536f61 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -672,6 +672,23 @@ private socprevten: %i[field_102], mortgageused: %i[field_105 field_119 field_128], soctenant: %i[field_99], + + uprn: %i[field_19], + address_line1: %i[field_20], + address_line2: %i[field_21], + town_or_city: %i[field_22], + county: %i[field_23], + + ethnic_group2: %i[field_40], + ethnicbuy2: %i[field_40], + nationalbuy2: %i[field_41], + + buy2living: %i[field_71], + prevtenbuy2: %i[field_72], + + prevshared: %i[field_85], + + staircasesale: %i[field_90], } end diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index 48a6dab8b..ecbd457fb 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -156,6 +156,25 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=100023336956") .to_return(status: 200, body:, headers: {}) + body = { + header: { + uri: "https://api.os.uk/search/places/v1/uprn?uprn=2", + query: "uprn=2", + offset: 0, + totalresults: 0, + format: "JSON", + dataset: "DPA", + lr: "EN,CY", + maxresults: 100, + epoch: "101", + lastupdate: "2023-05-11", + output_srs: "EPSG:27700", + }, + }.to_json + + stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=2") + .to_return(status: 200, body:, headers: {}) + parser.valid? end @@ -533,7 +552,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do end describe "#field_19" do # UPRN - context "when UPRN known" do + context "when UPRN known and lookup found" do let(:attributes) { setup_section_params.merge({ field_19: "100023336956" }) } it "is valid" do @@ -562,6 +581,14 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do expect(parser.errors[:field_19]).to be_present end end + + context "when UPRN entered but no lookup found" do + let(:attributes) { setup_section_params.merge({ field_19: "2" }) } + + it "is not valid" do + expect(parser.errors[:field_19]).to be_present + end + end end [