def test_save_credentials(self): ''' Test for credential info ''' self.new_credential.save_credentials() instagram = Credentials('Rose','Instagram','inst@') instagram.save_credentials() self.assertEqual(len(Credentials.credentials),2)
class TestCredentials(unittest.TestCase): ''' Test class for the credentials class ''' def test_check_user(self): ''' Function to verify whether the function check_user works ''' self.new_user = User('Rose','rudim3nt@l') self.new_user.save_user() user2 = User('Rio','3liz@b3th') user2.save_user() for user in User.users: if user.username == user2.username and user.password == user2.password: current_user = user.username return current_user self.assertEqual(current_user,Credentials.check_user(user2.password,user2.username)) def setUp(self): ''' Function for creating account creds before test ''' self.new_credential = Credentials('Rose','Instagram','inst@') def test__init__(self): ''' Test to check on new credentials ''' self.assertEqual(self.new_credential.name,'Rose') self.assertEqual(self.new_credential.site_name,'Instagram') self.assertEqual(self.new_credential.password,'inst@') def test_save_credentials(self): ''' Test for credential info ''' self.new_credential.save_credentials() instagram = Credentials('Rose','Instagram','inst@') instagram.save_credentials() self.assertEqual(len(Credentials.credentials),2) def tearDown(self): ''' Function for clearing creds list after every test ''' Credentials.credentials = [] User.users = []
def test_check_user(self): ''' Function to verify whether the function check_user works ''' self.new_user = User('Rose','rudim3nt@l') self.new_user.save_user() user2 = User('Rio','3liz@b3th') user2.save_user() for user in User.users: if user.username == user2.username and user.password == user2.password: current_user = user.username return current_user self.assertEqual(current_user,Credentials.check_user(user2.password,user2.username))
def copy_credential(site_name): ''' Function for copying credentials to the clipboard ''' return Credentials.copy_credential(site_name)
def display_credentials(name): ''' Function for the credentials saved by the user ''' return Credentials.display_credentials(name)
def save_credential(credential): ''' Function to save a new credential ''' Credentials.save_credentials(credential)
def create_credential(name, site_name, password): ''' Function for new credentials ''' new_credential = Credentials(name, site_name, password) return new_credential
def generate_password(): ''' Function for automatic passwords ''' gen_pass = Credentials.generate_password() return gen_pass
def verify_user(username, password): ''' Function for user verification ''' verifying_user = Credentials.check_user(username, password) return verifying_user
def setUp(self): ''' Function for creating account creds before test ''' self.new_credential = Credentials('Rose','Instagram','inst@')