def setUp(self):
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()
        self.mathSection = MySection(course=self.mathCourse, number=1)

        self.mathSection.save()
示例#2
0
class TestSectionModel(TestCase):
    def setUp(self):
        self.course1 = MyCourse(name="Introduction to Software Engineering",
                                number=361)
        self.course1.save()

        self.user1 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='ta')
        self.user1.save()

        self.section901 = MySection(number=901,
                                    course=self.course1,
                                    teacher=self.user1)
        self.section901.save()

        self.section902 = MySection(number=902, course=self.course1)
        self.section902.save()

    def test_section_str_with_teacher(self):
        self.assertEqual(self.section901.__str__(), "361-901")

    def test_section_str_without_teacher(self):
        self.assertEqual(self.section902.__str__(), "361-902")
class TestCourseCreation(TestCase):
    def setUp(self):
        self.client = Client()
        self.supervisor = MyUser(email="*****@*****.**",
                                 password='******',
                                 first_name="steve",
                                 last_name="miller",
                                 phone_number="(123)456-7890",
                                 address="123 Main St, Milwaukee, WI, 53211",
                                 role="supervisor")
        self.supervisor.save()

        self.course = MyCourse(name="Intro to Chemistry", number=102)
        self.course.save()

    def test_createNewCourse(self):

        r = self.client.post("/course/", {
            "name": "Math",
            "number": 100,
            "course_button": ''
        },
                             follow=True)
        self.assertEqual("Course successfully added", r.context['message'])

    def test_courseTaken(self):
        # course name is already used but not number
        r = self.client.post("/course/", {
            "name": self.course.name,
            "number": 103,
            "course_button": ''
        },
                             follow=True)
        print(r.context['message'])
        self.assertEqual(r.context['message'], "Course successfully added")

        # course number is already used but not name

        r = self.client.post("/course/", {
            "name": "CompSci",
            "number": 102,
            "course_button": ''
        },
                             follow=True)
        print(r.context['message'])
        self.assertEqual(r.context['message'], "Course successfully added")

        # course name and number are already used.

        r = self.client.post("/course/", {
            "name": self.course.name,
            "number": self.course.number,
            "course_button": ''
        },
                             follow=True)
        self.assertEqual(
            r.context['message'],
            "A course with this name and number has already been created.  Try again."
        )
示例#4
0
class TestSectionCreation(TestCase):
    def setUp(self):
        self.course1 = MyCourse(name="System Programming", number=337)
        self.course1.save()

        self.section1 = MySection(course=self.course1, number=901)
        self.section1.save()

    def test_create_section_number_used(self):
        self.assertEqual(
            create_section(self.course1, 901),
            "A section with this number within this course has already been created.  Try again."
        )

    def test_create_section_number_unused(self):
        self.assertIsInstance(create_section(self.course1, 801), MySection)

    def test_create_section_number_big(self):
        self.assertEqual(
            create_section(self.course1, 8098),
            "The section number is not 3 digits long.  Try again.")

    def test_create_section_number_small(self):
        self.assertEqual(
            create_section(self.course1, 83),
            "The section number is not 3 digits long.  Try again.")

    def test_create_section_first_param_not_course(self):
        with self.assertRaises(
                TypeError,
                msg=
                "The create_section() function must take a course object as its first argument"
        ):
            create_section("hello", 83)

    def test_create_section_second_param_not_int(self):
        with self.assertRaises(
                TypeError,
                msg=
                "The create_section() function must take an integer as its second argument"
        ):
            create_section(self.course1, "string")

    def test_create_section_too_many_args(self):
        with self.assertRaises(
                TypeError,
                msg="The create_section() function must take two arguments"):
            create_section(self.course1, 456, "third")

    def test_create_section_not_enough_args(self):
        with self.assertRaises(
                TypeError,
                msg="The create_section() function must take two arguments"):
            create_section(self.course1)
    def setUp(self):
        self.client = Client()
        self.supervisor = MyUser(email="*****@*****.**",
                                 password='******',
                                 first_name="steve",
                                 last_name="miller",
                                 phone_number="(123)456-7890",
                                 address="123 Main St, Milwaukee, WI, 53211",
                                 role="supervisor")
        self.supervisor.save()

        self.course = MyCourse(name="Intro to Chemistry", number=102)
        self.course.save()
