def test_Course4(self):
     co = Course("CS-337", "004", ["M", "W", "F"], "11:00", "11:50",
                 ["001", "002", "003"])
     with self.assertRaises(ValueError) as ctx:
         co.section = "abs"
     self.assertEqual("Section must be a three digit number",
                      str(ctx.exception))
 def test_Course21(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     with self.assertRaises(ValueError) as ctx:
         co.lab_sections = ["abs", "001", "r34"]
     self.assertEqual("Lab sections must be a three digit number",
                      str(ctx.exception))
 def test_Course17(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     with self.assertRaises(ValueError) as ctx:
         co.lab = "00001"
     self.assertEqual("Lab must be a three digit number",
                      str(ctx.exception))
 def test_Course12(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     with self.assertRaises(ValueError) as ctx:
         co.end_time = "23:000"
     self.assertEqual("valid end time is 00:00 to 23:59",
                      str(ctx.exception))
 def test_Course13(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.start_time = "11:00"
     with self.assertRaises(ValueError) as ctx:
         co.end_time = "10:00"
     self.assertEqual("end time can not be earlier than start time",
                      str(ctx.exception))
 def test_Course22(self):
     co = Course("CS-361", "001", ["T", "R"], "11:00", "11:50",
                 ["001", "002", "003"])
     self.assertEqual(co.name, "CS-361")
     self.assertEqual(co.section, "001")
     self.assertEqual(co.days_of_week, ["T", "R"])
     self.assertEqual(co.start_time, "11:00")
     self.assertEqual(co.end_time, "11:50")
     self.assertEqual(co.lab_sections, ["001", "002", "003"])
示例#7
0
 def create_course(self, psname="", pssection="", psdaysofweek="", pstimes="", pslabsection=""):
     if psname == "" or pssection == "" or psdaysofweek == "" or pstimes == "":
         raise ValueError("Please fill in all required fields to create a course")
     else:
         days = psdaysofweek.split("/")
         labs = pslabsection.split("/")
         times = pstimes.split("-")
         co = Course(psname, pssection, days, times[0], times[1], labs)
         self.coursesDB.add_course(co)
示例#8
0
 def add_course(self, entry: Course) -> bool:
     """
         :param entry: a data validated Course object that will entered into the DB
         :return: a boolean if the process was successful
     """
     self.__dbObject = open(self.db_path, "a+")
     if self.db_object is None or entry is None or not self.__isConnected:
         return False
     self.db_object.write(entry.__str__() + "\n")
     self.__dbObject.close()
     return True
示例#9
0
 def setUp(self):
     self.account_correct = Account()
     self.account_correct.user = "******"
     self.account_correct.password = "******"
     self.account_correct.role = "TA"
     self.course_correct = Course()
     self.course_correct.name = "CS103"
     self.course_correct.section = "222"
     self.course_correct.days_of_week = ["M", "W", "F"]
     self.course_correct.start_time = "12:00"
     self.course_correct.end_time = "13:00"
     self.course_correct.lab_sections = "210"
 def test_Course19(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.lab_sections = ["008", "009"]
     self.assertEqual(co.lab_sections, ["008", "009"])
 def test_Course10(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.end_time = "11:00"
     self.assertEqual(co.end_time, "11:00")
 def test_Course1(self):
     co = Course("CS-337", "004", ["M", "W", "F"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.name = "CS-361"
     self.assertEqual(co.name, "CS-361")
 def test_Course6(self):
     with self.assertRaises(ValueError) as ctx:
         co = Course("CS-337", "004", ["T", "Z"], "11:00", "11:50",
                     ["001", "002", "003"])
     self.assertEqual("Days of week are noted as M T W R F",
                      str(ctx.exception))
 def test_Course5(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.days_of_week = ["M", "W", "F"]
     self.assertEqual(co.days_of_week, ["M", "W", "F"])
 def test_Course14(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.instructor = " Jason Rock"
     self.assertEqual(co.instructor, " Jason Rock")
 def test_Course15(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.tas = ["Steve", "Tim"]
     self.assertEqual(co.tas, ["Steve", "Tim"])
 def test_Course16(self):
     co = Course("CS-337", "004", ["M", "W"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.lab = "008"
     self.assertEqual(co.lab, "008")
 def test_Course2(self):
     co = Course("CS-337", "004", ["M", "W", "F"], "11:00", "11:50",
                 ["001", "002", "003"])
     co.section = "001"
     self.assertEqual(co.section, "001")