Ejemplo n.º 1
0
class TestUser(unittest.TestCase):
    '''
    Test class that defines test cases for the user class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    '''
    def setUp(self):
        '''
        Method to run before each user test cases.
        '''
        self.new_user = User("FeistyDory", "210sda38")

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_user.username, "FeistyDory")
        self.assertEqual(self.new_user.password, "210sda38")

    def test_save_user(self):
        '''
        test case to test if a new user object has been saved into the User list
        '''

        self.new_user.save_user()
        self.assertEqual(len(User.user_list), 1)
Ejemplo n.º 2
0
 def setUp(self):
     """
     Method that runs before each individual test methods run.
     """
     self.user = User('WangechiKimani', '123Pass')
     self.credentials = Credentials('instagram', 'WangechiKimani',
                                    '123Pass')
Ejemplo n.º 3
0
class TestUser(unittest.TestCase):
    '''
    Test class that defines test cases for the user class behaviours.
    Args:
        unittest.TestCase: helps in creating test cases
    '''
    def setUp(self):
        '''
        Function to create a user account before each test
        '''
        self.new_user = User('Ngigi', 'Kariuki', 'pswd100')

    def test__init__(self):
        '''
        Test to if check the initialization/creation of user instances is properly done
        '''
        self.assertEqual(self.new_user.first_name, 'Ngigi')
        self.assertEqual(self.new_user.last_name, 'Kariuki')
        self.assertEqual(self.new_user.password, 'pswd100')

    def test_save_user(self):
        '''
        Test to check if the new users info is saved into the users list
        '''
        self.new_user.save_user()
        self.assertEqual(len(User.users_list), 1)
Ejemplo n.º 4
0
def handleSignUp():
    '''
    A function that will handle our signup for a new user
    '''
    result = "login"

    println('Sign Up')

    while True:
        username = read('Username')

        if len(username) == 0:
            print_error(
                "Empty username is not allowed. Please enter valid username.")
        if User.user_exist(username) == True:
            print_error(
                "The username {0} is already taken. Please enter another name."
                .format(username))
        else:
            break

    while True:
        password = read('Password')

        if len(password) == 0:
            print_error(
                "Empty password is not allowed. Please enter valid password.")
        else:
            break

    user = User(username, password)

    save_user(user)

    return result
Ejemplo n.º 5
0
    def test_save_multiple_user(self):

        self.new_user.save_user()
        test_user = User("Test_user","password")#new user

        test_user.save_user()
        self.assertEqual(len(User.user_List),2)
Ejemplo n.º 6
0
    def test_view_detail(self):
        # self.new_account.new_details()
        test_detail = User("Instagram", "styles", "password")
        test_detail.save_details()

        viewing = User.view_detail("Instagram")
        
        self.assertEqual(viewing.account_user, test_detail.account_user)
Ejemplo n.º 7
0
    def test_copy_email(self):
        '''
        test to confirm that we are copying email from found user
        '''
        self.new_user.save_user()
        User.copy_email("Instagram")

        self.assertEqual(self.new_user.email, pyperclip.paste())
Ejemplo n.º 8
0
    def test_copy_password(self):
        '''
        Test if the copy password function works
        '''
        self.new_data.add_password()
        User.copy_password(1, 1)

        self.assertEqual(self.new_data.app_key, pyperclip.paste())
Ejemplo n.º 9
0
 def setUp(self):
     '''
     Set Up method to run before each test cases.
     '''
     self.new_user = User("Derrick", "Kariuki", "0718016066",
                          "*****@*****.**")  # creates user object
     self.new_account = Credentials(
         "Instagram", "dero1234")  # creates credentials object
Ejemplo n.º 10
0
 def test_save_multiple_user(self):
     '''
     test_save_multiple_user to check if we can save multiple users object to our lists
     '''
     self.new_user.save_user()
     test_user = User("Roman", "Facebook", "@roman.com", "reigns18")
     test_user.save_user()
     self.assertEqual(len(User.user_list), 2)
Ejemplo n.º 11
0
 def test_save_multiple_user(self):
     '''
         test_save_multiple_contact to check if we can save multiple contact
         objects to our contact_list
         '''
     self.new_user.save_user()
     test_user = User("fname", "abc123")  # new user
     test_user.save_user()
     self.assertEqual(len(User.user_list), 2)
Ejemplo n.º 12
0
    def test_delete_user(self):

        self.new_user.save_user()
        test_user = User("Test_user","password")

        test_user.save_user()
        self.new_user.delete_user() #del user

        self.assertEqual(len(User.user_List),1)
Ejemplo n.º 13
0
    def test_data_exists(self):
        '''
        Test to check if the function for checking data works 
        '''
        self.new_data.add_password()
        test_data = User(1, 1, "facebook.com", "tpgh")
        test_data.add_password()

        data_exists = User.existing_data(1)
        self.assertTrue(data_exists)
Ejemplo n.º 14
0
    def test_save_multiple_user(self):
        '''
        test_save_multiple_user to check if we can save multiple user objects to our user_list 
        '''

        self.new_user.save_user()
        test_user = User("Test", "user", "0712345678",
                         "*****@*****.**")  # the new user
        test_user.save_user()
        self.assertEqual(len(User.user_list), 2)
Ejemplo n.º 15
0
    def test_delete_user(self):
        '''
        test_delete_user to test if we can remove a user from our user_list
        '''
        self.new_user.save_user()
        test_user = User("feven", "a1b1c1")  # new user
        test_user.save_user()

        self.new_user.delete_user()  # Deleting a user object
        self.assertEqual(len(User.user_list), 1)
Ejemplo n.º 16
0
    def test_delete_user(self):
        """
        test_delete_user to test if we can remove a user from our users list
        """
        self.created_user.save_user()
        test_user = User("Kevin", "1050")
        test_user.save_user()

        self.created_user.delete_user()
        self.assertEqual(len(User.user_list), 1)
Ejemplo n.º 17
0
    def test_user_exists(self):
        '''
        test to check if we can return a boolean if cannot find the contact.
        '''
        self.new_user.save_user()
        test_user = User("Roman", "Facebook", "@roman.com", "reigns18")
        test_user.save_user()

        user_exists = User.user_exist("Facebook")
        self.assertTrue(user_exists)
Ejemplo n.º 18
0
    def test_display_data(self):
        '''
        Test if data can be displayed.
        '''
        self.new_data.add_password()
        test_data = User(1, 1, "facebook.com", "poiii")
        test_data.add_password()

        data_found = User.display_data(1, 1)
        self.assertEqual(data_found.app_name, test_data.app_name)
Ejemplo n.º 19
0
    def test_find_user_by_account_name(self):
        '''
        test to check if we can find user by account name and display information
        '''
        self.new_user.save_user()
        test_user = User("Roman", "Facebook", "@roman.com", "reigns18")
        test_user.save_user()

        found_user = User.find_by_account_name("Facebook")
        self.assertEqual(found_user.password, test_user.password)
Ejemplo n.º 20
0
    def test_delete_user(self):
        '''
        test_delete_contact to test if we can remove a contact from our contact list
        '''
        self.new_user.save_user()
        test_user = User("Roman", "Facebook", "@roman.com", "reigns18")
        test_user.save_user()

        self.new_user.delete_user()
        self.assertEqual(len(User.user_list), 1)
Ejemplo n.º 21
0
    def test_user_exists(self):
        '''
        test to check if we can return a Boolean if we cannot find the user.
        '''

        self.new_user.save_user()
        test_user = User("Test", "user", "0711223344", "test@user")  #new user
        test_user.save_user()

        user_exists = User.user_exist("0711223344")
        self.assertTrue(user_exists)
Ejemplo n.º 22
0
    def test_users_exists(self):
        '''
        returns boolean if users not found test
        '''
        self.new_user.save_user()
        test_user  = User("test_user","password",)

        test_user.save_user()
        user_exists = User.user_exist("test")
        
        self.assertTrue(user_exists)
Ejemplo n.º 23
0
    def test_delete_user(self):
        '''
        test_delete_user to test if we can remove a user from our user list 
        '''

        self.new_user.save_user()
        test_user = User("Test", "user", "0712345678",
                         "*****@*****.**")  # new user
        test_user.save_user()

        self.new_user.delete_user()  # Deleting a user object
        self.assertEqual(len(User.user_list), 1)
Ejemplo n.º 24
0
    def test_find_account_by_login(self):
        '''
        test to check if we can find an account by login name
        '''

        self.new_account.save_account()
        test_account = User("lulumuts","VXg@!9")#new accounts
        test_account.save_account()

        found_account=User.find_account_by_login("VXg@!9")

        self.assertEqual(found_account.login,test_account.login)
