def test_byCourseCode_contains(self): """ Test that course code search returns correct results for contains comparison """ d = DescSearches() self.assertTrue(len(d.byCourseCode(self.three_courses, "ci", "~")) == 2) self.assertTrue(len(d.byCourseCode(self.three_courses, "h", "~")) == 1) self.assertTrue(len(d.byCourseCode(self.three_courses, "CIS", "~")) == 2) self.assertTrue(len(d.byCourseCode(self.three_courses, "HTM", "~")) == 1)
def test_byCourseCode_case(self): """ Test that course code search returns correct results regardless of upper/lower case """ upperCode = "HTM" lowerCode = "htm" mixedCode = "hTm" d = DescSearches() upperResult = d.byCourseCode(self.single_course, upperCode, '=') lowerResult = d.byCourseCode(self.single_course, lowerCode, '=') mixedResult = d.byCourseCode(self.single_course, mixedCode, '=') self.assertTrue(len(upperResult) == 1) self.assertTrue(len(lowerResult) == 1) self.assertTrue(len(mixedResult) == 1)
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_byCourseCode_none(self): """ Test that course code search returns no results for code not in courses """ d = DescSearches() self.assertTrue(len(d.byCourseCode(self.single_course, "DNE", '=')) == 0)
def test_byCourseCode(self): """ Test that course code search returns correct results """ d = DescSearches() self.assertTrue(len(d.byCourseCode(self.single_course, "HTM", '=')) == 1)