Browse Source

CLDC-4173: add sales csv export tests for 26 including buildheightclass

pull/3186/head
Nat Dean-Lewis 3 months ago
parent
commit
05ac936124
  1. 3
      spec/fixtures/files/sales_logs_csv_export_codes_26.csv
  2. 3
      spec/fixtures/files/sales_logs_csv_export_labels_26.csv
  3. 88
      spec/services/csv/sales_log_csv_service_spec.rb

3
spec/fixtures/files/sales_logs_csv_export_codes_26.csv vendored

@ -0,0 +1,3 @@
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,created_at,updated_at,collection_start_year,creation_method,bulk_upload_id,is_dpo,day,month,year,purchid,ownershipsch,type,staircase,jointpur,jointmore,noint,privacynotice,uprn,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,proptype,buildheightclass,beds,builtype,wchair,age1,sexrab1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sexrab2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sexrab3,sex3,ecstat3,relat4,age4,sexrab4,sex4,ecstat4,relat5,age5,sexrab5,sex5,ecstat5,relat6,age6,sexrab6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,resale,proplen,hoday,homonth,hoyear,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortlen,deposit,cashdis,mrent,stairbought,stairowned,staircasesale,firststair,numstair,lasttransaction,initialpurchase,mrentprestaircasing
132,in_progress,,2026-05-01T00:00:00+01:00,2026-05-01T00:00:00+01:00,2026,1,,true,1,5,2026,,2,8,,1,1,2,1,1,"1, Test Street",,Test Town,,,,E09000033,Westminster,1,2,2,1,1,30,F,X,17,17,,1,1,P,35,F,X,17,,,1,1,3,X,14,M,X,9,X,-9,M,X,3,R,-9,R,R,10,,,,,,1,1,,,0,,,3,,1,4,5,1,1,0,13400,1,0,13400,1,4,1,,1,2,,10,,,,,,,110000.0,,1,20000.0,10,80000.0,,,,,,,,,,
1
2 id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo day month year purchid ownershipsch type staircase jointpur jointmore noint privacynotice uprn address_line1 address_line2 town_or_city county pcode1 pcode2 la la_label proptype buildheightclass beds builtype wchair age1 sexrab1 sex1 ethnic_group ethnic nationality_all ecstat1 buy1livein relat2 age2 sexrab2 sex2 ethnic_group2 ethnicbuy2 nationality_all_buyer2 ecstat2 buy2livein hholdcount relat3 age3 sexrab3 sex3 ecstat3 relat4 age4 sexrab4 sex4 ecstat4 relat5 age5 sexrab5 sex5 ecstat5 relat6 age6 sexrab6 sex6 ecstat6 prevten ppcodenk ppostc1 ppostc2 previous_la_known prevloc prevloc_label buy2living prevtenbuy2 hhregres hhregresstill armedforcesspouse disabled wheel income1nk income1 inc1mort income2nk income2 inc2mort hb savingsnk savings prevown prevshared resale proplen hoday homonth hoyear frombeds fromprop socprevten value equity mortgageused mortgage mortlen deposit cashdis mrent stairbought stairowned staircasesale firststair numstair lasttransaction initialpurchase mrentprestaircasing
3 132 in_progress 2026-05-01T00:00:00+01:00 2026-05-01T00:00:00+01:00 2026 1 true 1 5 2026 2 8 1 1 2 1 1 1, Test Street Test Town E09000033 Westminster 1 2 2 1 1 30 F X 17 17 1 1 P 35 F X 17 1 1 3 X 14 M X 9 X -9 M X 3 R -9 R R 10 1 1 0 3 1 4 5 1 1 0 13400 1 0 13400 1 4 1 1 2 10 110000.0 1 20000.0 10 80000.0

3
spec/fixtures/files/sales_logs_csv_export_labels_26.csv vendored

