mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
Add 2A-i admin data. Finishes #183105627
This commit is contained in:
parent
459393381b
commit
b5bc9c9de4
4 changed files with 18662 additions and 0 deletions
66
spec/services/dese/two_a_one_scraper_spec.rb
Normal file
66
spec/services/dese/two_a_one_scraper_spec.rb
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
require 'rails_helper'
|
||||
require 'fileutils'
|
||||
require 'csv'
|
||||
|
||||
RSpec.describe Dese::TwoAOneScraper do
|
||||
let(:academic_years) do
|
||||
[
|
||||
create(:academic_year, range: '2021-22'),
|
||||
create(:academic_year, range: '2020-21'),
|
||||
create(:academic_year, range: '2019-20'),
|
||||
create(:academic_year, range: '2018-19'),
|
||||
create(:academic_year, range: '2017-18'),
|
||||
create(:academic_year, range: '2016-17')
|
||||
]
|
||||
end
|
||||
|
||||
let(:i1_filepath) { Rails.root.join('tmp', 'spec', 'dese', 'two_a_one_students_suspended.csv') }
|
||||
let(:i3_filepath) { Rails.root.join('tmp', 'spec', 'dese', 'two_a_one_students_disciplined.csv') }
|
||||
|
||||
let(:filepaths) do
|
||||
[i1_filepath, i3_filepath]
|
||||
end
|
||||
before do
|
||||
FileUtils.mkdir_p 'tmp/spec/dese'
|
||||
end
|
||||
|
||||
before :each do
|
||||
academic_years
|
||||
end
|
||||
|
||||
context 'Creating a new Scraper' do
|
||||
it 'creates a csv file with the scraped data' do
|
||||
Dese::TwoAOneScraper.new(filepaths:)
|
||||
expect(i1_filepath).to exist
|
||||
end
|
||||
|
||||
it 'has the correct headers' do
|
||||
headers = File.open(i1_filepath) do |file|
|
||||
headers = file.first
|
||||
end.split(',')
|
||||
|
||||
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
||||
'Students', 'Students Disciplined',
|
||||
'% In-School Suspension', '% Out-of-School Suspension', '% Expulsion', '% Removed to Alternate Setting',
|
||||
'% Emergency Removal', '% Students with a School-Based Arrest', "% Students with a Law Enforcement Referral\n"]
|
||||
end
|
||||
|
||||
it 'has the right likert score results for a-phys-i1' do
|
||||
results = CSV.parse(File.read(i1_filepath), headers: true).map do |row|
|
||||
row['Likert Score'].to_f
|
||||
end
|
||||
|
||||
expect(results.take(20)).to eq [5.0, 5.0, 4.33, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
|
||||
5.0, 5.0, 5.0, 5.0]
|
||||
end
|
||||
it 'has the right likert score results for a-exp-i3' do
|
||||
results = CSV.parse(File.read(i3_filepath), headers: true).map do |row|
|
||||
next unless row['Admin Data Item'] == 'a-phys-i3' && row['Academic Year'] == '2020-21'
|
||||
|
||||
row['Likert Score'].to_f
|
||||
end.flatten.compact
|
||||
|
||||
expect(results.take(20)).to eq [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue