Example #1
0
    def test_badData(self):
        check = assign_ta_to_lab({
            "designation": 1,
            "labSection": 801,
            "taUsername": "******"
        })
        self.assertFalse(
            check, msg="Error: bad data for assigning TA to lab does not fail")
        self.lab = LabData.objects.get(section=801)
        self.assertEqual(
            None,
            self.lab.TA,
            msg="Error: some TA is assigned to lab when bad data is passed")
        self.assertEqual(
            1,
            len(TAsToCourses.objects.all()),
            msg="Error: an extra entry is created in linking table")

        check = assign_ta_to_lab({
            "designation": "cs1",
            "labSection": "801",
            "taUsername": "******"
        })
        self.assertFalse(
            check, msg="Error: bad data for assigning TA to lab does not fail")
        self.lab = LabData.objects.get(section=801)
        self.assertEqual(
            None,
            self.lab.TA,
            msg="Error: some TA is assigned to lab when bad data is passed")
        self.assertEqual(
            1,
            len(TAsToCourses.objects.all()),
            msg="Error: an extra entry is created in linking table")

        check = assign_ta_to_lab({
            "designation": "cs1",
            "labSection": 801,
            "taUsername": 1
        })
        self.assertFalse(
            check, msg="Error: bad data for assigning TA to lab does not fail")
        self.lab = LabData.objects.get(section=801)
        self.assertEqual(
            None,
            self.lab.TA,
            msg="Error: some TA is assigned to lab when bad data is passed")
        self.assertEqual(
            1,
            len(TAsToCourses.objects.all()),
            msg="Error: an extra entry is created in linking table")
Example #2
0
 def test_goodData(self):
     check = assign_ta_to_lab({
         "designation": "cs1",
         "labSection": 801,
         "taUsername": "******"
     })
     print(check)
     self.assertTrue(
         check,
         msg="Error: good data does not return true for adding TA to lab")
     self.assertTrue(
         type(check) is bool,
         msg="Error: something other than a bool is returned on success")
     self.lab = LabData.objects.get(section=801)
     self.assertEqual(self.lab.TA,
                      self.ta,
                      msg="Error: wrong TA is assigned to lab")
     query = TAsToCourses.objects.all()
     self.assertEqual(
         len(query),
         1,
         msg="Error: an object is not created in the linking table")
     self.assertEqual(query[0].TA,
                      self.ta,
                      msg="Error: wrong TA is created in linking table")
     self.assertEqual(query[0].course.title,
                      "course1",
                      msg="Error: wrong course is in the linking table")
Example #3
0
 def post(self, request, **kwargs):
     check = database_access.assign_ta_to_lab({"designation": self.kwargs["course"],
                                               "labSection": int(self.kwargs["lab"]),
                                               "taUsername": request.POST["taUsername"]})
     tas = ((i[0], database_access.get_skills(i[1]), i[1]) for i in database_access.get_tas_of_course(self.kwargs["course"]))
     return render(request, "assign_my_ta.html", {"pagetitle": "My Courses",
                                                  "position": request.session['position'],
                                                  "message": str(check) if not check else "Success!",
                                                  "tas": tas,
                                                  "course": self.kwargs["course"],
                                                  "lab": self.kwargs["lab"]})
Example #4
0
    def post(self, request, **kwargs):
        check = database_access.assign_ta_to_lab({"designation": self.kwargs.get("course"),
                                                  "labSection": int(self.kwargs.get("lab")),
                                                  "taUsername": request.POST.get("taUsername")})

        return render(request, "assign_ta_to_lab.html", {"pagetitle": "Assign TA to Lab",
                                                         "designation": self.kwargs.get('course'),
                                                         "TAs": database_access.get_tas_of_course(
                                                             self.kwargs.get('course')),
                                                         "lab": self.kwargs.get('lab'),
                                                         "message": str(check) if not check else "Success!"})
Example #5
0
 def test_labDoesNotExist(self):
     check = assign_ta_to_lab({
         "designation": "cs1",
         "labSection": 802,
         "taUsername": "******"
     })
     self.assertFalse(
         check, msg="Error: assigning TA does not fail when it should")
     self.lab = LabData.objects.get(section=801)
     self.assertEqual(
         None,
         self.lab.TA,
         msg="Error: TA is assigned to lab when it should not be")
Example #6
0
 def test_userNotTA(self):
     check = assign_ta_to_lab({
         "designation": "cs1",
         "labSection": 801,
         "taUsername": "******"
     })
     self.assertFalse(
         check,
         msg="Error: trying to assign a supervisor as a TA does not fail")
     self.lab = LabData.objects.get(section=801)
     self.assertEqual(
         None,
         self.lab.TA,
         msg="Error: someone is assigned to lab when it should not be")