Пример #1
0
 def test_search_social_media(self):
     '''
     Test to confirm if the method returns the correct social media credential
     '''
     self.new_credential.save_credentials()
     facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented')
     facebook.save_credentials()
     credential_exists = Credential.search_social_media('Facebook')
     self.assertEqual(credential_exists, facebook)
Пример #2
0
 def test_display_credentials(self):
     '''
     Test to confirm user can view the correct credential details
     '''
     self.new_credential.save_credentials()
     facebook = Credential('cyrian', 'facebook', 'cyrian254', 'contented')
     facebook.save_credentials()
     self.assertEqual(Credential.display_credentials(),
                      Credential.credentials_list)
Пример #3
0
 def test_display_credentials(self):
     '''
     method that returns a list of all credentials saved
     '''
     self.new_credential.save_credentials()
     test_fb = Credential('sam','facebook','matta','123456')
     test_fb.save_credentials()
     
     self.assertEqual(Credential.display_credentials(User),Credential.user_credentials_list)
Пример #4
0
 def test_save_multiple_credentials(self):
     '''
     test_save_multiple_credential to check if we can save multiple credentials
     objects to our credentials_list
     '''
     self.new_credential.save_credentials()
     test_credential = Credential("sam1","Medium","matta1","112233") # new credential
     test_credential.save_credentials()
     
     self.assertEqual(len(Credential.credentials_list),2)
Пример #5
0
    def test_find_by_site_name(self):
        '''
		Test to check if we can find a credential by site_name
		'''
        self.new_credential.save_credentials()
        test_fb = Credential('Joseph', 'facebook', 'josylad', '123456')
        test_fb.save_credentials()

        credential_exists = Credential.find_by_site_name('facebook')
        self.assertEqual(credential_exists, test_fb)
Пример #6
0
def create_credential(user_name, social_media, account_name, password):
    '''
    Function creating new credentials
    '''
    new_credential = Credential(user_name, social_media, account_name,
                                password)
    return new_credential
Пример #7
0
 def test_confirm_user(self):
     '''
     Function to confirm login details to active user
     '''
     self.new_user = User('Norah', 'Shako', 'sugar')
     self.new_user.save_user()
     userX = User('Norah', 'Shako', 'sugar')
     userX.save_user()
     active_user = Credential.confirm_user('Norah', 'Shako', 'angry')
     self.assertTrue(active_user)
Пример #8
0
 def test_copy_password(self):  #uses pyperclip
     '''
     Test to check if the copy password method will copy the correct password from social media site specified
     '''
     self.new_credential.save_credentials()
     facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented')
     facebook.save_credentials()
     Credential.copy_password('facebook')
     self.assertEqual(self.new_credential.password, pyperclip.paste())
Пример #9
0
    def test_copy_credential(self):
        '''
		Test to confirm if we can copy a credential from saved credentials
		'''
        self.new_credential.save_credentials()
        test_fb = Credential('Joseph', 'facebook', 'josylad', '123456')
        test_fb.save_credentials()
        Credential.copy_credential('123456')

        self.assertEqual(self.new_credential.password, pyperclip.paste())
        print(pyperclip.paste())
Пример #10
0
def display_credentials(username):
	'''
	Function to display saved credentials
	'''
	return Credential.display_credentials(username)
Пример #11
0
def del_credential(site_name):
    '''
    Function to delete a credential
    '''
    Credential.delete_credentials()
Пример #12
0
def save_credential(credential):
	'''
	Function to save a newly created credential
	'''
	Credential.save_credentials(credential)
Пример #13
0
def create_credential(username, site_name, account_name, password):
	'''
	Function to create a new credential
	'''
	new_credential = Credential(username, site_name, account_name, password)
	return new_credential
Пример #14
0
def check_existing_site(site_name):
    '''
    Function that check if a credential exists with that site_name and return a Boolean
    '''
    return Credential.find_by_site_name(site_name)
Пример #15
0
 def setUp(self):
     '''
     Function to create social media account credentials before each test
     '''
     self.new_credential = Credential('cyrian', 'facebook', 'cyrian254',
                                      'contented')
Пример #16
0
def authenticate_user(first_name, password):
    '''
    Function to verify user is enabled before launching the credentials
    '''
    confirm_user = Credential.confirm_user(first_name, password)
    return confirm_user
Пример #17
0
    def setUp(self):
        '''
		Setup method to run before each test case
		'''
        self.new_credential = Credential('Joseph', 'FB.com', 'Josylad',
                                         '123456')
