Пример #1
0
 def test_compute_schedules(self):
     "Should have 36 solutions for all courses."
     result = s.compute_schedules(self.courses.values())
     # RPI scheduler lists 12 schedules but:
     # - MATH 2010 has two sections for all the 12 schedules
     # - Software Design & Docs has 2 sections for 6 of the schedules
     self.assertEqual(len(result), 36)
Пример #2
0
 def test_schedules_with_restricting_times_and_no_conflicts(self):
     "Should have 1 solution for graph theory & intro to philosophy with time restriction."
     courses = (self.courses["graph theory math"], self.courses["intro to philosophy"])
     restrictions = []
     for p in courses[1].sections[0].periods:
         restrictions.append(s.TimeRange(*p.time_range, dow=(0,)))
     result = s.compute_schedules(courses, restrictions)
     expected = [{courses[0]: courses[0].sections[0], courses[1]: courses[1].sections[1]}]
     self.assertEqual(list(result), expected)
Пример #3
0
    def test_schedules_with_no_conflicts(self):
        "Should have 2 solutions for graph theory & intro to philosophy."
        courses = (self.courses["graph theory math"], self.courses["intro to philosophy"])
        result = s.compute_schedules(courses)
        expected = [
            {courses[0]: courses[0].sections[0], courses[1]: courses[1].sections[1]},
            {courses[0]: courses[0].sections[0], courses[1]: courses[1].sections[0]},
        ]

        self.assertIn(result[0], expected)
        self.assertIn(result[1], expected)
        self.assertNotEqual(result[0], result[1])
Пример #4
0
    def test_schedules_with_conflicts(self):
        "Should schedule courses with some conflicts."
        result = s.compute_schedules(self.courses.values())
        c = (self.courses["BEGINNING PROG FOR ENG"], self.courses["COMPUTER SCIENCE I"])
        expected = []
        for s1 in c[0].sections:
            for s2 in c[1].sections:
                if not s1.conflicts_with(s2):
                    expected.append({c[0]: s1, c[1]: s2})

        self.assertEqual(len(result), len(expected))
        for r in result:
            self.assertIn(r, expected)
            for r2 in result:
                if r != r2:
                    self.assertNotEqual(r, r2)
Пример #5
0
    def test_schedules_with_conflicts_and_restricted_times(self):
        "Should schedule courses with some conflicts and time restrictions"
        result = s.compute_schedules(self.courses.values())
        c = (self.courses["BEGINNING PROG FOR ENG"], self.courses["COMPUTER SCIENCE I"])

        restrictions = [s.TimeRange(start=1000, end=1100, dow=(0,))]

        expected = []
        for s1 in c[0].sections:
            if restrictions[0].conflicts_with(s1):
                continue
            for s2 in c[1].sections:
                if not s1.conflicts_with(s2):
                    expected.append({c[0]: s1, c[1]: s2})

        self.assertEquals(len(result), len(expected))
        for r in result:
            self.assertIn(r, expected)
            for r2 in result:
                if r != r2:
                    self.assertNotEqual(r, r2)