def test_bySemester_invalid(self): """Test that semester search fails nonconforming input.""" d = DescSearches() with self.assertRaises(Exception): d.bySemester(self.single_course, "W", '=') with self.assertRaises(Exception): d.bySemester(self.single_course, 4, '=')
class TestIntegration(unittest.TestCase): @classmethod def setUpClass(self): self.search = DescSearches() converter = PDFConverter() converter.openPDF("./c12.pdf") parser = CourseParser() self.courses = parser.open_file("converted-pdf.txt") def test_findCIS4250(self): socsCourses = self.search.byDepartment(self.courses, "School of Computer Science", "=") cisCourses = self.search.byCourseCode(socsCourses, "CIS", "=") fourthYearCourses = self.search.byCourseLevel(cisCourses, "4", "=") cis4250 = self.search.byCourseNumber(fourthYearCourses,"4250", "=") self.assertTrue(cis4250[0].code == "CIS" and cis4250[0].number == "4250") def test_findENVS1060(self): oneCreditCourses = self.search.byWeight(self.courses, 0.5, "=") summerCourses = self.search.bySemester(oneCreditCourses, SemesterOffered.S, "=") soesCourses = self.search.byDepartment(summerCourses, "School of Environmental Sciences", "=") firstYearCourses = self.search.byCourseLevel(soesCourses, "1", "=") envsCourses = self.search.byCourseCode(firstYearCourses, "ENVS", "=") envs1060 = self.search.byCourseNumber(envsCourses, "1060", "=") self.assertTrue(envs1060[0].code == "ENVS" and envs1060[0].number == "1060") def test_languageKeyword(self): languageKeywordCourses = self.search.byKeyword(self.courses, "language", "=") englishKeywordCourses = self.search.byKeyword(languageKeywordCourses, "english", "=") frenchKeywordCourses = self.search.byKeyword(englishKeywordCourses, "french", "=") fallCourses = self.search.bySemester(frenchKeywordCourses, SemesterOffered.F, "=") self.assertTrue(fallCourses[0].code == "FREN" and fallCourses[0].number == "3500")
def test_bySemester(self): """Test that semester search returns correct results.""" d = DescSearches() self.assertTrue(len(d.bySemester(self.single_course, SemesterOffered.W, '=')) == 1) self.assertTrue(len(d.bySemester(self.two_courses, SemesterOffered.F, '=')) == 1)