Пример #1
0
 def test_state_view_with_504_not_stated(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_PROGRAM_504] = ['NS']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 2)
Пример #2
0
    def test_district_view(self):
        testParam = {}
        testParam[Constants.STATECODE] = 'NC'
        testParam[Constants.DISTRICTGUID] = '228'
        testParam[Constants.ASMTYEAR] = 2016
        results = get_comparing_populations_report(testParam)

        # check top-level attributes
        self.assertTrue(Constants.RECORDS in results, "returning JSON must have records")
        self.assertTrue(Constants.METADATA in results, "returning JSON must have colors")
        self.assertTrue(Constants.SUBJECTS in results, "returning JSON must have subjects")
        self.assertTrue('context' in results, "returning JSON must have context")
        self.assertTrue(Constants.SUMMARY in results, "returning JSON must have summary")

        # check school-level results
        records = results[Constants.RECORDS]
        self.assertEqual(3, len(records), "3 schools in the list")
        found_school = False
        for record in records:
            if record[Constants.ID] == '242':
                found_school = True
                self.assertEqual('Sunset - Eastern Elementary', record[Constants.NAME])
                asmt_results = record[Constants.RESULTS]
                self.assertEqual(2, len(asmt_results))
                subject1 = asmt_results[Constants.SUBJECT1]
                self.assertEqual(35, subject1[Constants.TOTAL])
                self.assertEqual(Constants.MATH, subject1[Constants.ASMT_SUBJECT])
                intervals = subject1[Constants.INTERVALS]
                self.assertEqual(4, len(intervals))
                self.assertEqual(1, intervals[0][Constants.LEVEL])
                self.assertEqual(14, intervals[0][Constants.PERCENTAGE])
                self.assertEqual(5, intervals[0][Constants.COUNT])
                break
        self.assertTrue(found_school, 'Did not find school in list')

        # check summary results
        summ_results = results[Constants.SUMMARY][0][Constants.RESULTS]
        self.assertEqual(2, len(summ_results))
        subject1 = summ_results[Constants.SUBJECT1]
        self.assertEqual(49, subject1[Constants.TOTAL])
        self.assertEqual(Constants.MATH, subject1[Constants.ASMT_SUBJECT])
        intervals = subject1[Constants.INTERVALS]
        self.assertEqual(4, len(intervals))
        self.assertEqual(1, intervals[0][Constants.LEVEL])
        self.assertEqual(16, intervals[0][Constants.PERCENTAGE])
        self.assertEqual(8, intervals[0][Constants.COUNT])

        # check subjects
        self.assertEqual(Constants.MATH, results[Constants.SUBJECTS][Constants.SUBJECT1])
        self.assertEqual(Constants.ELA, results[Constants.SUBJECTS][Constants.SUBJECT2])

        # check context
        context_items = results['context']['items']
        self.assertEqual(3, len(context_items))
        self.assertEqual('North Carolina', context_items[1][Constants.NAME])
        self.assertEqual('Sunset School District', context_items[2][Constants.NAME])

        # check colors
        self.assertTrue('text_color' in results[Constants.METADATA][Constants.SUBJECT1][Constants.COLORS][0])
        self.assertTrue('bg_color' in results[Constants.METADATA][Constants.SUBJECT1][Constants.COLORS][0])
 def test_state_view_with_504_not_stated(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_PROGRAM_504] = ['NS']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 2)
Пример #4
0
 def test_state_view_with_504_no(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.ASMTYEAR] = 2015
     testParam[filters.FILTERS_PROGRAM_504] = ['N']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 4)
     self.assertEqual(results['records'][1]['results']['subject1']['total'], 97)
     self.assertEqual(results['records'][1]['results']['subject2']['total'], 66)
Пример #5
0
 def test_view_with_lep_multi(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '0513ba44-e8ec-4186-9a0e-8481e9c16206'
     testParam[filters.FILTERS_PROGRAM_LEP] = ['N', 'Y', 'NS']
     testParam[Constants.ASMTYEAR] = 2015
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 4)
     self.assertEqual(results['records'][1]['results']['subject1']['total'], 55)
Пример #6
0
 def test_comparing_populations_ethnicity_two_or_more(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '228'
     testParam[Constants.SCHOOLGUID] = '248'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_ETHNICITY] = [filters.FILTERS_ETHNICITY_MULTI]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 0)
Пример #7
0
 def test_comparing_populations_with_sex_not_stated(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '229'
     testParam[filters.FILTERS_SEX] = [filters.FILTERS_SEX_NOT_STATED]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 1)
     self.assertEqual(results['records'][0]['results']['subject1']['total'], -1)
     self.assertEqual(results['records'][0]['results']['subject2']['total'], 0)
Пример #8
0
 def test_district_view_with_grades(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '229'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_GRADE] = ['03']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(results['records'][0]['results']['subject1']['total'], 0)
     self.assertEqual(len(results['records']), 1)
Пример #9
0
 def test_state_view_with_iep_yes(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_PROGRAM_IEP] = ['Y']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 3)
     self.assertEqual(results['records'][0]['results']['subject1']['total'], 4)
     self.assertEqual(results['records'][1]['results']['subject2']['total'], -1)
Пример #10
0
 def test_comparing_populations_ethnicity_hispanic(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '228'
     testParam[Constants.SCHOOLGUID] = '248'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_ETHNICITY] = [filters.FILTERS_ETHNICITY_HISPANIC]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 1)
     self.assertEqual(results['records'][0]['results']['subject1']['total'], -1)
 def test_district_view_with_grades(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '229'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_GRADE] = ['03']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(results['records'][0]['results']['subject1']['total'],
                      0)
     self.assertEqual(len(results['records']), 1)
 def test_state_view_with_iep_yes(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_PROGRAM_IEP] = ['Y']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 3)
     self.assertEqual(results['records'][0]['results']['subject1']['total'],
                      4)
     self.assertEqual(results['records'][1]['results']['subject2']['total'],
                      -1)
 def test_state_view_with_504_no(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.ASMTYEAR] = 2015
     testParam[filters.FILTERS_PROGRAM_504] = ['N']
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 4)
     self.assertEqual(results['records'][1]['results']['subject1']['total'],
                      97)
     self.assertEqual(results['records'][1]['results']['subject2']['total'],
                      66)
 def test_view_with_lep_multi(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[
         Constants.DISTRICTGUID] = '0513ba44-e8ec-4186-9a0e-8481e9c16206'
     testParam[filters.FILTERS_PROGRAM_LEP] = ['N', 'Y', 'NS']
     testParam[Constants.ASMTYEAR] = 2015
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 4)
     self.assertEqual(results['records'][1]['results']['subject1']['total'],
                      55)
 def test_comparing_populations_with_sex_not_stated(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '229'
     testParam[filters.FILTERS_SEX] = [filters.FILTERS_SEX_NOT_STATED]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 1)
     self.assertEqual(results['records'][0]['results']['subject1']['total'],
                      -1)
     self.assertEqual(results['records'][0]['results']['subject2']['total'],
                      0)
Пример #16
0
 def test_comparing_populations_ethnicity_two_or_more(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '228'
     testParam[Constants.SCHOOLGUID] = '248'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_ETHNICITY] = [
         filters.FILTERS_ETHNICITY_MULTI
     ]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 0)
Пример #17
0
 def test_comparing_populations_with_sex(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '229'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_SEX] = [filters.FILTERS_SEX_MALE]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 2)
     self.assertEqual(results['records'][0]['results']['subject1']['total'], -1)
     self.assertEqual(results['records'][0]['results']['subject2']['total'], 5)
     self.assertEqual(results['records'][1]['results']['subject1']['total'], -1)
     self.assertEqual(results['records'][1]['results']['subject2']['total'], 0)
Пример #18
0
    def test_comparing_populations_with_not_stated_count(self):
        testParam = {}
        testParam[Constants.STATECODE] = 'NC'
        testParam[Constants.DISTRICTGUID] = '229'
        results = get_comparing_populations_report(testParam)

        self.assertEqual(results['not_stated']['total'], 29)
        self.assertEqual(results['not_stated']['dmgPrg504'], 2)
        self.assertEqual(results['not_stated']['dmgPrgIep'], 2)
        self.assertEqual(results['not_stated']['dmgPrgLep'], 0)
        self.assertEqual(results['not_stated']['dmgStsMig'], 1)
        self.assertEqual(results['not_stated']['ethnicity'], 0)
        self.assertEqual(results['not_stated']['sex'], 1)
Пример #19
0
 def test_comparing_populations_ethnicity_hispanic(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '228'
     testParam[Constants.SCHOOLGUID] = '248'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_ETHNICITY] = [
         filters.FILTERS_ETHNICITY_HISPANIC
     ]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 1)
     self.assertEqual(results['records'][0]['results']['subject1']['total'],
                      -1)
    def test_comparing_populations_with_not_stated_count(self):
        testParam = {}
        testParam[Constants.STATECODE] = 'NC'
        testParam[Constants.DISTRICTGUID] = '229'
        results = get_comparing_populations_report(testParam)

        self.assertEqual(results['not_stated']['total'], 29)
        self.assertEqual(results['not_stated']['dmgPrg504'], 2)
        self.assertEqual(results['not_stated']['dmgPrgIep'], 2)
        self.assertEqual(results['not_stated']['dmgPrgLep'], 0)
        self.assertEqual(results['not_stated']['dmgStsMig'], 1)
        self.assertEqual(results['not_stated']['ethnicity'], 0)
        self.assertEqual(results['not_stated']['sex'], 1)
 def test_comparing_populations_with_sex(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '229'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_SEX] = [filters.FILTERS_SEX_MALE]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 2)
     self.assertEqual(results['records'][0]['results']['subject1']['total'],
                      -1)
     self.assertEqual(results['records'][0]['results']['subject2']['total'],
                      5)
     self.assertEqual(results['records'][1]['results']['subject1']['total'],
                      -1)
     self.assertEqual(results['records'][1]['results']['subject2']['total'],
                      0)
Пример #22
0
 def test_comparing_populations_ethnicity_all(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '228'
     testParam[Constants.SCHOOLGUID] = '248'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_ETHNICITY] = [filters.FILTERS_ETHNICITY_AMERICAN,
                                             filters.FILTERS_ETHNICITY_ASIAN,
                                             filters.FILTERS_ETHNICITY_BLACK,
                                             filters.FILTERS_ETHNICITY_HISPANIC,
                                             filters.FILTERS_ETHNICITY_PACIFIC,
                                             filters.FILTERS_ETHNICITY_NOT_STATED,
                                             filters.FILTERS_ETHNICITY_WHITE,
                                             filters.FILTERS_ETHNICITY_MULTI]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 2)
     self.assertEqual(results['records'][0]['results']['subject1']['total'], 3)
     self.assertEqual(results['records'][0]['results']['subject2']['total'], -1)
Пример #23
0
 def test_comparing_populations_ethnicity_all(self):
     testParam = {}
     testParam[Constants.STATECODE] = 'NC'
     testParam[Constants.DISTRICTGUID] = '228'
     testParam[Constants.SCHOOLGUID] = '248'
     testParam[Constants.ASMTYEAR] = 2016
     testParam[filters.FILTERS_ETHNICITY] = [
         filters.FILTERS_ETHNICITY_AMERICAN,
         filters.FILTERS_ETHNICITY_ASIAN, filters.FILTERS_ETHNICITY_BLACK,
         filters.FILTERS_ETHNICITY_HISPANIC,
         filters.FILTERS_ETHNICITY_PACIFIC,
         filters.FILTERS_ETHNICITY_NOT_STATED,
         filters.FILTERS_ETHNICITY_WHITE, filters.FILTERS_ETHNICITY_MULTI
     ]
     results = get_comparing_populations_report(testParam)
     self.assertEqual(len(results['records']), 2)
     self.assertEqual(results['records'][0]['results']['subject1']['total'],
                      3)
     self.assertEqual(results['records'][0]['results']['subject2']['total'],
                      -1)
    def test_state_view(self):
        testParam = {}
        testParam[Constants.STATECODE] = 'NC'
        testParam[Constants.ASMTYEAR] = 2016
        results = get_comparing_populations_report(testParam)

        # check top-level attributes
        self.assertTrue(Constants.RECORDS in results,
                        "returning JSON must have records")
        self.assertTrue(Constants.METADATA in results,
                        "returning JSON must have colors")
        self.assertTrue(Constants.SUBJECTS in results,
                        "returning JSON must have subjects")
        self.assertTrue('context' in results,
                        "returning JSON must have context")
        self.assertTrue(Constants.SUMMARY in results,
                        "returning JSON must have summary")

        # check district-level results
        records = results[Constants.RECORDS]
        self.assertEqual(5, len(records), "4 districts in the list")
        found_district = False
        for record in records:
            if record[Constants.ID] == '228':
                found_district = True
                self.assertEqual('Sunset School District',
                                 record[Constants.NAME])
                asmt_results = record[Constants.RESULTS]
                self.assertEqual(2, len(asmt_results))
                subject1 = asmt_results[Constants.SUBJECT1]
                self.assertEqual(49, subject1[Constants.TOTAL])
                self.assertEqual(Constants.MATH,
                                 subject1[Constants.ASMT_SUBJECT])
                intervals = subject1[Constants.INTERVALS]
                self.assertEqual(4, len(intervals))
                self.assertEqual(1, intervals[0][Constants.LEVEL])
                self.assertEqual(16, intervals[0][Constants.PERCENTAGE])
                self.assertEqual(8, intervals[0][Constants.COUNT])
                break
        self.assertTrue(found_district, 'Did not find district in list')

        # check summary results
        summ_results = results[Constants.SUMMARY][0][Constants.RESULTS]
        self.assertEqual(2, len(summ_results))
        subject1 = summ_results[Constants.SUBJECT1]
        self.assertEqual(89, subject1[Constants.TOTAL])
        self.assertEqual(Constants.MATH, subject1[Constants.ASMT_SUBJECT])
        intervals = subject1[Constants.INTERVALS]
        self.assertEqual(4, len(intervals))
        self.assertEqual(1, intervals[0][Constants.LEVEL])
        self.assertEqual(11, intervals[0][Constants.PERCENTAGE])
        self.assertEqual(10, intervals[0][Constants.COUNT])

        # check subjects
        self.assertEqual(Constants.MATH,
                         results[Constants.SUBJECTS][Constants.SUBJECT1])
        self.assertEqual(Constants.ELA,
                         results[Constants.SUBJECTS][Constants.SUBJECT2])

        # check context
        context_items = results['context']['items']
        self.assertEqual(2, len(context_items))
        self.assertEqual('North Carolina', context_items[1][Constants.NAME])

        # check colors
        self.assertEqual(
            len(results[Constants.METADATA][Constants.SUBJECT1][
                Constants.COLORS]), 4)
        self.assertTrue('text_color' in results[Constants.METADATA][
            Constants.SUBJECT1][Constants.COLORS][0])
        self.assertTrue('bg_color' in results[Constants.METADATA][
            Constants.SUBJECT1][Constants.COLORS][0])
Пример #25
0
 def test_invalid_params(self):
     params = {Constants.STATECODE: 'AA'}
     results = get_comparing_populations_report(params)
     self.assertIsInstance(results, HTTPForbidden)
    def test_school_view(self):
        testParam = {}
        testParam[Constants.STATECODE] = 'NC'
        testParam[Constants.DISTRICTGUID] = '228'
        testParam[Constants.ASMTYEAR] = 2016
        testParam[Constants.SCHOOLGUID] = '242'
        results = get_comparing_populations_report(testParam)

        # check top-level attributes
        self.assertTrue(Constants.RECORDS in results,
                        "returning JSON must have records")
        self.assertTrue(Constants.METADATA in results,
                        "returning JSON must have colors")
        self.assertTrue(Constants.SUBJECTS in results,
                        "returning JSON must have subjects")
        self.assertTrue('context' in results,
                        "returning JSON must have context")
        self.assertTrue(Constants.SUMMARY in results,
                        "returning JSON must have summary")

        # check grade-level results
        records = results[Constants.RECORDS]
        self.assertEqual(2, len(records), "2 grades in the list")
        self.assertEqual('03', records[0][Constants.ID])
        self.assertEqual('03', records[0][Constants.NAME])
        asmt_results = records[0][Constants.RESULTS]
        self.assertEqual(2, len(asmt_results))
        subject1 = asmt_results[Constants.SUBJECT1]
        self.assertEqual(21, subject1[Constants.TOTAL])
        self.assertEqual(Constants.MATH, subject1[Constants.ASMT_SUBJECT])
        intervals = subject1[Constants.INTERVALS]
        self.assertEqual(4, len(intervals))
        self.assertEqual(1, intervals[0][Constants.LEVEL])
        self.assertEqual(10, intervals[0][Constants.PERCENTAGE])
        self.assertEqual(2, intervals[0][Constants.COUNT])

        # check summary results
        summ_results = results[Constants.SUMMARY][0][Constants.RESULTS]
        self.assertEqual(2, len(summ_results))
        subject1 = summ_results[Constants.SUBJECT1]
        self.assertEqual(35, subject1[Constants.TOTAL])
        self.assertEqual(Constants.MATH, subject1[Constants.ASMT_SUBJECT])
        intervals = subject1[Constants.INTERVALS]
        self.assertEqual(4, len(intervals))
        self.assertEqual(1, intervals[0][Constants.LEVEL])
        self.assertEqual(14, intervals[0][Constants.PERCENTAGE])
        self.assertEqual(5, intervals[0][Constants.COUNT])

        # check subjects
        self.assertEqual(Constants.MATH,
                         results[Constants.SUBJECTS][Constants.SUBJECT1])
        self.assertEqual(Constants.ELA,
                         results[Constants.SUBJECTS][Constants.SUBJECT2])

        # check context
        context_items = results['context']['items']
        self.assertEqual(4, len(context_items))
        self.assertEqual('Home', context_items[0][Constants.NAME])
        self.assertEqual('North Carolina', context_items[1][Constants.NAME])
        self.assertEqual('Sunset School District',
                         context_items[2][Constants.NAME])
        self.assertEqual('Sunset - Eastern Elementary',
                         context_items[3][Constants.NAME])

        # check colors
        self.assertTrue('text_color' in results[Constants.METADATA][
            Constants.SUBJECT1][Constants.COLORS][0])
        self.assertTrue('bg_color' in results[Constants.METADATA][
            Constants.SUBJECT1][Constants.COLORS][0])
 def test_invalid_params(self):
     params = {Constants.STATECODE: 'AA'}
     results = get_comparing_populations_report(params)
     self.assertIsInstance(results, HTTPForbidden)