mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-10 16:00:33 -07:00
turn off three b one scraper spec
This commit is contained in:
parent
7dbb025357
commit
677cee83e4
1 changed files with 40 additions and 40 deletions
|
|
@ -1,12 +1,12 @@
|
|||
require 'rails_helper'
|
||||
require 'fileutils'
|
||||
require 'csv'
|
||||
require "rails_helper"
|
||||
require "fileutils"
|
||||
require "csv"
|
||||
|
||||
RSpec.describe Dese::ThreeBOne do
|
||||
let(:academic_years) do
|
||||
[
|
||||
create(:academic_year, range: '2021-22'),
|
||||
create(:academic_year, range: '2020-21')
|
||||
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'),
|
||||
|
|
@ -14,95 +14,95 @@ RSpec.describe Dese::ThreeBOne do
|
|||
]
|
||||
end
|
||||
|
||||
let(:i1_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_masscore.csv') }
|
||||
let(:i2_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_advcoursecomprate.csv') }
|
||||
let(:i3_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_ap.csv') }
|
||||
let(:i4_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_student_courses_ratio.csv') }
|
||||
let(:i1_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_masscore.csv") }
|
||||
let(:i2_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_advcoursecomprate.csv") }
|
||||
let(:i3_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_ap.csv") }
|
||||
let(:i4_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_student_courses_ratio.csv") }
|
||||
|
||||
let(:filepaths) do
|
||||
[i1_filepath, i2_filepath, i3_filepath, i4_filepath]
|
||||
end
|
||||
before do
|
||||
FileUtils.mkdir_p 'tmp/spec/dese'
|
||||
FileUtils.mkdir_p "tmp/spec/dese"
|
||||
end
|
||||
|
||||
before :each do
|
||||
academic_years
|
||||
end
|
||||
|
||||
context 'a-curv-i5' do
|
||||
it 'creates a csv file with the scraped data' do
|
||||
xcontext "a-curv-i5" do
|
||||
it "creates a csv file with the scraped data" do
|
||||
Dese::ThreeBOne.new(filepaths:).run_all
|
||||
expect(i4_filepath).to exist
|
||||
end
|
||||
end
|
||||
|
||||
xcontext 'Creating a new Scraper' do
|
||||
it 'creates a csv file with the scraped data' do
|
||||
xcontext "Creating a new Scraper" do
|
||||
it "creates a csv file with the scraped data" do
|
||||
Dese::ThreeBOne.new(filepaths:).run_all
|
||||
expect(i1_filepath).to exist
|
||||
expect(i2_filepath).to exist
|
||||
expect(i3_filepath).to exist
|
||||
end
|
||||
|
||||
it 'has the correct headers for a-curv-i1' do
|
||||
it "has the correct headers for a-curv-i1" do
|
||||
headers = File.open(i1_filepath) do |file|
|
||||
headers = file.first
|
||||
end.split(',')
|
||||
end.split(",")
|
||||
|
||||
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
||||
'# Graduated', '# Completed MassCore', "% Completed MassCore\n"]
|
||||
expect(headers).to eq ["Raw likert calculation", "Likert Score", "Admin Data Item", "Academic Year", "School Name", "DESE ID",
|
||||
"# Graduated", "# Completed MassCore", "% Completed MassCore\n"]
|
||||
end
|
||||
it 'has the correct headers for a-curv-i2' do
|
||||
it "has the correct headers for a-curv-i2" do
|
||||
headers = File.open(i2_filepath) do |file|
|
||||
headers = file.first
|
||||
end.split(',')
|
||||
end.split(",")
|
||||
|
||||
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
||||
'# Grade 11 and 12 Students', '# Students Completing Advanced', '% Students Completing Advanced',
|
||||
'% ELA', '% Math', '% Science and Technology', '% Computer and Information Science',
|
||||
'% History and Social Sciences', '% Arts', '% All Other Subjects', "% All Other Subjects\n"]
|
||||
expect(headers).to eq ["Raw likert calculation", "Likert Score", "Admin Data Item", "Academic Year", "School Name", "DESE ID",
|
||||
"# Grade 11 and 12 Students", "# Students Completing Advanced", "% Students Completing Advanced",
|
||||
"% ELA", "% Math", "% Science and Technology", "% Computer and Information Science",
|
||||
"% History and Social Sciences", "% Arts", "% All Other Subjects", "% All Other Subjects\n"]
|
||||
end
|
||||
|
||||
it 'has the correct headers for a-curv-i3' do
|
||||
it "has the correct headers for a-curv-i3" do
|
||||
headers = File.open(i3_filepath) do |file|
|
||||
headers = file.first
|
||||
end.split(',')
|
||||
end.split(",")
|
||||
|
||||
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
||||
'Tests Taken', 'Score=1', 'Score=2', 'Score=3', 'Score=4', 'Score=5', '% Score 1-2', "% Score 3-5\n"]
|
||||
expect(headers).to eq ["Raw likert calculation", "Likert Score", "Admin Data Item", "Academic Year", "School Name", "DESE ID",
|
||||
"Tests Taken", "Score=1", "Score=2", "Score=3", "Score=4", "Score=5", "% Score 1-2", "% Score 3-5\n"]
|
||||
end
|
||||
|
||||
it 'has the right likert score results for a-curv-i1' do
|
||||
it "has the right likert score results for a-curv-i1" do
|
||||
results = CSV.parse(File.read(i1_filepath), headers: true).map do |row|
|
||||
next unless row['Admin Data Item'] == 'a-curv-i1' && row['Academic Year'] == '2020-21'
|
||||
next unless row["Admin Data Item"] == "a-curv-i1" && row["Academic Year"] == "2020-21"
|
||||
|
||||
row['Likert Score'].to_f
|
||||
row["Likert Score"].to_f
|
||||
end.flatten.compact
|
||||
|
||||
expect(results.take(20)).to eq [4.44, 4.44, 3.33, 3.83, 4.44, 3.6, 4.44, 4.44, 1, 4.44, 4.44, 4.44, 4.44, 3.89,
|
||||
4.44, 4.44, 4.44, 4.44, 4.01, 3.92]
|
||||
4.44, 4.44, 4.44, 4.44, 4.01, 3.92]
|
||||
end
|
||||
|
||||
it 'has the right likert score results for a-curv-i2' do
|
||||
it "has the right likert score results for a-curv-i2" do
|
||||
results = CSV.parse(File.read(i2_filepath), headers: true).map do |row|
|
||||
next unless row['Admin Data Item'] == 'a-curv-i2' && row['Academic Year'] == '2020-21'
|
||||
next unless row["Admin Data Item"] == "a-curv-i2" && row["Academic Year"] == "2020-21"
|
||||
|
||||
row['Likert Score'].to_f
|
||||
row["Likert Score"].to_f
|
||||
end.flatten.compact
|
||||
|
||||
expect(results.take(20)).to eq [5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 1.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
|
||||
5.0, 2.53, 5.0, 5.0]
|
||||
5.0, 2.53, 5.0, 5.0]
|
||||
end
|
||||
it 'has the right likert score results for a-curv-i3' do
|
||||
it "has the right likert score results for a-curv-i3" do
|
||||
results = CSV.parse(File.read(i3_filepath), headers: true).map do |row|
|
||||
next unless row['Admin Data Item'] == 'a-curv-i3' && row['Academic Year'] == '2020-21'
|
||||
next unless row["Admin Data Item"] == "a-curv-i3" && row["Academic Year"] == "2020-21"
|
||||
|
||||
row['Likert Score'].to_f
|
||||
row["Likert Score"].to_f
|
||||
end.flatten.compact
|
||||
|
||||
expect(results.take(20)).to eq [5.0, 1.46, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 2.06, 3.54, 5.0,
|
||||
5.0, 5.0, 5.0, 5.0, 1.0]
|
||||
5.0, 5.0, 5.0, 5.0, 1.0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue