def test_parse_evaluation_page_missing_dnf(self):
        response = fake_response_from_file(self.evaluation_did_not_follow_missing)
        response.meta["course"] = CourseItem(evaluations=[], code="11124")
        response.meta["counter"] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item["evaluations"][0]

        self.assertEqual(u"2008", evaluation["year"])
        self.assertEqual(u"Winter", evaluation["semester"])
        self.assertEqual(u"24", evaluation["could_answer"])
        self.assertEqual(u"15", evaluation["have_answered"])
        self.assertEqual(u"0", evaluation["did_not_follow"])

        self.assertEqual(u"0", evaluation["performance_much_less"])
        self.assertEqual(u"0", evaluation["performance_less"])
        self.assertEqual(u"11", evaluation["performance_same"])
        self.assertEqual(u"4", evaluation["performance_more"])
        self.assertEqual(u"0", evaluation["performance_much_more"])

        self.assertEqual(u"0", evaluation["prereq_too_low"])
        self.assertEqual(u"2", evaluation["prereq_low"])
        self.assertEqual(u"10", evaluation["prereq_adequate"])
        self.assertEqual(u"2", evaluation["prereq_high"])
        self.assertEqual(u"0", evaluation["prereq_too_high"])
    def test_parse_evaluation_3_week_jun(self):
        response = fake_response_from_file(self.evaluation_3_week_course_jun)
        response.meta["course"] = CourseItem(evaluations=[], code="11837")
        response.meta["counter"] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item["evaluations"][0]

        self.assertEqual(u"2013", evaluation["year"])
        self.assertEqual(u"June", evaluation["semester"])
        self.assertEqual(u"17", evaluation["could_answer"])
        self.assertEqual(u"0", evaluation["have_answered"])
        self.assertEqual(u"0", evaluation["did_not_follow"])

        self.assertEqual(u"0", evaluation["performance_much_less"])
        self.assertEqual(u"0", evaluation["performance_less"])
        self.assertEqual(u"0", evaluation["performance_same"])
        self.assertEqual(u"0", evaluation["performance_more"])
        self.assertEqual(u"0", evaluation["performance_much_more"])

        self.assertEqual(u"0", evaluation["prereq_too_low"])
        self.assertEqual(u"0", evaluation["prereq_low"])
        self.assertEqual(u"0", evaluation["prereq_adequate"])
        self.assertEqual(u"0", evaluation["prereq_high"])
        self.assertEqual(u"0", evaluation["prereq_too_high"])
Exemple #3
0
    def test_parse_evaluation_page(self):
        response = fake_response_from_file(self.course_27002_evaluation_page)
        response.meta['course'] = CourseItem(evaluations = [], code = '27002')
        response.meta['counter'] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item['evaluations'][0]

        self.assertEqual(u'2011', evaluation['year'])
        self.assertEqual(u'Summer', evaluation['semester'])
        self.assertEqual(u'80', evaluation['could_answer'])
        self.assertEqual(u'40', evaluation['have_answered'])
        self.assertEqual(u'6', evaluation['did_not_follow'])

        self.assertEqual(u'5', evaluation['performance_much_less'])
        self.assertEqual(u'9', evaluation['performance_less'])
        self.assertEqual(u'26', evaluation['performance_same'])
        self.assertEqual(u'0', evaluation['performance_more'])
        self.assertEqual(u'0', evaluation['performance_much_more'])

        self.assertEqual(u'0', evaluation['prereq_too_low'])
        self.assertEqual(u'2', evaluation['prereq_low'])
        self.assertEqual(u'36', evaluation['prereq_adequate'])
        self.assertEqual(u'1', evaluation['prereq_high'])
        self.assertEqual(u'1', evaluation['prereq_too_high'])
    def test_parse_evaluation_page(self):
        response = fake_response_from_file(self.course_27002_evaluation_page)
        response.meta["course"] = CourseItem(evaluations=[], code="27002")
        response.meta["counter"] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item["evaluations"][0]

        self.assertEqual(u"2011", evaluation["year"])
        self.assertEqual(u"Summer", evaluation["semester"])
        self.assertEqual(u"80", evaluation["could_answer"])
        self.assertEqual(u"40", evaluation["have_answered"])
        self.assertEqual(u"6", evaluation["did_not_follow"])

        self.assertEqual(u"5", evaluation["performance_much_less"])
        self.assertEqual(u"9", evaluation["performance_less"])
        self.assertEqual(u"26", evaluation["performance_same"])
        self.assertEqual(u"0", evaluation["performance_more"])
        self.assertEqual(u"0", evaluation["performance_much_more"])

        self.assertEqual(u"0", evaluation["prereq_too_low"])
        self.assertEqual(u"2", evaluation["prereq_low"])
        self.assertEqual(u"36", evaluation["prereq_adequate"])
        self.assertEqual(u"1", evaluation["prereq_high"])
        self.assertEqual(u"1", evaluation["prereq_too_high"])
