def test_edit_lab_time(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "lab", "801", "", "02:08"), "Section has been edited successfully.") course = models.Course.objects.get(course_id="361") lab1 = models.Lab.objects.get(course=course, lab_section="801") self.assertEqual(lab1.lab_location, "Somewhere") self.assertEqual(lab1.lab_time, datetime.time(2, 8))
def test_edit_lecture_bad_dept(self): self.assertEqual( Commands.edit_lec_lab("BAD DEPT", "361", "lecture", "401", "NEW LOCATION", "02:08"), "That department is not offered") course = models.Course.objects.get(course_id="361") lec1 = models.Lecture.objects.get(course=course, lecture_section="401") self.assertEqual(lec1.lecture_location, "Somewhere") self.assertEqual(lec1.lecture_time, datetime.time(12, 0))
def test_edit_lecture_location_and_more_bad_time(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "lecture", "401", "NEW LOCATION", "24:00"), "Bad time format (HH:MM)") course = models.Course.objects.get(course_id="361") lec1 = models.Lecture.objects.get(course=course, lecture_section="401") self.assertEqual(lec1.lecture_location, "NEW LOCATION") self.assertEqual(lec1.lecture_time, datetime.time(12, 0))
def test_edit_lecture_location(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "lecture", "401", "NEW LOCATION", ""), "Section has been edited successfully.") course = models.Course.objects.get(course_id="361") lec1 = models.Lecture.objects.get(course=course, lecture_section="401") self.assertEqual(lec1.lecture_location, "NEW LOCATION") self.assertEqual(lec1.lecture_time, datetime.time(12, 0))
def test_edit_lab_location_and_bad_time(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "lab", "801", "NEW LOCATION", "BAD"), "Bad time format (HH:MM)") course = models.Course.objects.get(course_id="361") lab1 = models.Lab.objects.get(course=course, lab_section="801") self.assertEqual(lab1.lab_location, "NEW LOCATION") self.assertEqual(lab1.lab_time, datetime.time(12, 0))
def post(self, request): request.session.set_expiry(300) department = request.POST["course_department"] course_id = request.POST["course_id"] section_type = request.POST["section"] section_id = request.POST["section_id"] location = request.POST["location"] time = request.POST["time"] response = Commands.edit_lec_lab(department, course_id, section_type, section_id, location, time) if response == "Section has been edited successfully.": messages.success(request, response) else: messages.error(request, response) return render(request, 'main/edit_lec_lab.html')
def test_edit_lecture_course_dne(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "333", "lecture", "401", "NEW LOCATION", "02:08"), "That course does not exist")
def test_edit_lecture_bad_course_id(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "BAD", "lecture", "401", "NEW LOCATION", "02:08"), "Course ID must be a number")
def test_edit_lab_bad_section_id(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "lab", "BAD", "NEW LOCATION", "02:08"), "Section ID must be a number")
def test_edit_lab_section_dne(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "lab", "811", "NEW LOCATION", "02:08"), "That lab does not exist")
def test_edit_lab_bad_section_type(self): self.assertEqual( Commands.edit_lec_lab("COMPSCI", "361", "badness", "801", "NEW LOCATION", "02:08"), "Invalid section type")