def test_add_two_course(self):
        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.course_department = "COMPSCI"
        course.course_id = "301"
        course.save()

        course2 = models.Course()
        course2.course_department = "COMPSCI"
        course2.course_id = "351"
        course2.save()

        insCourse = models.InstructorCourse()
        insCourse.course = course
        insCourse.instructor = inst1
        insCourse.save()

        insCourse = models.InstructorCourse()
        insCourse.course = course2
        insCourse.instructor = inst1
        insCourse.save()

        response = Commands.view_course_assignments(inst1.email)
        self.assertEqual(response, "COMPSCI: 301 \nCOMPSCI: 351 \n")
    def test_ta_not_assigned_sup(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        course1 = models.Course()
        course1.num_labs = 0
        course1.current_num_TA = 0
        course1.num_lectures = 1
        course1.instructor = "DEFAULT"
        course1.course_id = "302"
        course1.course_department = "COMPSCI"
        course1.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'supervisor'
        session.save()
        response = client.post('/assign_ta_lablec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "302",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA")
        self.assertContains(response, "TA not assigned to this course!")
예제 #3
0
    def test_ta_not_assigned_ins(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        course1 = models.Course()
        course1.num_labs = 0
        course1.current_num_TA = 0
        course1.num_lectures = 1
        course1.instructor = "DEFAULT"
        course1.course_id = "302"
        course1.course_department = "COMPSCI"
        course1.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        inscourse1 = models.InstructorCourse()
        inscourse1.instructor = inst1
        inscourse1.course = course1
        inscourse1.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        response = Commands.assign_ta_to_lablec(inst1.email, ta1.email,
                                                course1.course_id,
                                                lec.lecture_section,
                                                course.course_department)
        self.assertEqual(response, "TA not assigned to this course!")
    def test_two_courses(self):
        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.save()

        course2 = models.Course()
        course2.course_department = "COMPSCI"
        course2.course_id = "150"
        course2.save()

        lists = Commands.access_info()
        courses = lists[1]
        self.assertTrue(course1 in courses)
        self.assertTrue(course2 in courses)
 def test_assign_ta_too_many(self):
     ta1 = models.User()
     ta1.email = "*****@*****.**"
     ta1.type = "ta"
     ta1.save()
     ta2 = models.User()
     ta2.email = "*****@*****.**"
     ta2.type = "ta"
     ta2.save()
     ta3 = models.User()
     ta3.email = "*****@*****.**"
     ta3.type = "ta"
     ta3.save()
     course = models.Course()
     course.num_labs = 2
     course.current_num_TA = 0
     course.num_lectures = 1
     course.instructor = "DEFAULT"
     course.course_id = "301"
     course.course_department = "COMPSCI"
     course.save()
     proper = Commands.assign_ta_to_course(ta1.email, course.course_id,
                                           course.course_department)
     self.assertEqual(proper, "TA Assigned!")
     proper = Commands.assign_ta_to_course(ta2.email, course.course_id,
                                           course.course_department)
     self.assertEqual(proper, "TA Assigned!")
     proper = Commands.assign_ta_to_course(ta3.email, course.course_id,
                                           course.course_department)
     self.assertEqual(proper, "Too Many TA's Assigned")
예제 #6
0
    def test_no_such_lab_or_lec_sup(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        response = Commands.assign_ta_to_lablec(sup1.email, ta1.email,
                                                course.course_id, "804",
                                                course.course_department)
        self.assertEqual(response, "No Such Lab or Lecture")
    def test_access_info_ta_course_tapage(self):

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.name = "Ted"
        ta1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.course_dept_id = "COMPSCI100"
        course1.ta = "*****@*****.**"
        course1.save()

        ta1_course1 = models.TACourse()
        ta1_course1.TA = ta1
        ta1_course1.course = course1
        ta1_course1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()

        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        response = client.get('/ta/[email protected]/')
        self.assertContains(response, "TA: Ted")
        self.assertContains(response, "COMPSCI100")
예제 #8
0
    def test_super_post(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'supervisor'
        session.save()
        response = client.post('/assign_ta/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA")
        self.assertContains(response, "TA Assigned!")
    def test_proper(self):
        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        response = Commands.assign_instructor_to_lec(inst1.email,
                                                     course.course_id,
                                                     lec.lecture_section,
                                                     course.course_department)
        self.assertEqual(response, "Instructor assigned to lecture")
예제 #10
0
    def test_super_post_lab(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 1
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lab()
        lec.course = course
        lec.lab_section = "801"
        lec.save()

        response = Commands.assign_ta_to_lablec(sup1.email, ta1.email,
                                                course.course_id,
                                                lec.lab_section,
                                                course.course_department)
        self.assertEqual(response, "TA Assigned to Lab!")
    def test_access_info_inst_course_instpage(self):

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.name = "Bob"
        inst1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.course_dept_id = "COMPSCI100"
        course1.instructor = "*****@*****.**"
        course1.save()

        inst1_course1 = models.InstructorCourse()
        inst1_course1.instructor = inst1
        inst1_course1.course = course1
        inst1_course1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()

        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        response = client.get('/instructor/[email protected]/')
        self.assertContains(response, "Instructor: Bob")
        self.assertContains(response, "COMPSCI100")
예제 #12
0
    def test_delete_account_after_TA_assign(self):

        tester = models.User()
        tester.email = "*****@*****.**"
        tester.password = "******"
        tester.type = "TA"

        tester.save()
        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        lab = models.Lab()
        lab.TA = tester.email
        lab.course = course
        lab.lab_section = 499
        lab.save()

        self.assertEqual(Commands.delete_account("*****@*****.**"), "[email protected] has been deleted successfully")
        self.assertEqual(len(models.User.objects.filter(email="*****@*****.**")), 0)
        self.assertEqual(models.Lab.objects.get(lab_section=499).TA, "no TA")
    def test_add_one_course(self):
        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.course_department = "COMPSCI"
        course.course_id = "301"
        course.save()

        insCourse = models.InstructorCourse()
        insCourse.course = course
        insCourse.instructor = inst1
        insCourse.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'instructor'
        session.save()
        response = client.get('/view_course_assignments/')
        # status code 200, we loaded the correct page
        self.assertEqual(response.status_code, 200)
        # since we returned a render, it has all the content of the page
        # we'll just look for the header
        self.assertContains(response, "Courses Assigned to You:")
        all_messages = [msg for msg in get_messages(response.wsgi_request)]
        # no error messages
        info_string = str(all_messages[0])
        self.assertEqual(info_string, "COMPSCI: 301 \n")
        self.assertEqual(len(all_messages), 1)
    def test_improper_admin_ins(self):
        ad1 = models.User()
        ad1.email = "*****@*****.**"
        ad1.type = "administrator"
        ad1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'instructor'
        session.save()
        response = client.post('/assign_ta_lablec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA to Labs/Lectures")
        self.assertContains(response, "no such ta")
    def test_all_the_things(self):
        ad1 = models.User()
        ad1.email = "*****@*****.**"
        ad1.password = "******"
        ad1.type = "administrator"
        ad1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.password = "******"
        sup1.type = "supervisor"
        sup1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.password = "******"
        inst1.type = "instructor"
        inst1.save()

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.password = "******"
        ta1.type = "ta"
        ta1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.save()

        course2 = models.Course()
        course2.course_department = "COMPSCI"
        course2.course_id = "150"
        course2.save()

        lists = Commands.access_info()
        users = lists[0]
        self.assertTrue(ad1 in users)
        self.assertTrue(sup1 in users)
        self.assertTrue(inst1 in users)
        self.assertTrue(ta1 in users)
        courses = lists[1]
        self.assertTrue(course1 in courses)
        self.assertTrue(course2 in courses)
    def test_valid_double(self):
        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 2
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        lec2 = models.Lecture()
        lec2.course = course
        lec2.lecture_section = "402"
        lec2.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'supervisor'
        session.save()
        response = client.post('/assign_instructor_lec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign Instructor To Lecture")
        self.assertContains(response, "Instructor assigned to lecture")
        response = client.post('/assign_instructor_lec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "402"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign Instructor To Lecture")
        self.assertContains(response, "Instructor assigned to lecture")
    def test_not_assigned_to_course_ins(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        inst3 = models.User()
        inst3.email = "*****@*****.**"
        inst3.type = "instructor"
        inst3.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'instructor'
        session.save()
        response = client.post('/assign_ta_lablec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA to Labs/Lectures")
        self.assertContains(response, "You are not assigned to this course")
예제 #18
0
    def create_course(department, course_id, num_lectures, num_labs):
        good_dept = [
            "COMPSCI", "ELECENG", "PHYSICS", "MATH", "BIOMED", "CIVIL",
            "INDENG", "MATENG", "MECHENG", "STRUCENG", "WEBDEV"
        ]
        if department not in good_dept:
            return "That department is not offered"
        if not course_id.isdigit():
            return "Course ID must be a number"
        if int(course_id) < 101 or int(course_id) > 999:
            return "Course ID must be 3 digits long and between 101 and 999"
        if not num_labs.isdigit():
            return "Number of lab sections must be a number"
        if not num_lectures.isdigit():
            return "Number of lecture sections must be a number"
        if int(num_labs) < 0 or int(num_labs) > 5:
            return "Number of lab sections cannot be less than 0 or greater than 5"
        if int(num_lectures) < 1 or int(num_lectures) > 5:
            return "Number of lecture sections cannot be less than 1 or greater than 5"

        try:
            find_course = models.Course.objects.get(
                course_department=department, course_id=course_id)
        except models.Course.DoesNotExist:
            find_course = "none"
        if find_course != "none":
            return "Course already exists"

        some_course = models.Course()
        some_course.course_department = department
        some_course.course_id = course_id
        some_course.course_dept_id = department + str(course_id)
        some_course.num_lectures = num_lectures
        some_course.num_labs = num_labs
        some_course.save()

        for i in range(int(num_labs)):
            lab = models.Lab()
            lab.lab_section = 801 + i
            lab.course = some_course
            lab.save()

        for i in range(int(num_lectures)):
            lec = models.Lecture()
            if int(num_labs) == 0:
                temp = 1 + i
                lec.lecture_section = "00" + str(temp)
            else:
                lec.lecture_section = 401 + i
            lec.course = some_course
            lec.save()

        return "Course created successfully"
    def test_access_info_course(self):
        course1 = models.Course()
        course1.course_dept_id = "COMPSCI100"
        course1.instructor = "*****@*****.**"
        course1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()
        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "COMPSCI100")
 def test_assign_improper_course(self):
     ins1 = models.User()
     ins1.email = "*****@*****.**"
     ins1.type = "instructor"
     ins1.save()
     course = models.Course()
     course.num_labs = 2
     course.current_num_TA = 0
     course.num_lectures = 1
     course.instructor = "DEFAULT"
     course.course_id = "301"
     course.course_department = "COMPSCI"
     course.save()
     proper = Commands.assign_instructor_to_course(ins1.email, "302", course.course_department)
     self.assertEqual(proper, "no such course")
 def test_assign_instructor_admin(self):
     ad1 = models.User()
     ad1.email = "*****@*****.**"
     ad1.type = "administrator"
     ad1.save()
     course = models.Course()
     course.num_labs = 2
     course.current_num_TA = 0
     course.num_lectures = 1
     course.instructor = "DEFAULT"
     course.course_id = "301"
     course.course_department = "COMPSCI"
     course.save()
     proper = Commands.assign_instructor_to_course(ad1.email, course.course_id, course.course_department)
     self.assertEqual(proper, "no such instructor")
예제 #22
0
    def test_improper_admin_ins(self):
        ad1 = models.User()
        ad1.email = "*****@*****.**"
        ad1.type = "administrator"
        ad1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        response = Commands.assign_ta_to_lablec(inst1.email, ad1.email,
                                                course.course_id,
                                                lec.lecture_section,
                                                course.course_department)
        self.assertEqual(response, "no such ta")
 def test_assign_ta_sup(self):
     sup1 = models.User()
     sup1.email = "*****@*****.**"
     sup1.type = "supervisor"
     sup1.save()
     course = models.Course()
     course.num_labs = 2
     course.current_num_TA = 0
     course.num_lectures = 1
     course.instructor = "DEFAULT"
     course.course_id = "301"
     course.course_department = "COMPSCI"
     course.save()
     proper = Commands.assign_ta_to_course(sup1.email, course.course_id,
                                           course.course_department)
     self.assertEqual(proper, "no such ta")
    def setUp(self):
        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = 361
        course1.num_lectures = 1
        course1.num_labs = 1
        course1.save()

        lec1 = models.Lecture()
        lec1.course = course1
        lec1.lecture_section = "401"
        lec1.lecture_location = "Somewhere"
        lec1.lecture_time = datetime.time(12, 00)
        lec1.save()

        lab1 = models.Lecture()
        lab1.course = course1
        lab1.lab_section = "801"
        lab1.lab_location = "Somewhere"
        lab1.lab_time = datetime.time(12, 00)
        lab1.save()
    def test_access_info_inst_course_lecture_coursepage(self):

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.name = "Bob"
        inst1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.course_dept_id = "COMPSCI100"
        course1.instructor = "*****@*****.**"
        course1.num_lectures = 1
        course1.current_num_lectures = 1
        course1.save()

        inst1_course1 = models.InstructorCourse()
        inst1_course1.instructor = inst1
        inst1_course1.course = course1
        inst1_course1.save()

        lecture1 = models.Lecture()
        lecture1.instructor = "*****@*****.**"
        lecture1.course = course1
        lecture1.lecture_section = "401"
        lecture1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()

        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        response = client.get('/course/COMPSCI100/')
        self.assertContains(response, "Lectures")
        self.assertContains(response, "COMPSCI100-401")
    def test_access_info_ta_course_lab_coursepage(self):

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.name = "Ted"
        ta1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.course_dept_id = "COMPSCI100"
        course1.TA = "*****@*****.**"
        course1.num_labs = 1
        course1.current_num_labs = 1
        course1.save()

        ta1_course1 = models.TACourse()
        ta1_course1.TA = ta1
        ta1_course1.course = course1
        ta1_course1.save()

        lecture1 = models.Lab()
        lecture1.TA = "*****@*****.**"
        lecture1.course = course1
        lecture1.lab_section = "801"
        lecture1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()

        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        response = client.get('/course/COMPSCI100/')
        self.assertContains(response, "Labs")
        self.assertContains(response, "COMPSCI100-801")
예제 #27
0
    def test_assign_improper_ins_ins(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lab()
        lec.course = course
        lec.lab_section = "801"
        lec.save()
        response = Commands.assign_ta_to_lablec(inst1.email, inst1.email,
                                                course.course_id,
                                                lec.lab_section,
                                                course.course_department)
        self.assertEqual(response, "no such ta")
    def test_course_default_setup(self):
        ad1 = models.User()
        ad1.email = "*****@*****.**"
        ad1.password = "******"
        ad1.type = "administrator"
        ad1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.password = "******"
        sup1.type = "supervisor"
        sup1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.save()

        lists = Commands.access_info()
        users = lists[0]
        self.assertTrue(ad1 in users)
        self.assertTrue(sup1 in users)
        courses = lists[1]
        self.assertTrue(course1 in courses)
예제 #29
0
    def test_invalid_lec_assign_sup(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        response = Commands.assign_ta_to_lablec(sup1.email, ta1.email,
                                                course.course_id,
                                                lec.lecture_section,
                                                course.course_department)
        self.assertEqual(response,
                         "TA cannot be assigned to this lecture(labs exist)!")