Exemple #5
0
    def test_parse_evaluation_page_missing_dnf(self):
        response = fake_response_from_file(self.evaluation_did_not_follow_missing)
        response.meta['course'] = CourseItem(evaluations = [], code = '11124')
        response.meta['counter'] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item['evaluations'][0]

        self.assertEqual(u'2008', evaluation['year'])
        self.assertEqual(u'Winter', evaluation['semester'])
        self.assertEqual(u'24', evaluation['could_answer'])
        self.assertEqual(u'15', evaluation['have_answered'])
        self.assertEqual(u'0', evaluation['did_not_follow'])

        self.assertEqual(u'0', evaluation['performance_much_less'])
        self.assertEqual(u'0', evaluation['performance_less'])
        self.assertEqual(u'11', evaluation['performance_same'])
        self.assertEqual(u'4', evaluation['performance_more'])
        self.assertEqual(u'0', evaluation['performance_much_more'])

        self.assertEqual(u'0', evaluation['prereq_too_low'])
        self.assertEqual(u'2', evaluation['prereq_low'])
        self.assertEqual(u'10', evaluation['prereq_adequate'])
        self.assertEqual(u'2', evaluation['prereq_high'])
        self.assertEqual(u'0', evaluation['prereq_too_high'])
Exemple #6
0
    def test_parse_evaluation_3_week_jun(self):
        response = fake_response_from_file(self.evaluation_3_week_course_jun)
        response.meta['course'] = CourseItem(evaluations = [], code = '11837')
        response.meta['counter'] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item['evaluations'][0]

        self.assertEqual(u'2013', evaluation['year'])
        self.assertEqual(u'June', evaluation['semester'])
        self.assertEqual(u'17', evaluation['could_answer'])
        self.assertEqual(u'0', evaluation['have_answered'])
        self.assertEqual(u'0', evaluation['did_not_follow'])

        self.assertEqual(u'0', evaluation['performance_much_less'])
        self.assertEqual(u'0', evaluation['performance_less'])
        self.assertEqual(u'0', evaluation['performance_same'])
        self.assertEqual(u'0', evaluation['performance_more'])
        self.assertEqual(u'0', evaluation['performance_much_more'])

        self.assertEqual(u'0', evaluation['prereq_too_low'])
        self.assertEqual(u'0', evaluation['prereq_low'])
        self.assertEqual(u'0', evaluation['prereq_adequate'])
        self.assertEqual(u'0', evaluation['prereq_high'])
        self.assertEqual(u'0', evaluation['prereq_too_high'])
    def test_parse_course(self):
        response = fake_response_from_file(self.course_27002_page)
        response.meta['department'] = DepartmentItem()
        actual = self.spider.parse_course(response)

        self.assertEqual(u'27002', actual['code'])
        self.assertEqual(u'Danish', actual['language'])
        self.assertEqual(u'Life Science', actual['title_en'])
        self.assertEqual(u'Biovidenskab', actual['title_da'])
        self.assertEqual(u'7 step scale', actual['evaluation_type'])
        self.assertEqual(5.0, actual['ects_credits'])
        self.assertEqual(u'BSc', actual['course_type'])
    def test_parse_grade_dist_not_enough_grades(self):
        response = fake_response_from_file(self.not_enough_grades)
        response.meta['course'] = CourseItem(course_runs = [], code = '11130')
        response.meta['counter'] = PageCounter(1, 0)

        course_item = self.course_run_parser.parse_grade_dist_page(response)
        course_run = course_item['course_runs'][0]

        self.assertEqual(u'2012', course_run['year'])
        self.assertEqual(u'Winter', course_run['semester'])
        self.assertEqual(u'2', course_run['students_registered'])
        self.assertEqual(u'1', course_run['students_attended'])
    def test_parse_grade_dist_missing_passed(self):
        response = fake_response_from_file(self.missing_passed)
        response.meta['course'] = CourseItem(course_runs = [], code = '11126')
        response.meta['counter'] = PageCounter(1, 0)

        course_item = self.course_run_parser.parse_grade_dist_page(response)
        course_run = course_item['course_runs'][0]

        self.assertEqual(u'2011', course_run['year'])
        self.assertEqual(u'Winter', course_run['semester'])
        self.assertEqual(u'2', course_run['students_registered'])
        self.assertEqual(u'2', course_run['students_attended'])
        self.assertEqual(u'1', course_run['grade_12'])
        self.assertEqual(u'0', course_run['grade_10'])
        self.assertEqual(u'0', course_run['grade_7'])
        self.assertEqual(u'0', course_run['grade_4'])
        self.assertEqual(u'0', course_run['grade_02'])
        self.assertEqual(u'0', course_run['grade_00'])
        self.assertEqual(u'1', course_run['grade_minus_3'])
    def test_parse_grade_dist_mixed_scales(self):
        response = fake_response_from_file(self.mixed_scales)
        response.meta['course'] = CourseItem(course_runs = [], code = '27944')
        response.meta['counter'] = PageCounter(1, 0)

        course_item = self.course_run_parser.parse_grade_dist_page(response)
        course_run = course_item['course_runs'][0]

        self.assertEqual(u'2012', course_run['year'])
        self.assertEqual(u'Summer', course_run['semester'])
        self.assertEqual(u'23', course_run['students_registered'])
        self.assertEqual(u'23', course_run['students_attended'])
        self.assertEqual(u'23', course_run['students_passed'])
        self.assertEqual(u'2', course_run['grade_12'])
        self.assertEqual(u'3', course_run['grade_10'])
        self.assertEqual(u'13', course_run['grade_7'])
        self.assertEqual(u'1', course_run['grade_4'])
        self.assertEqual(u'4', course_run['grade_02'])
        self.assertEqual(u'0', course_run['grade_00'])
        self.assertEqual(u'0', course_run['grade_minus_3'])
    def test_parse_grade_dist_two_grade_scales(self):
        response = fake_response_from_file(self.course_run_two_scales)
        response.meta['course'] = CourseItem(course_runs = [], code = '11B12')
        response.meta['counter'] = PageCounter(1, 0)

        course_item = self.course_run_parser.parse_grade_dist_page(response)
        course_run = course_item['course_runs'][0]

        self.assertEqual(u'2004', course_run['year'])
        self.assertEqual(u'Winter', course_run['semester'])
        self.assertEqual(u'24', course_run['students_registered'])
        self.assertEqual(u'18', course_run['students_attended'])
        self.assertEqual(u'18', course_run['students_passed'])
        self.assertEqual(u'0', course_run['grade_12'])
        self.assertEqual(u'11', course_run['grade_10'])
        self.assertEqual(u'7', course_run['grade_7'])
        self.assertEqual(u'0', course_run['grade_4'])
        self.assertEqual(u'0', course_run['grade_02'])
        self.assertEqual(u'0', course_run['grade_00'])
        self.assertEqual(u'0', course_run['grade_minus_3'])
        self.assertEqual(u'6', course_run['not_shown'])
    def test_parse_grade_dist_page(self):
        response = fake_response_from_file(self.course_27002_course_run_page)
        response.meta['course'] = CourseItem(course_runs = [], code = '27002')
        response.meta['counter'] = PageCounter(1, 0)
        course_item = self.course_run_parser.parse_grade_dist_page(response)
        course_run = course_item['course_runs'][0]

        self.assertEqual(u'2010', course_run['year'])
        self.assertEqual(u'Summer', course_run['semester'])
        self.assertEqual(u'74', course_run['students_registered'])
        self.assertEqual(u'61', course_run['students_attended'])
        self.assertEqual(u'45', course_run['students_passed'])
        #self.assertEqual(u'4.7', course_run['exam_average'])
        self.assertEqual(u'2', course_run['grade_12'])
        self.assertEqual(u'10', course_run['grade_10'])
        self.assertEqual(u'21', course_run['grade_7'])
        self.assertEqual(u'7', course_run['grade_4'])
        self.assertEqual(u'5', course_run['grade_02'])
        self.assertEqual(u'8', course_run['grade_00'])
        self.assertEqual(u'8', course_run['grade_minus_3'])
        self.assertEqual(u'2', course_run['sick'])
        self.assertEqual(u'11', course_run['not_shown'])
