def test_createSection_invalid_sectionNumber(self):
     self.assertEqual(createSection("564", "0", "408", "W", "1300", "1500"), "Lab section number must be 200 level, numeric, and three digits long.")
     self.assertEqual(createSection("564", "0", "2508", "W", "1300", "1500"), "Lab section number must be 200 level, numeric, and three digits long.")
     self.assertEqual(createSection("564", "0", "2m8", "W", "1300", "1500"), "Lab section number must be 200 level, numeric, and three digits long.")
     self.assertEqual(createSection("564", "1", "208", "W", "1300", "1500"), "Lecture section number must be 400 level, numeric, and three digits long.")
     self.assertEqual(createSection("564", "1", "48", "W", "1300", "1500"), "Lecture section number must be 400 level, numeric, and three digits long.")
     self.assertEqual(createSection("564", "1", "40i8", "W", "1300", "1500"), "Lecture section number must be 400 level, numeric, and three digits long.")
示例#2
0
    def post(self, request):
        CU = CurrentUser()
        Acc = CU.getCurrentUser(request)
        courseList = Course.objects.all()
        courseName = str(request.POST.get("course"))
        #course = Course.objects.get(name=courseName)
        # courseNum = str(course.number)
        type = str(request.POST["type"])
        number = str(request.POST["number"])
        days = str(request.POST["days"])
        start = str(request.POST["start"])
        end = str(request.POST["end"])

        base = CU.getTemplate(request)
        message = createSection(courseName, type, number, days, start, end)
        return render(
            request, 'createSection.html', {
                "message": message,
                "editor": Acc,
                "courseList": courseList,
                "base": base
            })
示例#3
0
 def test_createSection_success(self):
     self.assertEqual(createSection("633", "1", "604", "W", "1300", "1500"),
                      "Lab successfully created")
 def test_createSection_invalidTimes(self):
     self.assertEqual(createSection("784", "1", "401", "W", "130", "1500"), "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(createSection("784", "1", "401", "W", "13m0", "1500"), "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(createSection("784", "1", "401", "W", "8300", "1500"), "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(createSection("784", "1", "401", "W", "1300", "3500"), "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(createSection("784", "1", "401", "W", "1300", "1100"), "End time must be after start time.")
 def test_createSection_alreadyExists(self):
     self.assertEqual(createSection("784", "1", "401", "W", "1300", "1500"), "Section already exists; section not added.")
     self.assertEqual(createSection("784", "1", "402", "W", "1300", "1500"), "Section already exists; section not added.")
     self.assertEqual(createSection("784", "0", "203", "W", "1300", "1500"), "Section already exists; section not added.")
 def test_createSection_onlineLecture_success(self):
     self.assertEqual(createSection("564", "1", "404", "W", "1300", "1500"), "Section successfully created.")
     self.assertEqual(createSection("564", "1", "408", "W", "1300", "1500"), "Section successfully created.")
 def test_createSection_onlineLab_fail(self):
     self.assertEqual(createSection("564", "0", "206", "W", "1300", "1500"), "You cannot create a lab section for an online course.")
     self.assertEqual(createSection("564", "0", "205", "W", "1300", "1500"),
                      "You cannot create a lab section for an online course.")
 def test_createSection_invalidType(self):
     self.assertEqual(createSection("633", "-1", "404", "W", "1300", "1500"), "Invalid section type.")
     self.assertEqual(createSection("633", "2", "404", "W", "1300", "1500"), "Invalid section type.")
 def test_createSection_courseDNE(self):
     self.assertEqual(createSection("975", "1", "404", "W", "1300", "1500"), "The course does not exist.")
 def test_createSection_invalid_course(self):
     self.assertEqual(createSection("M3", "1", "404", "W", "1300", "1500"), "Course number must be numeric and three digits long")
     self.assertEqual(createSection("2008", "1", "404", "W", "1300", "1500"),
                      "Course number must be numeric and three digits long")
     self.assertEqual(createSection("38", "1", "404", "W", "1300", "1500"),
                      "Course number must be numeric and three digits long")
 def test_createSection_success(self):
     self.assertEqual(createSection("633", "1", "404", "W", "1300", "1500"), "Section successfully created.")
     self.assertEqual(createSection("633", "0", "204", "W", "1300", "1500"), "Section successfully created.")