示例#6
0
    def setUp(self):
        self.user1 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='supervisor')
        self.user1.save()

        self.user2 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='instructor')
        self.user2.save()

        self.user3 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='ta')
        self.user3.save()

        self.user4 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='')
        self.user4.save()

        self.course1 = MyCourse(name="System Programming", number=337)
        self.course1.save()

        self.section1 = MySection(course=self.course1, number=837)
        self.section1.save()

        self.section2 = MySection(course=self.course1, number=200)
        self.section2.save()

        self.section3 = MySection(course=self.course1, number=900)
        self.section3.save()

        self.section4 = MySection(course=self.course1, number=300)
        self.section4.save()
示例#7
0
class TestCourseCreation(TestCase):
    def setUp(self):
        self.course1 = MyCourse(name="System Programming", number=337)
        self.course1.save()

    def test_create_course_number_used(self):
        self.assertIsInstance(create_course("New Course", 337), MyCourse)

    def test_create_course_number_unused(self):
        self.assertIsInstance(create_course("Course1", 123), MyCourse)

    def test_create_course_number_big(self):
        self.assertEqual(
            create_course("Course2", 37),
            "The course number is not 3 digits long.  Try again.")

    def test_create_course_number_small(self):
        self.assertEqual(
            create_course("Course2", 5678),
            "The course number is not 3 digits long.  Try again.")

    def test_create_course_name_not_string(self):
        with self.assertRaises(
                TypeError,
                msg=
                "The first parameter in the create_course() function must be a string"
        ):
            create_course(123, 123)

    def test_create_course_number_not_int(self):
        with self.assertRaises(
                TypeError,
                msg=
                "The second parameter in the create_course() function must be an int"
        ):
            create_course("name of course", "second parameter")

    def test_create_course_not_enough_args(self):
        with self.assertRaises(
                TypeError,
                msg="The create_course() function must take 2 parameters"):
            create_course("name of course")

    def test_create_course_too_many_args(self):
        with self.assertRaises(
                TypeError,
                msg="The create_course() function must take 2 parameters"):
            create_course("name of course", 123, "arg3")
    def setUp(self):
        self.courses = MyCourse.objects.all()
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()
        self.labSection = MySection(course=self.mathCourse,
                                    number=800,
                                    teacher=None)
        self.lectureSection = MySection(course=self.mathCourse,
                                        number=201,
                                        teacher=None)
        self.labSection.save()
        self.lectureSection.save()

        self.newCourse = MyCourse(name="CS", number=150)
        self.newCourse.save()
class TestSectionCreation(TestCase):
    client = None
    courseList = None

    def setUp(self):
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()
        self.mathSection = MySection(course=self.mathCourse, number=1)

        self.mathSection.save()

    # number is not three digits
    def test_add_section_already_exists(self):
        c = self.client.session
        c["number"] = 1
        c.save

        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "section_number":
            self.mathSection.number,
            "section_button":
            ''
        },
                                follow=True)
        print(resp.context)
        self.assertEqual(
            "The section number is not 3 digits long.  Try again.",
            resp.context["message"])

    def test_add_section(self):

        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "section_number":
            400,
            "section_button":
            ''
        },
                                follow=True)
        print(resp.context)
        self.assertEqual("Section successfully added", resp.context["message"])
    def setUp(self):
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()

        self.instructor = MyUser(first_name="instructor",
                                 last_name="super",
                                 email="*****@*****.**",
                                 password='******',
                                 address="123 straight st",
                                 phone_number="1234567890",
                                 role='instructor')

        self.instructor2 = MyUser(first_name="instructor2",
                                  last_name="super2",
                                  email="*****@*****.**",
                                  password='******',
                                  address="123 straight st",
                                  phone_number="1234567890",
                                  role='instructor')

        self.ta = MyUser.objects.create(first_name="ta",
                                        last_name="assist",
                                        email="*****@*****.**",
                                        password="******",
                                        address="123 round st",
                                        phone_number="1234567890",
                                        role="ta")

        self.ta2 = MyUser.objects.create(first_name="ta2",
                                         last_name="assist",
                                         email="*****@*****.**",
                                         password="******",
                                         address="123 round st",
                                         phone_number="1234567890",
                                         role="ta")

        self.instructor.save()
        self.ta.save()
        self.instructor2.save()
        self.ta2.save()
示例#11
0
    def setUp(self):
        self.course1 = MyCourse(name="Introduction to Software Engineering",
                                number=361)
        self.course1.save()

        self.user1 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='ta')
        self.user1.save()

        self.section901 = MySection(number=901,
                                    course=self.course1,
                                    teacher=self.user1)
        self.section901.save()

        self.section902 = MySection(number=902, course=self.course1)
        self.section902.save()
