mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-13 01:10:39 -07:00
import students
This commit is contained in:
parent
8c7767d0b9
commit
12e4e3f177
28 changed files with 11093 additions and 10843 deletions
74
spec/services/student_loader_spec.rb
Normal file
74
spec/services/student_loader_spec.rb
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe StudentLoader do
|
||||
let(:path_to_student_responses) { Rails.root.join('spec', 'fixtures', 'test_2020-21_student_survey_responses.csv') }
|
||||
let(:american_indian) { Race.find_by_qualtrics_code(1) }
|
||||
let(:asian) { Race.find_by_qualtrics_code(2) }
|
||||
let(:black) { Race.find_by_qualtrics_code(3) }
|
||||
let(:latinx) { Race.find_by_qualtrics_code(4) }
|
||||
let(:white) { Race.find_by_qualtrics_code(5) }
|
||||
let(:middle_eastern) { Race.find_by_qualtrics_code(8) }
|
||||
let(:unknown) { Race.find_by_qualtrics_code(99) }
|
||||
|
||||
before :each do
|
||||
Rails.application.load_seed
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
describe '#process_races' do
|
||||
context 'as a standalone function' do
|
||||
it 'race codes of 6 or 7 get classified as an unknown race' do
|
||||
codes = [6]
|
||||
expect(StudentLoader.process_races(codes:)).to eq Set[unknown]
|
||||
codes = [7]
|
||||
expect(StudentLoader.process_races(codes:)).to eq Set[unknown]
|
||||
codes = [6, 7]
|
||||
expect(StudentLoader.process_races(codes:)).to eq Set[unknown]
|
||||
codes = [1, 6, 7]
|
||||
expect(StudentLoader.process_races(codes:)).to eq Set[american_indian]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'self.load_data' do
|
||||
context 'student survey responses' do
|
||||
before :each do
|
||||
SurveyResponsesDataLoader.load_data filepath: path_to_student_responses
|
||||
StudentLoader.load_data filepath: path_to_student_responses
|
||||
end
|
||||
|
||||
it 'ensures student responses load correctly' do
|
||||
assigns_student_to_the_survey_item_responses
|
||||
assigns_races_to_students
|
||||
is_idempotent_for_students
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def assigns_student_to_the_survey_item_responses
|
||||
expect(SurveyItemResponse.find_by_response_id('student_survey_response_1').student).not_to eq nil
|
||||
expect(SurveyItemResponse.find_by_response_id('student_survey_response_1').student).to eq Student.find_by_lasid('123456')
|
||||
expect(SurveyItemResponse.find_by_response_id('student_survey_response_6').student).not_to eq nil
|
||||
expect(SurveyItemResponse.find_by_response_id('student_survey_response_6').student).to eq Student.find_by_response_id('student_survey_response_6')
|
||||
end
|
||||
|
||||
def assigns_races_to_students
|
||||
expect(Student.find_by_response_id('student_survey_response_1').races).to eq [american_indian]
|
||||
expect(Student.find_by_response_id('student_survey_response_2').races).to eq [asian, black, latinx]
|
||||
expect(Student.find_by_response_id('student_survey_response_3').races).to eq [unknown]
|
||||
expect(Student.find_by_response_id('student_survey_response_4').races).to eq [unknown]
|
||||
expect(Student.find_by_response_id('student_survey_response_5').races).to eq [american_indian, asian, black, latinx, white,
|
||||
middle_eastern]
|
||||
expect(Student.find_by_response_id('student_survey_response_6').races).to eq [american_indian, asian, black, latinx, white,
|
||||
middle_eastern]
|
||||
expect(Student.find_by_response_id('student_survey_response_7').races).to eq [unknown]
|
||||
end
|
||||
|
||||
def is_idempotent_for_students
|
||||
number_of_students = Student.count
|
||||
StudentLoader.load_data filepath: path_to_student_responses
|
||||
expect(Student.count).to eq number_of_students
|
||||
end
|
||||
|
|
@ -132,8 +132,8 @@ def loads_student_survey_item_response_values
|
|||
end
|
||||
|
||||
def student_survey_item_response_count_matches_expected
|
||||
expect(SurveyItemResponse.where(survey_item: s_phys_q1).count).to eq 3
|
||||
expect(SurveyItemResponse.where(survey_item: s_phys_q2).count).to eq 3
|
||||
expect(SurveyItemResponse.where(survey_item: s_phys_q1).count).to eq 5
|
||||
expect(SurveyItemResponse.where(survey_item: s_phys_q2).count).to eq 5
|
||||
end
|
||||
|
||||
def captures_likert_scores_for_student_survey_item_responses
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue