Пример #1
0
 def setUp(self):
     '''
     python will run this instruction every time
     it encounters a new method
     '''
     self.new_user = Users("Edgar","pass123")
     self.new_credential = Credentials("facebook", "ekibe", "pass123")
Пример #2
0
 def test_save_multiple_accounts(self):
     '''
         test_save_multiple_contact to check if we can save multiple contact
         objects to our contact_list
         '''
     self.new_user_data.save_account()
     test_account = Users("account", "username", "*****@*****.**",
                          "password")  #regestering a new account
     test_account.save_account()
     self.assertEqual(len(Users.account_details), 2)
Пример #3
0
    def test_delete_account(self):
        '''
            test_delete_account to test if we can remove a saved account from our account details list
            '''
        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  # registered new account
        test_account.save_account()

        self.new_user_data.delete_account()
        self.assertEqual(len(Users.account_details), 1)
Пример #4
0
    def test_account_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the account details.
        '''

        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  #registered new account
        test_account.save_account()

        account_exists = Users.account_exist("username")

        self.assertTrue(account_exists)
Пример #5
0
    def test_find_details_by_username(self):
        '''
        test to check if we can find the details of an account by typing the username and display information
        '''

        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  #registered new account
        test_account.save_account()

        found_account = Users.find_by_username("username")

        self.assertEqual(found_account.email, test_account.email)
Пример #6
0
 def test_user_with_an_account_can_login(self):
     
     '''
     test to check if a user exists
     '''
     self.new_user.save_user()
     user_exist  = Users.find_by_username("Edgar")
     self.assertTrue(user_exist)  
Пример #7
0
 def test_user_with_an_account_can_login(self):
     
     '''
     tests if user can log in using the credentials already saved 
     in users list
     '''
     self.new_user.save_user()
     validate_user = Users.check_user("Edgar","pass123")
     self.assertEqual(validate_user, self.new_user.user_name)
Пример #8
0
class UserTestCases(unittest.TestCase):

    def tearDown(self):
        Users.users_list=[]
        '''
        clears the users list before next method
        '''

    def setUp(self):
        '''
        python will run this instruction every time
        it encounters a new method
        '''
        self.new_user = Users("Edgar","pass123")
        self.new_credential = Credentials("facebook", "ekibe", "pass123")
    def test_if_user_can_create_an_account(self):

        '''
        tests if created user account is saved
        in the list
        '''

        self.new_user.save_user()
        self.assertEqual(len(Users.users_list),1)
    def test_user_with_an_account_can_login(self):
        
        '''
        test to check if a user exists
        '''
        self.new_user.save_user()
        user_exist  = Users.find_by_username("Edgar")
        self.assertTrue(user_exist)  

    def test_user_with_an_account_can_login(self):
        
        '''
        tests if user can log in using the credentials already saved 
        in users list
        '''
        self.new_user.save_user()
        validate_user = Users.check_user("Edgar","pass123")
        self.assertEqual(validate_user, self.new_user.user_name)
    
    # Tests credentials
    def test_if_user_can_create_credential(self):
        '''
        test if credentials_list gets appended with
        added credential
        '''
        self.new_credential.save_credential()
        self.assertEqual(len(Credentials.credentials_list),1)
Пример #9
0
def check_existing_accounts(username):
    '''
    Function that check if a contact exists with that number and return a Boolean
    '''
    return Users.account_exist(username)
Пример #10
0
def find_account(username):
    '''
    Function that finds account details using the username
    '''
    return Users.find_by_username(username)
Пример #11
0
def verify_user(uname, upass):
    '''
	Function that verifies the existance of the user before creating credentials
	'''
    checking_user = Users.check_user(uname, upass)
    return checking_user
Пример #12
0
def create_acc(u_name, u_pass):
    # u_pass= hashlib.new(u_pass)
    # encrypted_pass=sdigest(u_pass)
    new_acc = Users(u_name, u_pass)
    return new_acc
Пример #13
0
    def test_display_all_accounts(self):
        '''
        method that returns a list of all accounts saved
        '''

        self.assertEqual(Users.display_accounts(), Users.account_details)
Пример #14
0
class TestUsers(unittest.TestCase):
    '''
    Test class that defines test cases for the users class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    '''
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user_data = Users("Instagram", "@levim", "*****@*****.**",
                                   "axolotl")  # create contact object

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''

        self.assertEqual(self.new_user_data.account_name, "Instagram")
        self.assertEqual(self.new_user_data.username, "@levim")
        self.assertEqual(self.new_user_data.email, "*****@*****.**")
        self.assertEqual(self.new_user_data.password, "axolotl")

    def test_save_user_data(self):
        '''
        test_save_user_data test case to test if the users object is saved into
         the account details.
        '''
        self.new_user_data.save_account()  # saving the new account details
        self.assertEqual(len(Users.account_details), 1)

    def tearDown(self):
        '''
            tearDown method that does clean up after each test case has run.
            '''
        Users.account_details = []

    def test_save_multiple_accounts(self):
        '''
            test_save_multiple_contact to check if we can save multiple contact
            objects to our contact_list
            '''
        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  #regestering a new account
        test_account.save_account()
        self.assertEqual(len(Users.account_details), 2)

    def test_delete_account(self):
        '''
            test_delete_account to test if we can remove a saved account from our account details list
            '''
        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  # registered new account
        test_account.save_account()

        self.new_user_data.delete_account()
        self.assertEqual(len(Users.account_details), 1)

    def test_find_details_by_username(self):
        '''
        test to check if we can find the details of an account by typing the username and display information
        '''

        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  #registered new account
        test_account.save_account()

        found_account = Users.find_by_username("username")

        self.assertEqual(found_account.email, test_account.email)

    def test_account_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the account details.
        '''

        self.new_user_data.save_account()
        test_account = Users("account", "username", "*****@*****.**",
                             "password")  #registered new account
        test_account.save_account()

        account_exists = Users.account_exist("username")

        self.assertTrue(account_exists)

    def test_display_all_accounts(self):
        '''
        method that returns a list of all accounts saved
        '''

        self.assertEqual(Users.display_accounts(), Users.account_details)
Пример #15
0
def display_accounts():
    '''
    Function that returns all the saved contacts
    '''
    return Users.display_accounts()
Пример #16
0
def create_account(account_name,username,email,password):
    '''
    Function to create account detail
    '''
    new_account = Users(account_name,username,email,password)
    return new_account
Пример #17
0
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user_data = Users("Instagram", "@levim", "*****@*****.**",
                                "axolotl")  # create contact object