Example #1
0
    def test_byLectureHours(self):
        """
            Tests that each comparison (including default) returns correct results
        """
        d = DescSearches()
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.0)) == 2) # Default is "="
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.5, "=")) == 1)

        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.6, "<")) == 3)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.0, "<=")) == 2)
        
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.0, ">")) == 1)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.0, ">=")) == 3)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.5, ">=")) == 1)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 0.0, ">=")) == 3)
Example #2
0
    def test_byLectureHours_invalid(self):
        """
            Tests that search throws exceptions for invalid input
        """
        d = DescSearches()

        with self.assertRaises(Exception):
            d.byLectureHours(self.single_course, -1.0)
        with self.assertRaises(Exception):
            d.byLectureHours(self.single_course, 1)
        with self.assertRaises(Exception):
            d.byLectureHours(self.single_course, 2.0, "A")
Example #3
0
    def test_byLectureHours_none(self):
        """
            Tests that each comparison (including default) returns no results for no matches
        """
        d = DescSearches()
        self.assertTrue(len(d.byLectureHours(self.three_courses, 16.0)) == 0) # Default is "="
        self.assertTrue(len(d.byLectureHours(self.three_courses, 1.0, "=")) == 0)

        self.assertTrue(len(d.byLectureHours(self.three_courses, 0.0, "<")) == 0)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 2.9, "<=")) == 0)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 0.0, "<=")) == 0)
        
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.5, ">")) == 0)
        self.assertTrue(len(d.byLectureHours(self.three_courses, 3.6, ">=")) == 0)