@ -0,0 +1,3 @@
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,created_at,updated_at,collection_start_year,creation_method,bulk_upload_id,is_dpo,day,month,year,purchid,ownershipsch,type,staircase,jointpur,jointmore,noint,privacynotice,uprn,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,proptype,buildheightclass,beds,builtype,wchair,age1,sexrab1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sexrab2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sexrab3,sex3,ecstat3,relat4,age4,sexrab4,sex4,ecstat4,relat5,age5,sexrab5,sex5,ecstat5,relat6,age6,sexrab6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,resale,proplen,hoday,homonth,hoyear,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortlen,deposit,cashdis,mrent,stairbought,stairowned,staircasesale,firststair,numstair,lasttransaction,initialpurchase,mrentprestaircasing
132,in_progress,,2026-05-01T00:00:00+01:00,2026-05-01T00:00:00+01:00,2026,single log,,true,1,5,2026,,Discounted Ownership,Right to Acquire (RTA),,Yes,Yes,Yes,1,1,"1, Test Street",,Test Town,,,,E09000033,Westminster,Flat or maisonette,Low-rise,2,Purpose built,Yes,30,Female,Non-binary,Buyer prefers not to say,17,,Full-time – 30 hours or more per week,Yes,Yes,35,Female,Non-binary,Buyer prefers not to say,,,Full-time – 30 hours or more per week,Yes,3,No,14,Male,Non-binary,Child under 16,No,Not known,Male,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Prefers not to say,,,,,,Local authority tenant,No,,,No,,,Don’t know,,Yes,Yes,No,Yes,Yes,Yes,13400,Yes,Yes,13400,Yes,Don’t know ,No,,Yes,No,,10,,,,,,,110000.0,,Yes,20000.0,10,80000.0,,,,,,,,,,
1
2 id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo day month year purchid ownershipsch type staircase jointpur jointmore noint privacynotice uprn address_line1 address_line2 town_or_city county pcode1 pcode2 la la_label proptype buildheightclass beds builtype wchair age1 sexrab1 sex1 ethnic_group ethnic nationality_all ecstat1 buy1livein relat2 age2 sexrab2 sex2 ethnic_group2 ethnicbuy2 nationality_all_buyer2 ecstat2 buy2livein hholdcount relat3 age3 sexrab3 sex3 ecstat3 relat4 age4 sexrab4 sex4 ecstat4 relat5 age5 sexrab5 sex5 ecstat5 relat6 age6 sexrab6 sex6 ecstat6 prevten ppcodenk ppostc1 ppostc2 previous_la_known prevloc prevloc_label buy2living prevtenbuy2 hhregres hhregresstill armedforcesspouse disabled wheel income1nk income1 inc1mort income2nk income2 inc2mort hb savingsnk savings prevown prevshared resale proplen hoday homonth hoyear frombeds fromprop socprevten value equity mortgageused mortgage mortlen deposit cashdis mrent stairbought stairowned staircasesale firststair numstair lasttransaction initialpurchase mrentprestaircasing
3 132 in_progress 2026-05-01T00:00:00+01:00 2026-05-01T00:00:00+01:00 2026 single log true 1 5 2026 Discounted Ownership Right to Acquire (RTA) Yes Yes Yes 1 1 1, Test Street Test Town E09000033 Westminster Flat or maisonette Low-rise 2 Purpose built Yes 30 Female Non-binary Buyer prefers not to say 17 Full-time – 30 hours or more per week Yes Yes 35 Female Non-binary Buyer prefers not to say Full-time – 30 hours or more per week Yes 3 No 14 Male Non-binary Child under 16 No Not known Male Non-binary In government training into work Prefers not to say Not known Prefers not to say Prefers not to say Prefers not to say Local authority tenant No No Don’t know Yes Yes No Yes Yes Yes 13400 Yes Yes 13400 Yes Don’t know No Yes No 10 110000.0 Yes 20000.0 10 80000.0

88
spec/services/csv/sales_log_csv_service_spec.rb

