예제 #1
0
    def test_viewContactInfo(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)

        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)

        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)
        userdata4 = USER.objects.get(username="******")
        user4 = User.User(userdata4.permission, userdata4.username,
                          userdata4.password, userdata4.id, userdata4.email,
                          userdata4.firstName, userdata4.lastName,
                          userdata4.contactPhone, userdata4.officePhone,
                          userdata4.extension)

        self.user = user
        self.assertEqual(
            Terminal.viewContactInfo(self),
            str(user.permission) + " " + user.username + " " + user.password +
            " " + str(user.databaseID) + " " + user.email + " " +
            user.firstName + " " + user.lastName + " " + user.contactPhone +
            " " + user.officePhone + " " + user.extension)
        self.user = user2
        self.assertEqual(
            Terminal.viewContactInfo(self),
            user2.permission + " " + user2.username + " " + user2.password +
            " " + user2.databaseID + " " + user2.email + " " +
            user2.firstName + " " + user2.lastName + " " + user2.contactPhone +
            " " + user2.officePhone + " " + user2.extension)
        self.user = user3
        self.assertEqual(
            Terminal.viewContactInfo(self),
            user3.permission + " " + user3.username + " " + user3.password +
            " " + user3.databaseID + " " + user3.email + " " +
            user3.firstName + " " + user3.lastName + " " + user3.contactPhone +
            " " + user3.officePhone + " " + user3.extension)

        self.user = user4
        self.assertEqual(
            Terminal.viewContactInfo(user4.databaseID),
            user4.permission + " " + user4.username + " " + user4.password +
            " " + user4.databaseID + " " + user4.email + " " +
            user4.firstName + " " + user4.lastName + " " + user4.contactPhone +
            " " + user4.officePhone + " " + user4.extension)

        self.assertEqual(Terminal.viewContactInfo('fvs'), "Invalid UserID")
        self.assertEqual(Terminal.viewContactInfo('234'), "User Not Found")
예제 #2
0
    def test_viewCourseAssignments(self):

        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)
        userdata4 = USER.objects.get(username="******")
        user4 = User.User(userdata4.permission, userdata4.username,
                          userdata4.password, userdata4.id, userdata4.email,
                          userdata4.firstName, userdata4.lastName,
                          userdata4.contactPhone, userdata4.officePhone,
                          userdata4.extension)

        courseData = COURSE.objects.get(courseNumber=500)
        course = Course.Course(courseData.id, courseData.name,
                               courseData.courseNumber, courseData.classNumber,
                               courseData.time, courseData.location)
        self.assertTrue(user3.permission == 3)
        self.assertTrue((user4.permission != 4),
                        "Not Authorized To Use This Command")
        self.assertEqual(Terminal.viewCourseAssignments(userdata4.databaseID),
                         "User is not an Instructor")
        self.assertEqual(Terminal.viewCourseAssignments(user3.databaseID),
                         course.name)
        self.assertEqual(Terminal.viewCourseAssignments('1332'),
                         "User not found")
        self.assertEqual(Terminal.viewCourseAssignments('qakbd'),
                         "Invalid UserId")
예제 #3
0
    def test_deleteAccount(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)
        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)

        self.assertTrue(user.permission[1] == '1')
        self.assertTrue(user2.permission[1] == '2')
        self.assertTrue(user3.permission[1] != '1',
                        "Not Authorized To Use This Command")
        self.assertTrue(user2.permission == '2',
                        "Not Authorized To Use This Command")
        self.assertEqual(Terminal.deleteAccount('314351'), "User Not Found")
        self.assertEqual(Terminal.deleteAccount(user.databaseID),
                         "Account Deleted")
예제 #4
0
    def test_editAccount(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)
        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)

        self.assertTrue(user.permission[1] == 1)
        self.assertTrue(user2.permission[1] == 2)
        self.assertTrue((user3.permission[1] != 1 & user2.permission == 2),
                        "Not Authorized To Use This Command")

        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        self.assertEqual(Terminal.editAccount(user.databaseID),
                         "What Would You Like To Edit?")
        self.assertEqual(Terminal.editAccount('231231'), "User Not Found")
예제 #5
0
    def test_toString(self):
        user = User([1, 2], "username", "password", 45, "*****@*****.**",
                    "first name", "last name", "4142223333")
        userString = user.toString()

        self.assertEquals(
            "[1,2][email protected]$first name$last name$4142223333",
            userString)

        user = User([1], "username", "password", 45, "*****@*****.**",
                    "first name", "last name", "4142223333", "4142221111")
        userString = user.toString()

        self.assertEquals(
            "[1][email protected]$first name$last name$4142223333$4142221111",
            userString)

        user = User([1], "username", "password", 45, "*****@*****.**",
                    "first name", "last name", "4142223333", "4142221111",
                    "325")
        userString = user.toString()

        self.assertEquals(
            "[1][email protected]$first name$last name$4142223333$4142221111$325",
            userString)
예제 #6
0
    def test_getPermission(self):
        user = User(permission=[1, 3])
        self.assertEquals([1, 3], user.getPermission())

        user = User(permission=None)
        self.assertEquals(None, user.getPermission())

        user = User(permission=[])
        self.assertEquals(None, user.getPermission())
예제 #7
0
    def test_assignInstructorToCourse(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)

        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)
        userdata4 = USER.objects.get(username="******")
        user4 = User.User(userdata4.permission, userdata4.username,
                          userdata4.password, userdata4.id, userdata4.email,
                          userdata4.firstName, userdata4.lastName,
                          userdata4.contactPhone, userdata4.officePhone,
                          userdata4.extension)
        self.assertTrue((user.permission[1] == '1'),
                        "Not Authorized To Use This Command")
        self.assertTrue((user2.permission[1] != '1'),
                        "Not Authorized To Use This Command")
        self.assertTrue((user3.permission[1] != '1'),
                        "Not Authorized To Use This Command")
        self.assertTrue((user4.permission[1] != '1'),
                        "Not Authorized To Use This Command")

        courseData = COURSE.objects.get(courseNumber=500)
        course = Course.Course(courseData.id, courseData.name,
                               courseData.courseNumber, courseData.classNumber,
                               courseData.time, courseData.location)
        self.user = user
        self.assertEqual(
            Terminal.assignInstructorToCourse(self, course.databaseID,
                                              user.databaseID),
            user.firstName + " " + user.lastName + " was added to " +
            course.name)
        self.assertEqual(
            Terminal.assignInstructorToCourse(self, '234', user.databaseID),
            "Course not found")
        self.assertEqual(
            Terminal.assignInstructorToCourse(self, course.databaseID, '23'),
            "User not found")
예제 #8
0
 def test_logout(self):
     userdata = USER.objects.get(username="******")
     user = User.User(userdata.permission, userdata.username,
                      userdata.password, userdata.id, userdata.email,
                      userdata.firstName, userdata.lastName,
                      userdata.contactPhone, userdata.officePhone,
                      userdata.extension)
     Terminal.login(user, user.username, user.password)
     self.assertEquals(Terminal.logout(user), "Successfully Logged Out")
예제 #9
0
    def test_email(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)
        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)
        userdata4 = USER.objects.get(username="******")
        user4 = User.User(userdata4.permission, userdata4.username,
                          userdata4.password, userdata4.id, userdata4.email,
                          userdata4.firstName, userdata4.lastName,
                          userdata4.contactPhone, userdata4.officePhone,
                          userdata4.extension)
        print(user.permission[1])
        self.assertTrue(user.permission[1] == '1' or user.permission[1] == '2'
                        or user.permission[1] == '3')
        self.assertTrue(user2.permission[1] == '1'
                        or user2.permission[1] == '2'
                        or user2.permission[1] == '3')
        self.assertTrue(user3.permission[1] == '1'
                        or user3.permission[1] == '2'
                        or user3.permission[1] == '3')
        self.assertTrue(
            (user4.permission[1] != '1' and user4.permission[1] == '2'
             and user4.permission[1] == '3'),
            "Not Authorized To Use This Command")

        #SHould we have a user present with the wrong permissions so we can have a fail scenario?
        self.assertEqual(Terminal.email("Hello World"), "Message Sent")
예제 #10
0
 def test_login(self):
     userdata = USER.objects.get(username="******")
     user = User.User(userdata.permission, userdata.username,
                      userdata.password, userdata.id, userdata.email,
                      userdata.firstName, userdata.lastName,
                      userdata.contactPhone, userdata.officePhone,
                      userdata.extension)
     self.assertEquals(Terminal.login(user, user.username, user.password),
                       "Login Successful")
     self.assertEquals(Terminal.login(user, user.username, 'wrong'),
                       "Invalid Login")
     self.assertEquals(Terminal.login('IPPPO', user.password),
                       "Invalid Login")
     self.assertEquals(Terminal.login('IPPPPOOOOO', 'wronggggggg'),
                       "Invalid Login")
예제 #11
0
    def login(self, xName, xPassword):

        try:
            userData = USER.objects.get(username=xName)
        except USER.DoesNotExist:
            return "Invalid username or password", False

        if(userData.password == xPassword):
            self.user = User.User(userData.permission, userData.username, userData.password,
                                  userData.id, userData.email, userData.firstName, userData.lastName,
                                  userData.contactPhone, userData.officePhone, userData.extension)
            self.username = self.user.username
        else:
            return "Invalid username or password", False
        return "Logged in as: " + self.username, True
예제 #12
0
    def test_fromString(self):
        userString = "[1,2][email protected]$first name$last name$4142223333"

        user = User.fromString(userString)

        self.assertEquals([1, 2], user.permission)
        self.assertEquals('username', user.username)
        self.assertEquals('password', user.password)
        self.assertEquals(45, user.databaseID)
        self.assertEquals("*****@*****.**", user.email)
        self.assertEquals("first name", user.firstName)
        self.assertEquals("last name", user.lastName)
        self.assertEquals("4142223333", user.contactPhone)

        userString = "[1,2][email protected]$first name$last name$4142223333$4142221111"
        user.fromString(userString)

        self.assertEquals([1, 2], user.permission)
        self.assertEquals('username', user.username)
        self.assertEquals('password', user.password)
        self.assertEquals(45, user.databaseID)
        self.assertEquals("*****@*****.**", user.email)
        self.assertEquals("first name", user.firstName)
        self.assertEquals("last name", user.lastName)
        self.assertEquals("4142223333", user.contactPhone)
        self.assertEquals("4142221111", user.contactPhone)

        userString = "[1][email protected]$first name$last name$4142223333$4142221111$325"
        user.fromString(userString)

        self.assertEquals([1], user.permission)
        self.assertEquals('username', user.username)
        self.assertEquals('password', user.password)
        self.assertEquals(45, user.databaseID)
        self.assertEquals("*****@*****.**", user.email)
        self.assertEquals("first name", user.firstName)
        self.assertEquals("last name", user.lastName)
        self.assertEquals("4142223333", user.contactPhone)
        self.assertEquals("4142221111", user.contactPhone)
        self.assertEquals("325", user.contactPhone)
예제 #13
0
    def test_createAccount(self):
        userdata = USER.objects.get(username="******")
        user = User.User(userdata.permission, userdata.username,
                         userdata.password, userdata.id, userdata.email,
                         userdata.firstName, userdata.lastName,
                         userdata.contactPhone, userdata.officePhone,
                         userdata.extension)
        userdata2 = USER.objects.get(username="******")
        user2 = User.User(userdata2.permission, userdata2.username,
                          userdata2.password, userdata2.id, userdata2.email,
                          userdata2.firstName, userdata2.lastName,
                          userdata2.contactPhone, userdata2.officePhone,
                          userdata2.extension)
        userdata3 = USER.objects.get(username="******")
        user3 = User.User(userdata3.permission, userdata3.username,
                          userdata3.password, userdata3.id, userdata3.email,
                          userdata3.firstName, userdata3.lastName,
                          userdata3.contactPhone, userdata3.officePhone,
                          userdata3.extension)
        self.user = user2
        self.assertTrue(user.permission[1] == '1')
        self.assertTrue(user2.permission[1] != '1')
        self.assertTrue(user2.permission[1] == '2',
                        "Not Authorized To Use This Command")
        self.assertTrue(user3.permission[1] != '1')

        self.assertEquals(
            Terminal.createAccount(self, '2', 'jjj', '123', '*****@*****.**',
                                   'John', 'Aponte', '2011111111',
                                   '2012222222', '47'), "New user created")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'jjj', 'aaa', '*****@*****.**',
                                   'John', 'Aponte', '2011111111',
                                   '2012222222', '47'),
            "Account Already Exists")

        self.assertEqual(
            Terminal.createAccount(self, '4', 'bbb', 'ccc', '*****@*****.**',
                                   'John', 'Aponte', '2033333333',
                                   '2044444444', '48'), "New user created")

        self.assertEqual(
            Terminal.createAccount(self, '2', 'bbb', 'ccc', '*****@*****.**',
                                   'Hn', 'Te', '2055555555', '2066666666',
                                   '49'), "Username Already Exist")

        self.assertEqual(
            Terminal.createAccount(self, '1', 'eee', 'zzz', '*****@*****.**',
                                   'Jo', 'Ap', '2066666666', '207777777',
                                   '48'), "Email Already In Use")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**',
                                   'Doom', 'Kek', '2066666666', '2044444444',
                                   '48'), "Phone Number Already in Use")

        self.assertEqual(
            Terminal.createAccount(self, '0', 'hhh', 'yyy', '*****@*****.**',
                                   'Doom', 'Kek', '2066666666', '2044444444',
                                   '48'), "Invalid Permission")

        self.assertEqual(
            Terminal.createAccount(self, '5', 'hhh', 'yyy', '*****@*****.**',
                                   'Doom', 'Kek', '2066666666', '2044444444',
                                   '48'), "Invalid Permission")

        self.assertEqual(
            Terminal.createAccount(self, '3', '', 'yyy', '*****@*****.**',
                                   'Doom', 'Kek', '2066666666', '2044444444',
                                   '48'), "Invalid Username")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', '', '*****@*****.**',
                                   'Doom', 'Kek', '2066666666', '2044444444',
                                   '48'), "Invalid Password")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', 'dfsiahfilnwefr',
                                   'Doom', 'Kek', '2066666666', '2044444444',
                                   '48'), "Invalid Email")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', '', 'Doom', 'Kek',
                                   '2066666666', '2044444444', '48'),
            "Invalid Email")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**',
                                   '', 'Kek', '2066666666', '2044444444',
                                   '48'), "Must Enter Valid Name")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**',
                                   'Doom', '', '2066666666', '2044444444',
                                   '48'), "Must Enter Valid Name")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**',
                                   'Doom', 'Kek', '4535387478347874878247',
                                   '2044444444', '48'), "Invalid Phone Number")

        self.assertEqual(
            Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**',
                                   'Doom', 'Kek', '12334', '2044444444', '48'),
            "Invalid Phone Number")

        # Instead of having a general error, have the errors listed by the order of their fault. ex: the username in the
        # first error so it would spit out "Invalid username", then once its fixed, it would spit out "Invalid Email"
        self.assertEqual(
            Terminal.createAccount(self, '3', ' ', 'yyy',
                                   '*****@*****.**',
                                   'Do2om', '11', '2063242342346666666',
                                   '204444444423244', '4238'),
            "Multiple Invalid Credentials")
예제 #14
0
    def test_setExtension(self):
        user = User()

        user.setExtension("325")
        self.assertEquals("325", user.extension)

        with self.asserRaises(ValueError):
            user.setExtension(True)
            user.setExtension(1)
            user.setExtension(1, "this")
            user.setExtension({})
            user.setExtension(35)
            user.setExtension(4.5)
            user.setExtension([42])
            user.setExtension("222       333334444444")
            user.setExtension("number")
            user.setExtension(325)
예제 #15
0
    def test_setOfficePhone(self):
        user = User()

        user.setOfficePhone("2223334444")
        self.assertEquals("2223334444", user.officePhone)

        with self.asserRaises(ValueError):
            user.setOfficePhone(True)
            user.setOfficePhone(1)
            user.setOfficePhone(1, "this")
            user.setOfficePhone({})
            user.setOfficePhone(35)
            user.setOfficePhone(4.5)
            user.setOfficePhone([42])
            user.setOfficePhone("222       333334444444")
            user.setOfficePhone("number")
            user.setOfficePhone(2223334444)
예제 #16
0
    def test_setLastName(self):
        user = User()

        user.setLastName("John")
        self.assertEquals("John", user.lastName)

        with self.asserRaises(ValueError):
            user.setLastName(True)
            user.setLastName(1)
            user.setLastName(1, "this")
            user.setLastName({})
            user.setLastName(35)
            user.setLastName(4.5)
            user.setLastName([42])
예제 #17
0
    def test_setEmail(self):
        user = User()

        user.setEmail("*****@*****.**")
        self.assertEquals("*****@*****.**", user.emai)

        with self.asserRaises(ValueError):
            user.setEmail(True)
            user.setEmail(1)
            user.setEmail(1, "this")
            user.setEmail({})
            user.setEmail(35)
            user.setEmail(4.5)
            user.setEmail([42])
            user.setEmail('this')
            user.setEmail("this@")
            user.setEmail("this@ ")
            user.setEmail("@gmail.com")
예제 #18
0
    def test_getLastName(self):
        user = User(lastName="Doe")
        self.assertEquals("Doe", user.getLastName())

        user = User(lastName=None)
        self.assertEquals(None, user.getLastName())
예제 #19
0
    def test_getPassword(self):
        user = User(password="******")
        self.assertEquals("password", user.getPassword())

        user = User(password=None)
        self.assertEquals(None, user.getPassword())
예제 #20
0
    def test_setPermission(self):
        user = User()

        user.setPermission([1])
        self.assertEquals([1], user.permission)

        user.setPermission([1, 2])
        self.asserEquals([1, 2], user.permission)

        with self.asserRaises(ValueError):
            user.setPermission(True)
            user.setPermission(1)
            user.setPermission(1, "this")
            user.setPermission("this")
            user.setPermission({})
            user.setPermission(35)
            user.setPermission('raw')
            user.setPermission(4.5)
            user.setPermission([42])
            user.setPermission([-42])
예제 #21
0
    def test_getDatabaseID(self):
        user = User(databaseID=12)
        self.assertEquals(12, user.getDatabaseID())

        user = User(databaseID=None)
        self.assertEquals(None, user.getDatabaseID())
예제 #22
0
    def test_getExtension(self):
        user = User(extension="325")
        self.assertEquals("325", user.getExtension())

        user = User(extension=None)
        self.assertEquals(None, user.getExtension())
예제 #23
0
    def test_getContactPhone(self):
        user = User(contactPhone="2223334444")
        self.assertEquals("2223334444", user.getContactPhone())

        user = User(contactPhone=None)
        self.assertEquals(None, user.getContactPhone())
예제 #24
0
    def test_getEmail(self):
        user = User(email="*****@*****.**")
        self.assertEquals("*****@*****.**", user.getEmail())

        user = User(email=None)
        self.assertEquals(None, user.getEmail())
