Exemplo n.º 1
0
class CreateAccountTests(unittest.TestCase):
    def setUp(self):
        self.admin = Administrator("Admin", "*****@*****.**")
        self.account = Account("*****@*****.**", 12345)
        self.prof = Professor("Prof", "*****@*****.**")

    def test_create_account(self):
        #test that account is created correctly with username and password
        self.admin.createAccount(self.account)
        self.assertEqual(self.admin.accessData().account,
                         self.account,
                         msg="New account was not created successfully")

    def test_invalid_acc(self):
        #test that account is not created with incorrect username
        #and/or password
        with self.assertRaises(
                TypeError, msg="Admin creating an account with invalid input"):
            self.admin.createAccount(self.account)

    def test_existing_acc(self):
        #test that new account is not created if username correlates to
        #a pre-existing account
        self.assertEqual(
            self.admin.createAccount(),
            "Account has already been created",
            msg=
            "Incorrect error message when trying to create an account that already exists"
        )

    def test_create_acc_invalid_permissions(self):
        #test that only admin/supervisor can create account
        with self.assertRaises(PermissionError,
                               msg="Non-admin creating an account"):
            self.prof.createAccount(self.account)
 def setUp(self):
     self.admin = Admin()
     self.account = User.objects.create(name="name",
                                        email="*****@*****.**",
                                        password="******",
                                        type="P",
                                        phoneNumber=1234567,
                                        homeAddress="Milwaukee, WI")
     self.prof = Professor("Prof", "*****@*****.**")
Exemplo n.º 3
0
 def setUp(self):
     self.admin = Administrator("Admin", "*****@*****.**")
     self.inst = Professor("Inst", "*****@*****.**")
     self.ta = TA("TA", "*****@*****.**")
     self.course = Course("CS 361", [])
Exemplo n.º 4
0
    class AssignCourseTest(unittest.TestCase):
        def setUp(self):
            self.admin = Administrator("Admin", "*****@*****.**")
            self.inst = Professor("Inst", "*****@*****.**")
            self.ta = TA("TA", "*****@*****.**")
            self.course = Course("CS 361", [])

        def test_assign_inst(self):
            # test that instructor is correctly assigned to course by admin
            self.admin.assignProfessor(self.inst, self.course)
            self.assertEquals(
                self.inst.userID,
                self.course.professorID,
                msg="Failed to assign professor to course correctly")

        def test_assign_ta(self):
            # test that ta is correctly assigned to course by admin
            self.admin.assignTACourse(self.ta, self.course)
            self.assertTrue(self.ta.userID in self.course.taID,
                            msg="Failed to assign TA to course correctly")

        def test_assignprof_admin(self):
            # test that administrator cannot be assigned to course
            with assertRaises(
                    NameError,
                    msg=
                    "Failed to raise error when assigning admin with assignProfessor"
            ):
                self.admin.assignProfesor(self.admin)

        def test_assignta_admin(self):
            # test that administrator cannot be assigned to course
            with assertRaises(
                    NameError,
                    msg=
                    "Failed to raise error when assigning admin with assignTACourse"
            ):
                self.admin.assignTACourse(self.admin)

        def test_inst_assign_inst(self):
            # test that course cannot be assigned by instructor
            with self.assertRaises(
                    PermissionError,
                    msg=
                    "Instructor assigning instructor to coursefailed to raise error"
            ):
                self.inst.assignProfessor(self.inst, self.course)

        def test_inst_assign_ta(self):
            # test that course cannot be assigned by ta
            with self.assertRaises(
                    PermissionError,
                    msg=
                    "Instructor assigning ta to course failed to raise error"):
                self.inst.assignTACourse(self.ta, self.course)

        def test_ta_assign_inst(self):
            # test that course cannot be assigned by instructor
            with self.assertRaises(
                    PermissionError,
                    msg=
                    "TA assigning instructor to course failed to raise error"):
                self.ta.assignProfessor(self.inst, self.course)

        def test_ta_assign_ta(self):
            # test that course cannot be assigned by ta
            with self.assertRaises(
                    PermissionError,
                    msg="TA assigning ta to course failed to raise error"):
                self.ta.assignTACourse(self.ta, self.course)
Exemplo n.º 5
0
 def setUp(self):
     self.admin = Administrator("Admin", "*****@*****.**")
     self.account = Account("*****@*****.**", 12345)
     self.prof = Professor("Prof", "*****@*****.**")