Ejemplo n.º 25
0
    def test_user_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the user.
        '''

        self.new_user.save_user()
        test_user = User("feven", "a1b1c1")  # new user
        test_user.save_user()

        user_exists = User.user_exist("feven")

        self.assertTrue(user_exists)
Ejemplo n.º 26
0
def loadTestData():
    '''
    A function to load test data for development
    '''
    save_user(User('fev', '123'))
    save_credential(Credential('fev', 'Facebook', 'fev', 'feb4fev'))
    save_credential(Credential('fev', 'Facebook', 'fev2', 'feb4fev2'))
    save_credential(Credential('fev', 'Gmail', 'fev', 'gm4fev'))

    save_user(User('sim', '456'))
    save_credential(Credential('sim', 'Facebook', 'sim', 'feb4sim'))
    save_credential(Credential('sim', 'Gmail', 'sim', 'gm4sim'))
    save_credential(Credential('sim', 'Instagram', 'sim', 'insta4sim'))
Ejemplo n.º 27
0
    def test_find_user_by_number(self):
        '''
        test to check if we can find a user by phone number and display information
        '''

        self.new_user.save_user()
        test_user = User("Test", "user", "0711223344",
                         "*****@*****.**")  # new user
        test_user.save_user()

        found_user = User.find_by_number("0711223344")

        self.assertEqual(found_user.email, test_user.email)
Ejemplo n.º 28
0
class TestUsers(unittest.TestCase):
    '''
    Class to test application behaviour
    '''

    def setUp(self):
        '''
        Set's up user details
        '''

        self.new_account = User("Twitter", "minion", "21213")
    
    def tearDown(self):
        '''
        tearDown method that does a clean up after each test case has run
        '''
        User.store = []
    
    def test_init(self):
        self.assertEqual(self.new_account.account_name, "Twitter")
        self.assertEqual(self.new_account.account_user, "minion")
        self.assertEqual(self.new_account.account_password, "21213")
    
    def test_save_details(self):
        '''
        Test to see if the credentials are saved
        '''

        self.new_account.save_details()
        self.assertEqual(len(User.store), 1)
    
    def test_view_details(self):
        '''
        Test to see if you can view stored details
        '''

        self.assertEqual(User.view_details(), User.store)
    
    def test_view_detail(self):
        # self.new_account.new_details()
        test_detail = User("Instagram", "styles", "password")
        test_detail.save_details()

        viewing = User.view_detail("Instagram")
        
        self.assertEqual(viewing.account_user, test_detail.account_user)
    
    def test_delete_detail(self):
        User.delete_detail("Twitter")

        self.assertEqual(len(User.store), 0)
Ejemplo n.º 29
0
class TestClass(unittest.TestCase):
    """
    A Test class that defines test cases for the User class.
    """
    def setUp(self):
        """
        Method that runs before each individual test methods run.
        """
        self.user = User('WangechiKimani', '123Pass')
        self.credentials = Credentials('instagram', 'WangechiKimani',
                                       '123Pass')

    def test_init(self):
        """
        test case to check if the object has been initialized correctly
        """
        self.assertEqual(self.user.username, 'WangechiKimani')
        self.assertEqual(self.user.password, '123Pass')

    def test_save_user(self):
        """
        test case to test if a new user instance has been saved into the User list
        """
        self.user.save_user()
        self.assertGreater(len(User.user_list), 0)

    def test_get_user(self):
        self.user.save_user()
        self.assertIsNot(User.get_user(User('WangechiKimani', '123Pass')),
                         False)

    def test_save_credentials(self):
        self.credentials.save_credential()
        self.assertGreater(len(Credentials.credentials_list), 0)

    def test_generate_random_password_with_predefined_length(self):
        credentials = Credentials('twitter', 'WangechiKimani')
        password = credentials.generate_random_password(2)
        self.assertEqual(len(password), 2)

    def test_generate_random_password_with_standard_length(self):
        credentials = Credentials('twitter', 'WangechiKimani')
        password = credentials.generate_random_password()
        self.assertEqual(len(password), 10)

    def test_find_credentials(self):
        self.credentials.save_credential()
        self.assertEqual(len(self.user.find_credentials()), 0)
Ejemplo n.º 30
0
def create_user(luname,upassword):
    '''
    function create new user
    '''
    new_user = User(luname,upassword)

    return new_user