Пример #1
0
    def test_missingData(self):
        check = make_course({"title": "course0"})
        self.assertFalse(
            check,
            msg=
            "Error: making course does not fail if a section is not provided")

        check = make_course({"section": 201})
        self.assertFalse(
            check,
            msg="Error: making course does not fail when title is not provided"
        )
Пример #2
0
 def test_badData(self):
     check = make_course({"title": "course0", "section": "200"})
     self.assertFalse(
         check,
         msg="Error: making course does not fail when input is incorrect")
     self.assertFalse(
         CourseData.objects.filter(title="course0").exists(),
         msg="Error: course data is stored when creation failed")
Пример #3
0
 def test_goodData(self):
     check = make_course({
         "title": "course0",
         "section": 200,
         "designation": "CS350"
     })
     self.assertTrue(check,
                     msg="Error: good course data fails to create course")
     print(list(map(str, CourseSections.objects.all())))
Пример #4
0
 def test_existingCourse(self):
     check = make_course({
         "title": "course1",
         "section": 202,
         "designation": "CS351"
     })
     self.assertTrue(
         check,
         msg=
         "Error: creating new section for a course fails when it should not"
     )
Пример #5
0
 def test_courseSectionExists(self):
     check = make_course({
         "title": "course1",
         "section": 201,
         "designation": "CS351"
     })
     self.assertFalse(
         check,
         msg="Error: making course does not fail when course section exists"
     )
     tempCourse = CourseData.objects.get(title="course1")
     self.assertEqual(
         len(CourseSections.objects.filter(course=tempCourse, section=201)),
         1,
         msg="Error: extra section is created when data is incorrect")
Пример #6
0
    def post(self, request, **kwargs):
        try:
            tempsection = int(request.POST['section'])
        except ValueError:
            tempsection = None

        if request.POST.get('isLab'):
            check = database_access.make_lab({"designation": self.kwargs.get("course"),
                                              "section": tempsection})
        else:
            check = database_access.make_course({"title": " ", "semester": " ", "designation": self.kwargs["course"],
                                                 "section": tempsection})
        print(request.POST)

        return render(request, "create_course_section.html",
                      {"pagetitle": "Add Section", "designation": self.kwargs["course"],
                       "message": str(check) if not check else "Success!"})
Пример #7
0
 def setUp(self):
     make_course({
         "title": "course1",
         "section": 201,
         "designation": "CS351"
     })
Пример #8
0
 def post(self, request):
     check = database_access.make_course(
         {"title": request.POST.get('title'), "designation": request.POST.get('designation'),
          "section": int(request.POST.get('section')), "semester": request.POST.get('semester')})
     return render(request, "create_course.html",
                   {"message": str(check) if not check else "success", "pagetitle": "Create Course"})