Пример #18
0
class TestCredentials(unittest.TestCase):
    '''
    Test class that defines the test cases for the the credential class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    '''
    def setUp(self):
        '''
		Setup method to run before each test case
		'''
        self.new_credential = Credential('Joseph', 'FB.com', 'Josylad',
                                         '123456')

    def test__init__(self):
        '''
		Test to check if the initialization/creation of credential instances is properly done
		'''
        self.assertEqual(self.new_credential.username, 'Joseph')
        self.assertEqual(self.new_credential.site_name, 'FB.com')
        self.assertEqual(self.new_credential.account_name, 'Josylad')
        self.assertEqual(self.new_credential.password, '123456')

    def test_save_credentials(self):
        '''
        test_save_credentials test case to test if the credential object is saved into
         the credential list
        '''
        self.new_credential.save_credentials()  # saving the new credential

        self.assertEqual(len(Credential.credentials_list), 1)

    def test_save_multiple_credentials(self):
        '''
        test_save_multiple_credential to check if we can save multiple credentials
        objects to our credentials_list
        '''
        self.new_credential.save_credentials()
        test_credential = Credential("Joe", "Medium", "Josylad",
                                     "112233")  # new credential
        test_credential.save_credentials()

        self.assertEqual(len(Credential.credentials_list), 2)

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

    def test_find_by_site_name(self):
        '''
		Test to check if we can find a credential by site_name
		'''
        self.new_credential.save_credentials()
        test_fb = Credential('Joseph', 'facebook', 'josylad', '123456')
        test_fb.save_credentials()

        credential_exists = Credential.find_by_site_name('facebook')
        self.assertEqual(credential_exists, test_fb)

    def test_display_credentials(self):
        '''
        method that returns a list of all credentials saved
        '''
        self.new_credential.save_credentials()
        test_fb = Credential('Joseph', 'facebook', 'josylad', '123456')
        test_fb.save_credentials()

        self.assertEqual(Credential.display_credentials(User),
                         Credential.user_credentials_list)

    def test_copy_credential(self):
        '''
		Test to confirm if we can copy a credential from saved credentials
		'''
        self.new_credential.save_credentials()
        test_fb = Credential('Joseph', 'facebook', 'josylad', '123456')
        test_fb.save_credentials()
        Credential.copy_credential('123456')

        self.assertEqual(self.new_credential.password, pyperclip.paste())
        print(pyperclip.paste())
Пример #19
0
class TestCredentials(unittest.TestCase):
    '''
    Test class that defines test cases for the credentials class behaviours
    Args:
        unittest.TestCase: Testcase class that helps create test cases
    '''
    def test_confirm_user(self):
        '''
        Function to confirm login details to active user
        '''
        self.new_user = User('Norah', 'Shako', 'sugar')
        self.new_user.save_user()
        userX = User('Norah', 'Shako', 'sugar')
        userX.save_user()
        active_user = Credential.confirm_user('Norah', 'Shako', 'angry')
        self.assertTrue(active_user)

    def setUp(self):
        '''
        Function to create social media account credentials before each test
        '''
        self.new_credential = Credential('cyrian', 'facebook', 'cyrian254',
                                         'contented')

    def test__init__(self):
        '''
        Confirm that instance of credentials creation is as expected
        '''
        self.assertEqual(self.new_credential.user_name, 'cyrian')
        self.assertEqual(self.new_credential.social_media, 'facebook')
        self.assertEqual(self.new_credential.account_name, 'cyrian254')
        self.assertEqual(self.new_credential.password, 'contented')

    def test_save_credentials(self):
        '''
        Test and confirm that the new credential information is being saved
        '''
        self.new_credential.save_credentials()
        self.assertEqual(len(Credential.credentials_list), 1)

    def tearDown(self):
        '''
        tearDown method that executes a set of instructions after every test
        '''
        User.users_list = []
        Credential.credentials_list = []

    def test_display_credentials(self):
        '''
        Test to confirm user can view the correct credential details
        '''
        self.new_credential.save_credentials()
        facebook = Credential('cyrian', 'facebook', 'cyrian254', 'contented')
        facebook.save_credentials()
        self.assertEqual(Credential.display_credentials(),
                         Credential.credentials_list)

    def test_search_social_media(self):
        '''
        Test to confirm if the method returns the correct social media credential
        '''
        self.new_credential.save_credentials()
        facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented')
        facebook.save_credentials()
        credential_exists = Credential.search_social_media('Facebook')
        self.assertEqual(credential_exists, facebook)

    def test_copy_password(self):  #uses pyperclip
        '''
        Test to check if the copy password method will copy the correct password from social media site specified
        '''
        self.new_credential.save_credentials()
        facebook = Credential('cyrian', 'Facebook', 'cyrian254', 'contented')
        facebook.save_credentials()
        Credential.copy_password('facebook')
        self.assertEqual(self.new_credential.password, pyperclip.paste())
Пример #20
0
def find_credential(site_name):
    '''
    Function that finds a contact by number and returns the contact
    '''
    return Credential.find_by_site_name(site_name)
Пример #21
0
def copy_credential(site_name):
	'''
	Function to copy a credentials details to the clipboard
	'''
	return Credential.copy_credential(site_name)
Пример #22
0
def display_credentials():
    '''
    Function to display_credentials saved by user
    '''
    return Credential.display_credentials()
Пример #23
0
def generate_password():
    '''
    Function to automatically gen password
    '''
    gen_pwd = Credential.generate_password()
    return gen_pwd
Пример #24
0
    def setUp(self):
        '''
		Setup method to run before each test case
		'''
        self.new_credential = Credential('sam','FB.com','matta','123456')
Пример #25
0
def save_credential(credential):
    '''
    Saves new credentials
    '''
    Credential.save_credentials(credential)
Пример #26
0
def verify_user(first_name, password):
	'''
	Function that verifies the existence of the user before creating credentials
	'''
	check_user = Credential.check_user(first_name, password)
	return check_user
Пример #27
0
def copy_password(social_media):
    '''
    Function to copy credential details and paste then in clipboard
    '''
    return Credential.copy_password(social_media)
Пример #28
0
def generate_password():
	'''
	Function to generate a password automatically
	'''
	password_gen = Credential.generate_password()
	return password_gen