예제 #25
0
 def test_accessData(self):
     userdata = USER.objects.get(username="******")
     user = User.User(userdata.permission, userdata.username,
                      userdata.password, userdata.id, userdata.email,
                      userdata.firstName, userdata.lastName,
                      userdata.contactPhone, userdata.officePhone,
                      userdata.extension)
     userdata2 = USER.objects.get(username="******")
     user2 = User.User(userdata2.permission, userdata2.username,
                       userdata2.password, userdata2.id, userdata2.email,
                       userdata2.firstName, userdata2.lastName,
                       userdata2.contactPhone, userdata2.officePhone,
                       userdata2.extension)
     userdata3 = USER.objects.get(username="******")
     user3 = User.User(userdata3.permission, userdata3.username,
                       userdata3.password, userdata3.id, userdata3.email,
                       userdata3.firstName, userdata3.lastName,
                       userdata3.contactPhone, userdata3.officePhone,
                       userdata3.extension)
     userdata4 = USER.objects.get(username="******")
     user4 = User.User(userdata4.permission, userdata4.username,
                       userdata4.password, userdata4.id, userdata4.email,
                       userdata4.firstName, userdata4.lastName,
                       userdata4.contactPhone, userdata4.officePhone,
                       userdata4.extension)
     courseData = COURSE.objects.get(courseNumber=500)
     course = Course.Course(courseData.id, courseData.name,
                            courseData.courseNumber, courseData.classNumber,
                            courseData.time, courseData.location)
     print(user.permission[1])
     self.assertTrue(user.permission[1] == '1')
     self.assertTrue(user2.permission[1] == '2')
     self.assertTrue(user3.permission[1] != '1')
     self.assertTrue(user3.permission[1] != '2')
     self.assertTrue(user4.permission[1] != '1',
                     "Not Authorized To Use This Command")
     self.assertTrue(user4.permission[1] != '2',
                     "Not Authorized To Use This Command")
     self.user = user
     self.assertEqual(
         Terminal.accessData(self),
         str(user.permission) + " " + user.username + " " + user.password +
         " " + str(user.databaseID) + " " + user.email + " " +
         user.firstName + " " + user.lastName + " " + user.contactPhone +
         " " + user.officePhone + " " + user.extension + "\n " +
         str(user2.permission) + " " + user2.username + " " +
         user2.password + " " + str(user2.databaseID) + " " + user2.email +
         " " + user2.firstName + " " + user2.lastName + " " +
         user2.contactPhone + " " + user2.officePhone + " " +
         user2.extension + "\n " + str(user3.permission) + " " +
         user3.username + " " + user3.password + " " +
         str(user3.databaseID) + " " + user3.email + " " + user3.firstName +
         " " + user3.lastName + " " + user3.contactPhone + " " +
         user3.officePhone + " " + user3.extension + "\n " +
         str(user4.permission) + " " + user4.username + " " +
         user4.password + " " + str(user4.databaseID) + " " + user4.email +
         " " + user4.firstName + " " + user4.lastName + " " +
         user4.contactPhone + " " + user4.officePhone + " " +
         user4.extension + "\n " + str(course.databaseID) + " " +
         course.name + " " + str(course.courseNumber) + " " +
         str(course.classNumber) + " " + str(course.labList) + " " +
         course.time + " " + course.location)
예제 #26
0
    def test_setUsername(self):
        user = User()

        user.setUsername("username")
        self.assertEquals("username", user.username)

        with self.asserRaises(ValueError):
            user.setUsername(True)
            user.setUsername(1)
            user.setUsername(1, "this")
            user.setUsername({})
            user.setUsername(35)
            user.setUsername(4.5)
            user.setUsername([42])
예제 #27
0
    def test_getUsername(self):
        user = User(username="******")
        self.assertEquals("username", user.getUsername())

        user = User(username=None)
        self.assertEquals(None, user.getUsername())
예제 #28
0
    def test_setPassword(self):
        user = User()

        user.setPassword("password")
        self.assertEquals("password", user.password)

        with self.asserRaises(ValueError):
            user.setPassword(True)
            user.setPassword(1)
            user.setPassword(1, "this")
            user.setPassword({})
            user.setPassword(35)
            user.setPassword(4.5)
            user.setPassword([42])
예제 #29
0
    def test_getOfficePhone(self):
        user = User(officePhone="2223334444")
        self.assertEquals("2223334444", user.getOfficePhone())

        user = User(officePhone=None)
        self.assertEquals(None, user.getOfficePhone())
예제 #30
0
    def test_getFirstName(self):
        user = User(firstName="John")
        self.assertEquals("John", user.getFirstName())

        user = User(firstName=None)
        self.assertEquals(None, user.getFirstName())