@ -193,6 +193,21 @@ RSpec.describe Csv::SalesLogCsvService do
expect(la_label_value).to eq "Westminster"
end
context "when the requested form is 2023" do
let(:now) { Time.zone.local(2024, 1, 1) }
let(:year) { 2023 }
it "exports the CSV with the 2023 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_23.csv")
values_to_delete = %w[ID]
values_to_delete.each do |attribute|
index = attribute_line.index(attribute)
content_line[index] = nil
end
expect(csv).to eq expected_content
end
end
context "when the requested form is 2024" do
let(:now) { Time.zone.local(2024, 5, 1) }
let(:year) { 2024 }
@ -233,18 +248,23 @@ RSpec.describe Csv::SalesLogCsvService do
end
end
context "when the requested form is 2023" do
let(:now) { Time.zone.local(2024, 1, 1) }
let(:year) { 2023 }
context "when the requested form is 2026" do
let(:now) { Time.zone.local(2026, 5, 1) }
let(:year) { 2026 }
let(:fixed_time) { Time.zone.local(2026, 5, 1) }
it "exports the CSV with the 2023 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_23.csv")
values_to_delete = %w[ID]
before do
log.update!(nationality_all: 36, manual_address_entry_selected: false, uprn: "1", uprn_known: 1, buildheightclass: 2)
end
it "exports the CSV with the 2026 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_26.csv")
values_to_delete = %w[ID OWNINGORGID MANINGORGID CREATEDBYID USERNAMEID AMENDEDBYID]
values_to_delete.each do |attribute|
index = attribute_line.index(attribute)
content_line[index] = nil
end
expect(csv).to eq expected_content
expect(csv[1..]).to eq expected_content[1..] # Skip the first line as it contains the definitions
end
end
@ -301,23 +321,18 @@ RSpec.describe Csv::SalesLogCsvService do
expect(la_label_value).to eq "Westminster"
end
context "when the requested form is 2025" do
let(:now) { Time.zone.local(2025, 5, 1) }
let(:fixed_time) { Time.zone.local(2025, 5, 1) }
let(:year) { 2025 }
before do
log.update!(manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
end
context "when the requested form is 2023" do
let(:now) { Time.zone.local(2024, 1, 1) }
let(:year) { 2023 }
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_25.csv")
values_to_delete = %w[ID OWNINGORGID MANINGORGID CREATEDBYID USERNAMEID AMENDEDBYID]
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_23.csv")
values_to_delete = %w[ID]
values_to_delete.each do |attribute|
index = attribute_line.index(attribute)
content_line[index] = nil
end
expect(csv[1..]).to eq expected_content[1..] # Skip the first line as it contains the definitions
expect(csv).to eq expected_content
end
end
@ -341,18 +356,43 @@ RSpec.describe Csv::SalesLogCsvService do
end
end
context "when the requested form is 2023" do
let(:now) { Time.zone.local(2024, 1, 1) }
let(:year) { 2023 }
context "when the requested form is 2025" do
let(:now) { Time.zone.local(2025, 5, 1) }
let(:fixed_time) { Time.zone.local(2025, 5, 1) }
let(:year) { 2025 }
before do
log.update!(manual_address_entry_selected: false, uprn: "1", uprn_known: 1)
end
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_23.csv")
values_to_delete = %w[ID]
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_25.csv")
values_to_delete = %w[ID OWNINGORGID MANINGORGID CREATEDBYID USERNAMEID AMENDEDBYID]
values_to_delete.each do |attribute|
index = attribute_line.index(attribute)
content_line[index] = nil
end
expect(csv).to eq expected_content
expect(csv[1..]).to eq expected_content[1..] # Skip the first line as it contains the definitions
end
end
context "when the requested form is 2026" do
let(:now) { Time.zone.local(2026, 5, 1) }
let(:fixed_time) { Time.zone.local(2026, 5, 1) }
let(:year) { 2026 }
before do
log.update!(manual_address_entry_selected: false, uprn: "1", uprn_known: 1, buildheightclass: 2)
end
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_26.csv")
values_to_delete = %w[ID OWNINGORGID MANINGORGID CREATEDBYID USERNAMEID AMENDEDBYID]
values_to_delete.each do |attribute|
index = attribute_line.index(attribute)
content_line[index] = nil
end
expect(csv[1..]).to eq expected_content[1..] # Skip the first line as it contains the definitions
end
end

Loading…
Cancel
Save