Exemple #13
0
    def test_parse_evaluation_two_text_nodes_questions(self):
        response = fake_response_from_file(self.evaluation_two_text_nodes)
        response.meta['course'] = CourseItem(evaluations = [], code = '11B01')
        response.meta['counter'] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item['evaluations'][0]

        self.assertEqual(u'2007', evaluation['year'])
        self.assertEqual(u'Summer', evaluation['semester'])
        self.assertEqual(u'24', evaluation['could_answer'])
        self.assertEqual(u'10', evaluation['have_answered'])

        self.assertEqual(u'0', evaluation['performance_much_less'])
        self.assertEqual(u'3', evaluation['performance_less'])
        self.assertEqual(u'6', evaluation['performance_same'])
        self.assertEqual(u'1', evaluation['performance_more'])
        self.assertEqual(u'0', evaluation['performance_much_more'])

        self.assertEqual(u'0', evaluation['prereq_too_low'])
        self.assertEqual(u'0', evaluation['prereq_low'])
        self.assertEqual(u'0', evaluation['prereq_adequate'])
        self.assertEqual(u'0', evaluation['prereq_high'])
        self.assertEqual(u'0', evaluation['prereq_too_high'])
    def test_parse_evaluation_two_text_nodes_questions(self):
        response = fake_response_from_file(self.evaluation_two_text_nodes)
        response.meta["course"] = CourseItem(evaluations=[], code="11B01")
        response.meta["counter"] = PageCounter(0, 1)

        course_item = self.evaluation_parser.parse_evaluation_page(response)
        evaluation = course_item["evaluations"][0]

        self.assertEqual(u"2007", evaluation["year"])
        self.assertEqual(u"Summer", evaluation["semester"])
        self.assertEqual(u"24", evaluation["could_answer"])
        self.assertEqual(u"10", evaluation["have_answered"])

        self.assertEqual(u"0", evaluation["performance_much_less"])
        self.assertEqual(u"3", evaluation["performance_less"])
        self.assertEqual(u"6", evaluation["performance_same"])
        self.assertEqual(u"1", evaluation["performance_more"])
        self.assertEqual(u"0", evaluation["performance_much_more"])

        self.assertEqual(u"0", evaluation["prereq_too_low"])
        self.assertEqual(u"0", evaluation["prereq_low"])
        self.assertEqual(u"0", evaluation["prereq_adequate"])
        self.assertEqual(u"0", evaluation["prereq_high"])
        self.assertEqual(u"0", evaluation["prereq_too_high"])
 def test_parse(self):
     results = self.spider.parse(fake_response_from_file(self.department_list_page))
     result_list = list(results)
     self.assertTrue(len(result_list) == 2)
     self._check_departments(result_list)
 def test_parse_department_page(self):
     response = fake_response_from_file(self.department_27_page)
     response.meta['department'] = DepartmentItem()
     results = self.spider.parse_department_page(response)
     result_list = list(results)
     self.assertEqual(len(result_list), 64)
 def test_parse_course_information_page(self):
     response = fake_response_from_file(self.course_27002_info_page)
     response.meta['course'] = CourseItem()
     response.meta['department'] = DepartmentItem()
     results = self.spider.parse_course_information_page(response)
     self.assertEqual(len(list(results)), 17 + 5)
 def test_parse(self):
     results = self.spider.parse(fake_response_from_file(self.department_list_page))
     result_list = list(results)
     assert_that(result_list, has_length(21))