fix: no longer support 'form' in filename when cleaning. Only look for 'part X' and add that to the filename if it exists

rpp-main
Nelson Jovel 2 years ago
parent d907e2742e
commit cc8ed48204

@ -40,7 +40,7 @@ class Cleaner
row.school.name row.school.name
end.to_set end.to_set
part = filepath&.match(/[\b\s_.]+(part|form)[\W*_](?<label>[\w\d])/i)&.named_captures&.[]("label")&.upcase part = filepath&.match(/[\b\s_.]+(part)[\W*_](?<label>[\w\d])/i)&.named_captures&.[]("label")&.upcase
school_name = schools.first.parameterize school_name = schools.first.parameterize

@ -218,47 +218,11 @@ RSpec.describe Cleaner do
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:, data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:,
schools: School.school_hash)] schools: School.school_hash)]
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename( filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: early_education_survey_items, data:, filepath: "/data/survey_responses/maynard early ed_ form a.2022-23.csv" headers: early_education_survey_items, data:, filepath: "/data/survey_responses/maynard early ed_ part a.2022-23.csv"
) )
expect(filename).to eq "maynard.maynard-high-school.early_education.Part-A.2022-23.csv" expect(filename).to eq "maynard.maynard-high-school.early_education.Part-A.2022-23.csv"
end end
end end
context "when the file name includes the words 'form'" do
it "adds the part to the filename" do
survey_items = SurveyItem.where(survey_item_id: early_education_survey_items)
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:,
schools: School.school_hash)]
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: early_education_survey_items, data:, filepath: "/data/survey_responses/maynard early ed_ form f.2022-23.csv"
)
expect(filename).to eq "maynard.maynard-high-school.early_education.Part-F.2022-23.csv"
end
end
context "when the file name includes the words 'form'" do
it "adds the part to the filename" do
survey_items = SurveyItem.where(survey_item_id: early_education_survey_items)
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:,
schools: School.school_hash)]
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: early_education_survey_items, data:, filepath: "/data/survey_responses/maynard early ed_ form_f.2022-23.csv"
)
expect(filename).to eq "maynard.maynard-high-school.early_education.Part-F.2022-23.csv"
end
end
context "when the file name includes the words 'form'" do
it "adds the part to the filename" do
survey_items = SurveyItem.where(survey_item_id: early_education_survey_items)
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: early_education_survey_items, survey_items:,
schools: School.school_hash)]
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: early_education_survey_items, data:, filepath: "/data/survey_responses/maynard early ed_ form&f.2022-23.csv"
)
expect(filename).to eq "maynard.maynard-high-school.early_education.Part-F.2022-23.csv"
end
end
end end
end end
end end

Loading…
Cancel
Save