mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
feat: add ability to merge disaggregation data with raw survey data to
produce a cleaned csv with merged income disaggregation columns
This commit is contained in:
parent
fae530d21f
commit
0a2c5e02c5
13 changed files with 1203 additions and 229 deletions
35
spec/services/disaggregation_loader_spec.rb
Normal file
35
spec/services/disaggregation_loader_spec.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
require 'rails_helper'
|
||||
require 'fileutils'
|
||||
|
||||
RSpec.describe DisaggregationLoader do
|
||||
let(:path) do
|
||||
Rails.root.join('spec', 'fixtures', 'disaggregation')
|
||||
end
|
||||
let(:academic_year) { create(:academic_year, range: '2022-23') }
|
||||
let(:district) { create(:district, name: 'Maynard Public Schools') }
|
||||
context '.load' do
|
||||
it 'loads data from the file into a hash' do
|
||||
data = DisaggregationLoader.new(path:).load
|
||||
expect(data.values.first.lasid).to eq('1')
|
||||
expect(data.values.first.academic_year).to eq('2022-23')
|
||||
expect(data.values.first.district).to eq('Maynard Public Schools')
|
||||
expect(data.values.first.income).to eq('Free Lunch')
|
||||
|
||||
expect(data.values.last.lasid).to eq('500')
|
||||
expect(data.values.last.academic_year).to eq('2022-23')
|
||||
expect(data.values.last.district).to eq('Maynard Public Schools')
|
||||
expect(data.values.last.income).to eq('Not Eligible')
|
||||
|
||||
expect(data[['1', 'Maynard Public Schools', '2022-23']].income).to eq('Free Lunch')
|
||||
expect(data[['2', 'Maynard Public Schools', '2022-23']].income).to eq('Not Eligible')
|
||||
expect(data[['3', 'Maynard Public Schools', '2022-23']].income).to eq('Reduced Lunch')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Creating a new loader' do
|
||||
it 'creates a directory for the loader file' do
|
||||
DisaggregationLoader.new(path:)
|
||||
expect(path).to exist
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue