def test_byCourseSubject_contains(self): """ Test that subject search returns correct results for contains comparison """ d = DescSearches() self.assertTrue(len(d.byCourseSubject(self.three_courses, "hosp", "~")) == 1) self.assertTrue(len(d.byCourseSubject(self.three_courses, "compu", "~")) == 2)
def test_byCourseSubject_invalid(self): ''' Tests that subject search fails when fed something invalid ''' d= DescSearches() with self.assertRaises(Exception): d.byCourseSubject(self.three_courses, 1, '=') with self.assertRaises(Exception): d.byCourseSubject(self.three_courses, True, '=') with self.assertRaises(Exception): d.byCourseSubject(self.three_courses, 3.14, '=') with self.assertRaises(Exception): d.byCourseSubject(self.three_courses, [], '=')
def test_byCourseSubject(self): ''' Tests that subject search returns correctly ''' d= DescSearches() self.assertTrue(len(d.byCourseSubject(self.single_course, "Hospitality and Tourism Management", '=')) == 1) self.assertTrue(len(d.byCourseSubject(self.single_course, "Computing and Information Science", '=')) == 0) self.assertTrue(len(d.byCourseSubject(self.two_courses, "Hospitality and Tourism Management", '=')) == 1) self.assertTrue(len(d.byCourseSubject(self.two_courses, "Computing and Information Science", '=')) == 1) self.assertTrue(len(d.byCourseSubject(self.three_courses, "Hospitality and Tourism Management", '=')) == 1) self.assertTrue(len(d.byCourseSubject(self.three_courses, "Computing and Information Science", '=')) == 2)