class TestDeleteCourse(TestCase):
    def setUp(self):
        self.courses = MyCourse.objects.all()
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()
        self.labSection = MySection(course=self.mathCourse,
                                    number=800,
                                    teacher=None)
        self.lectureSection = MySection(course=self.mathCourse,
                                        number=301,
                                        teacher=None)
        self.labSection.save()
        self.lectureSection.save()

        self.newCourse = MyCourse(name="CS", number=150)
        self.newCourse.save()

    def test_delete_course_no_sections(self):
        resp = self.client.post("/course/", {
            "course_to_remove": self.newCourse.id,
            "delCButt": ''
        },
                                follow=True)
        self.assertNotIn(self.newCourse, resp.context['courses'])
        self.assertEqual("Course successfully deleted",
                         resp.context['message'])

    def test_delete_course_with_section(self):
        resp = self.client.post("/course/", {
            "course_to_remove": self.mathCourse.id,
            "delCButt": ''
        },
                                follow=True)

        self.assertNotIn(self.mathCourse, resp.context['courses'])
        self.assertEqual("Course successfully deleted",
                         resp.context['message'])
示例#13
0
    def setUp(self):
        self.course1 = MyCourse(name="Introduction to Software Engineering",
                                number=361)
        self.course1.save()

        self.course2 = MyCourse(name="Course", number=111)
        self.course2.save()

        self.user1 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='ta')
        self.user1.save()

        self.course3 = MyCourse(name="Third Course", number=222)
        self.course3.save()
        self.course3.people.add(self.user1)
        self.course3.save()
class TestAssignToCourse(TestCase):
    def setUp(self):
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()

        self.instructor = MyUser(first_name="instructor",
                                 last_name="super",
                                 email="*****@*****.**",
                                 password='******',
                                 address="123 straight st",
                                 phone_number="1234567890",
                                 role='instructor')

        self.instructor2 = MyUser(first_name="instructor2",
                                  last_name="super2",
                                  email="*****@*****.**",
                                  password='******',
                                  address="123 straight st",
                                  phone_number="1234567890",
                                  role='instructor')

        self.ta = MyUser.objects.create(first_name="ta",
                                        last_name="assist",
                                        email="*****@*****.**",
                                        password="******",
                                        address="123 round st",
                                        phone_number="1234567890",
                                        role="ta")

        self.ta2 = MyUser.objects.create(first_name="ta2",
                                         last_name="assist",
                                         email="*****@*****.**",
                                         password="******",
                                         address="123 round st",
                                         phone_number="1234567890",
                                         role="ta")

        self.instructor.save()
        self.ta.save()
        self.instructor2.save()
        self.ta2.save()

    def test_assign_instructor_to_course(self):
        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "person_selection":
            MyUser.objects.get(email=self.instructor.email).id,
            "ass_butt":
            ''
        },
                                follow=True)

        self.assertEqual("Course assignments updated", resp.context["message"])

    def test_assign_ta_to_course(self):
        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "person_selection":
            MyUser.objects.get(email=self.ta.email).id,
            "ass_butt":
            ''
        },
                                follow=True)

        self.assertEqual("Course assignments updated", resp.context["message"])

    def test_assign_multiple_assignments(self):
        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "person_selection":
            MyUser.objects.get(email=self.instructor.email).id,
            "ass_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Course assignments updated", resp.context["message"])

        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "person_selection":
            MyUser.objects.get(email=self.instructor2.email).id,
            "ass_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Course assignments updated", resp.context["message"])

        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "person_selection":
            MyUser.objects.get(email=self.ta.email).id,
            "ass_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Course assignments updated", resp.context["message"])

        resp = self.client.post("/course/", {
            "course_selection":
            MyCourse.objects.get(name=self.mathCourse.name,
                                 number=self.mathCourse.number).id,
            "person_selection":
            MyUser.objects.get(email=self.ta2.email).id,
            "ass_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Course assignments updated", resp.context["message"])
示例#15
0
    def setUp(self):
        self.course1 = MyCourse(name="System Programming", number=337)
        self.course1.save()

        self.section1 = MySection(course=self.course1, number=901)
        self.section1.save()
示例#16
0
class TestCourseModel(TestCase):
    def setUp(self):
        self.course1 = MyCourse(name="Introduction to Software Engineering",
                                number=361)
        self.course1.save()

        self.course2 = MyCourse(name="Course", number=111)
        self.course2.save()

        self.user1 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='ta')
        self.user1.save()

        self.course3 = MyCourse(name="Third Course", number=222)
        self.course3.save()
        self.course3.people.add(self.user1)
        self.course3.save()

    def test_course_str_long(self):
        self.assertEqual(self.course1.__str__(),
                         "Introduction to Software Engineering")

    def test_course_str_short(self):
        self.assertEqual(self.course2.__str__(), "Course")

    def test_course_str_with_user(self):
        self.assertEqual(self.course3.__str__(), "Third Course")
