Exemplo n.º 1
0
class Test(unittest.TestCase):
    def test_simpleStuff(self):

        self.study_plan = StudyPlan()
        self.study_plan.addCompletedCourse("completed course")
        self.study_plan.addCourse("course")
        self.study_plan.scheduleCourse("course", 1,
                                       Period(Period.I, Period.II))
        year1, period1 = self.study_plan.getCourse("course")
        self.assertEqual(1, year1, "Wrong year")
        self.assertEqual(Period(Period.I, Period.II), period1, "Wrong period")
        year2, period2 = self.study_plan.getCourse("completed course")
        self.assertEqual(StudyPlan.COMPLETED, year2, "Wrong year")
        self.assertEqual(None, period2, "Wrong period")
        year3, period3 = self.study_plan.getCourse("inexisting")
        self.assertEqual(None, year3, "wrong year")
        self.assertEqual(None, period3, "Wrong period")
        self.study_plan.removeCourse("course")
        year1, period1 = self.study_plan.getCourse("course")
        self.assertEqual(None, year1, "Wrong year")
        self.assertEqual(None, period1, "Wrong period")
        self.study_plan.addCourse("course")
        year1, period1 = self.study_plan.getCourse("course")
        self.assertEqual(StudyPlan.UNSCHEDULED, year1, "Wrong year")
        self.assertEqual(None, period1, "Wrong period")

    def test_prerequisites(self):
        plannerIO = PlannerIO()
        studyPlan = plannerIO.loadStudyPlan('studyplan2.csv')
        studyPlan.setAvailableCourses(plannerIO.loadCourses('courses1.csv'))
        dissatisfied = studyPlan.listCourseNamesWithDissatisfiedPrerequisites()
        self.assertTrue('fysiikka 2' in dissatisfied,
                        'something wrong with dissatisfied prerequisites')
        self.assertTrue('matematiikka 3' in dissatisfied,
                        'something wrong with dissatisfied prerequisites')
Exemplo n.º 2
0
class Test(unittest.TestCase):


    def test_simpleStuff(self):
        
        self.study_plan = StudyPlan()
        self.study_plan.addCompletedCourse("completed course")
        self.study_plan.addCourse("course")
        self.study_plan.scheduleCourse("course", 1, Period(Period.I, Period.II))
        year1, period1 = self.study_plan.getCourse("course")
        self.assertEqual(1, year1, "Wrong year")
        self.assertEqual(Period(Period.I, Period.II), period1, "Wrong period")
        year2, period2 = self.study_plan.getCourse("completed course")
        self.assertEqual(StudyPlan.COMPLETED, year2, "Wrong year")
        self.assertEqual(None, period2, "Wrong period")
        year3, period3 = self.study_plan.getCourse("inexisting")
        self.assertEqual(None, year3, "wrong year")
        self.assertEqual(None, period3, "Wrong period")
        self.study_plan.removeCourse("course")
        year1, period1 = self.study_plan.getCourse("course")
        self.assertEqual(None, year1, "Wrong year")
        self.assertEqual(None, period1, "Wrong period")
        self.study_plan.addCourse("course")
        year1, period1 = self.study_plan.getCourse("course")
        self.assertEqual(StudyPlan.UNSCHEDULED, year1, "Wrong year")
        self.assertEqual(None, period1, "Wrong period")
        
    def test_prerequisites(self):
        plannerIO = PlannerIO()
        studyPlan = plannerIO.loadStudyPlan('studyplan2.csv')
        studyPlan.setAvailableCourses(plannerIO.loadCourses('courses1.csv'))
        dissatisfied = studyPlan.listCourseNamesWithDissatisfiedPrerequisites()
        self.assertTrue('fysiikka 2' in dissatisfied, 'something wrong with dissatisfied prerequisites')
        self.assertTrue('matematiikka 3' in dissatisfied, 'something wrong with dissatisfied prerequisites')
Exemplo n.º 3
0
 def loadStudyPlan(self, inputFile):
     with open(inputFile, 'rb') as csvfile:
         reader = csv.reader(csvfile, delimiter=';')
         studyPlan = StudyPlan()
         for row in reader:
             year = int(row[1])
             if year == StudyPlan.UNSCHEDULED:
                 studyPlan.addCourse(row[0])
             elif year == StudyPlan.COMPLETED:
                 studyPlan.addCompletedCourse(row[0])
             else:
                 studyPlan.scheduleCourse(row[0], year, Period(row[2],row[3]))
                 
         return studyPlan
Exemplo n.º 4
0
    def loadStudyPlan(self, inputFile):
        with open(inputFile, 'rb') as csvfile:
            reader = csv.reader(csvfile, delimiter=';')
            studyPlan = StudyPlan()
            for row in reader:
                year = int(row[1])
                if year == StudyPlan.UNSCHEDULED:
                    studyPlan.addCourse(row[0])
                elif year == StudyPlan.COMPLETED:
                    studyPlan.addCompletedCourse(row[0])
                else:
                    studyPlan.scheduleCourse(row[0], year,
                                             Period(row[2], row[3]))

            return studyPlan