Exemplo n.º 1
0
 def test_insertUser(self):
     with UserDatabaseUtils(self.connection) as db:
         count = self.countUser()
         self.assertTrue(db.insertUser('Vincent','Pranata','*****@*****.**',"s3665858",'abcd','a'))
         self.assertTrue(count + 1 == self.countUser())
         self.assertTrue(db.insertUser('Sean','Tan','*****@*****.**','test','1111','a'))
         self.assertTrue(count + 2 == self.countUser())
Exemplo n.º 2
0
    def test_deleteUser(self):
        with UserDatabaseUtils(self.connection) as db:
            count = self.countUser()
            userID = 1

            self.assertTrue(self.userExists(userID))

            db.deleteUser(userID)

            self.assertFalse(self.userExists(userID))
            self.assertTrue(count - 1 == self.countUser())
Exemplo n.º 3
0
 def login(self, username, password):
     # constant name and hashed password to imitate stored username and encrypted password
     with UserDatabaseUtils() as db:
         for user in db.getUser():
             find = False
             if user[1] == username and self.verify_password(
                     user[2], password):
                 find = True
                 break
             else:
                 find = False
         return find
Exemplo n.º 4
0
 def searchUsers(self, column, search):
     with UserDatabaseUtils() as db:
         if column == "username":
             return db.searchUsersbyUsername(
                 search.lower())  #.lower() makes it lowercase
         elif column == "firstname":
             return db.searchUsersbyFirstName(search.lower())
         elif column == "lastname":
             return db.searchUsersbyLastName(search.lower())
         elif column == "email":
             return db.searchUsersbyEmail(search.lower())
         elif column == "type":
             account_type = 'z'
             if search == "admin":
                 account_type = 'a'
             elif search == "customer":
                 account_type = 'c'
             elif search == "engineer":
                 account_type = 'e'
             elif search == "manager":
                 account_type = 'm'
             return db.searchUsersbyType(account_type)
Exemplo n.º 5
0
 def deleteUser(self, userID):
     with UserDatabaseUtils() as db:
         db.deleteUser(userID)
Exemplo n.º 6
0
 def register(self, username, password, fname, lname, email):
     with UserDatabaseUtils() as db:
         db.insertUser(username, self.hash_password(password), fname, lname,
                       email, 'c')
Exemplo n.º 7
0
 def listUsers(self):
     with UserDatabaseUtils() as db:
         return db.getUser()
Exemplo n.º 8
0
 def getOtherUser(self, userID):
     with UserDatabaseUtils() as db:
         return db.getOtherUser(userID)
Exemplo n.º 9
0
 def getUser(self, username):
     with UserDatabaseUtils() as db:
         for user in db.getUser():
             if user[1] == username:
                 return user
Exemplo n.º 10
0
 def createUserTable(self):
     with UserDatabaseUtils() as db:
         db.createUserTable()
Exemplo n.º 11
0
 def updateUser(self, userID, name, password, fname, lname, email,
                acc_type):
     with UserDatabaseUtils() as db:
         db.updateUser(userID, name, self.hash_password(password), fname,
                       lname, email, acc_type)
Exemplo n.º 12
0
 def getUserDetails(self, userID):
     with UserDatabaseUtils() as db:
         return db.getUserDetails(int(userID))
Exemplo n.º 13
0
 def test_getUser(self):
     with UserDatabaseUtils(self.connection) as db:
         self.assertTrue(self.countUser() == len(db.getUser()))