示例#17
0
class TestValidTeacherForSection(TestCase):
    def setUp(self):
        self.user1 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='supervisor')
        self.user1.save()

        self.user2 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='instructor')
        self.user2.save()

        self.user3 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='ta')
        self.user3.save()

        self.user4 = MyUser.objects.create(email='*****@*****.**',
                                           password='******',
                                           first_name='joe',
                                           last_name='johnson',
                                           address='123 main st.',
                                           phone_number='123',
                                           role='')
        self.user4.save()

        self.course1 = MyCourse(name="System Programming", number=337)
        self.course1.save()

        self.section1 = MySection(course=self.course1, number=837)
        self.section1.save()

        self.section2 = MySection(course=self.course1, number=200)
        self.section2.save()

        self.section3 = MySection(course=self.course1, number=900)
        self.section3.save()

        self.section4 = MySection(course=self.course1, number=300)
        self.section4.save()

    #user2 = instructor
    #user3 = ta
    def test_valid_ta_and_valid_lab_section(self):
        self.assertTrue(ValidTeacherForSection(self.user3, self.section1))
        self.assertTrue(ValidTeacherForSection(self.user3, self.section3))

    def test_valid_instructor_to_lecture_section(self):
        self.assertTrue(ValidTeacherForSection(self.user2, self.section2))
        self.assertTrue(ValidTeacherForSection(self.user2, self.section4))

    def test_valid_ta_and_invalid_section(self):
        self.assertTrue(ValidTeacherForSection(self.user3, self.section2))
        self.assertTrue(ValidTeacherForSection(self.user3, self.section4))

    def test_valid_instructor_and_invalid_section(self):
        self.assertTrue(ValidTeacherForSection(self.user2, self.section1))
        self.assertTrue(ValidTeacherForSection(self.user2, self.section3))

    def test_invalid_role_and_valid_section(self):
        self.assertTrue(ValidTeacherForSection(self.user1, self.section3))

    def test_no_role_and_valid_section(self):
        self.assertTrue(ValidTeacherForSection(self.user4, self.section3))

    def test_not_MyUser(self):
        with self.assertRaises(TypeError):
            ValidTeacherForSection(self.section1, self.section1)

    def test_not_MySection(self):
        with self.assertRaises(TypeError):
            ValidTeacherForSection(self.user3, self.user3)

    def test_not_enough_args(self):
        with self.assertRaises(TypeError):
            ValidTeacherForSection(self.user3)

    def test_too_many_args(self):
        with self.assertRaises(TypeError):
            ValidTeacherForSection(self.user3, self.user3, self.user3)
    def setUp(self):
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()
        self.labSection = MySection(course=self.mathCourse,
                                    number=800,
                                    teacher=None)
        self.lectureSection = MySection(course=self.mathCourse,
                                        number=301,
                                        teacher=None)
        self.labSection.save()
        self.lectureSection.save()

        self.supervisor = MyUser(first_name="supervisor",
                                 last_name="super",
                                 email="*****@*****.**",
                                 password="******",
                                 address="123 straight st",
                                 phone_number="1234567890",
                                 role="supervisor")

        self.instructor = MyUser(first_name="instructor",
                                 last_name="super",
                                 email="*****@*****.**",
                                 password='******',
                                 address="123 straight st",
                                 phone_number="1234567890",
                                 role='instructor')

        self.instructor2 = MyUser(first_name="instructor2",
                                  last_name="super2",
                                  email="*****@*****.**",
                                  password='******',
                                  address="123 straight st",
                                  phone_number="1234567890",
                                  role='instructor')

        self.ta = MyUser.objects.create(first_name="ta",
                                        last_name="assist",
                                        email="*****@*****.**",
                                        password="******",
                                        address="123 round st",
                                        phone_number="1234567890",
                                        role="ta")

        self.ta2 = MyUser.objects.create(first_name="ta2",
                                         last_name="assist",
                                         email="*****@*****.**",
                                         password="******",
                                         address="123 round st",
                                         phone_number="1234567890",
                                         role="ta")

        self.instructor.save()
        self.ta.save()
        self.instructor2.save()
        self.ta2.save()
        self.supervisor.save()

        self.labSection2 = MySection(course=self.mathCourse,
                                     number=801,
                                     teacher=self.ta2)
        self.lectureSection2 = MySection(course=self.mathCourse,
                                         number=302,
                                         teacher=self.instructor2)
        self.labSection2.save()
        self.lectureSection2.save()
class TestAssignToSection(TestCase):
    def setUp(self):
        self.client = Client()
        self.mathCourse = MyCourse(name="Math", number=100)
        self.mathCourse.save()
        self.labSection = MySection(course=self.mathCourse,
                                    number=800,
                                    teacher=None)
        self.lectureSection = MySection(course=self.mathCourse,
                                        number=301,
                                        teacher=None)
        self.labSection.save()
        self.lectureSection.save()

        self.supervisor = MyUser(first_name="supervisor",
                                 last_name="super",
                                 email="*****@*****.**",
                                 password="******",
                                 address="123 straight st",
                                 phone_number="1234567890",
                                 role="supervisor")

        self.instructor = MyUser(first_name="instructor",
                                 last_name="super",
                                 email="*****@*****.**",
                                 password='******',
                                 address="123 straight st",
                                 phone_number="1234567890",
                                 role='instructor')

        self.instructor2 = MyUser(first_name="instructor2",
                                  last_name="super2",
                                  email="*****@*****.**",
                                  password='******',
                                  address="123 straight st",
                                  phone_number="1234567890",
                                  role='instructor')

        self.ta = MyUser.objects.create(first_name="ta",
                                        last_name="assist",
                                        email="*****@*****.**",
                                        password="******",
                                        address="123 round st",
                                        phone_number="1234567890",
                                        role="ta")

        self.ta2 = MyUser.objects.create(first_name="ta2",
                                         last_name="assist",
                                         email="*****@*****.**",
                                         password="******",
                                         address="123 round st",
                                         phone_number="1234567890",
                                         role="ta")

        self.instructor.save()
        self.ta.save()
        self.instructor2.save()
        self.ta2.save()
        self.supervisor.save()

        self.labSection2 = MySection(course=self.mathCourse,
                                     number=801,
                                     teacher=self.ta2)
        self.lectureSection2 = MySection(course=self.mathCourse,
                                         number=302,
                                         teacher=self.instructor2)
        self.labSection2.save()
        self.lectureSection2.save()

    def test_assign_ta_to_lecture_fails(self):
        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.lectureSection.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.ta.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual(
            "Only Instructors can be assigned to lecture sections.",
            resp.context["message"])

    def test_assign_ta_to_empty_lab(self):
        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.labSection.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.ta.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Added Teacher to section.", resp.context["message"])

    def test_assign_ta_to_ta_lab(self):

        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.labSection2.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.ta.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual(
            "Teacher: ta2 assist was removed.\nTeacher: ta assist was added.",
            resp.context["message"])

    def test_assign_instructor_to_empty_lecture(self):
        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.lectureSection.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.instructor.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Added Teacher to section.", resp.context["message"])

    def test_assign_instructor_to_instructor_lecture(self):
        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.lectureSection2.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.instructor.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual(
            "Teacher: instructor2 super2 was removed.\nTeacher: instructor super was added.",
            resp.context["message"])

    def test_assign_instructor_to_lab_fails(self):
        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.labSection.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.instructor.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Only TAs can be assigned to lab sections.",
                         resp.context["message"])

    def test_assign_supervisor_to_section_fails(self):
        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.labSection.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.supervisor.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual("Only TAs can be assigned to lab sections.",
                         resp.context["message"])

        resp = self.client.post("/course/", {
            "section_selection":
            MySection.objects.get(number=self.lectureSection.number,
                                  course=self.mathCourse).id,
            "person_selection":
            MyUser.objects.get(email=self.supervisor.email).id,
            "ass_section_butt":
            ''
        },
                                follow=True)
        self.assertEqual(
            "Only Instructors can be assigned to lecture sections.",
            resp.context["message"])
示例#20
0
 def setUp(self):
     self.course1 = MyCourse(name="System Programming", number=337)
     self.course1.save()